aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/omap/mcbsp.h
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2012-02-14 11:20:58 -0500
committerLiam Girdwood <lrg@ti.com>2012-03-12 09:34:19 -0400
commit45656b44f6d1968d838f3abcf3a264ee9fa2fc62 (patch)
treeaf489389d8565bdd83f756115239524814b902d9 /sound/soc/omap/mcbsp.h
parent219f43164e8c611c6b8e7b628def9183098b430b (diff)
ASoC: omap-mcbsp: Create a single driver for McBSP
The OMAP McBSP driver stack used to contain two different drivers. One of them was used as kind low-level access to the IP, while the other driver was the ASoC DAI driver. There were global, shared structures, in different places, the McBSP instances are reffered with id numbers (sometimes 0 based, in other cases 1 based id numbers). Create one single driver for OMAP McBSP with name: omap-mcbsp. Convert the old omap-mcbsp driver initially to be a library for the omap-mcbsp DAI driver. With this change we can get rid of all global variables, structures. Further cleanup is coming... Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Tested-by: Grazvydas Ignotas <notasas@gmail.com> Tested-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com> Signed-off-by: Liam Girdwood <lrg@ti.com>
Diffstat (limited to 'sound/soc/omap/mcbsp.h')
-rw-r--r--sound/soc/omap/mcbsp.h104
1 files changed, 81 insertions, 23 deletions
diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h
index 5590ab271eec..6d579938a154 100644
--- a/sound/soc/omap/mcbsp.h
+++ b/sound/soc/omap/mcbsp.h
@@ -24,6 +24,8 @@
24#ifndef __ASOC_MCBSP_H 24#ifndef __ASOC_MCBSP_H
25#define __ASOC_MCBSP_H 25#define __ASOC_MCBSP_H
26 26
27#include "omap-pcm.h"
28
27/* McBSP register numbers. Register address offset = num * reg_step */ 29/* McBSP register numbers. Register address offset = num * reg_step */
28enum { 30enum {
29 /* Common registers */ 31 /* Common registers */
@@ -257,36 +259,92 @@ struct omap_mcbsp_reg_cfg {
257 u16 rccr; 259 u16 rccr;
258}; 260};
259 261
260void omap_mcbsp_config(unsigned int id, 262struct omap_mcbsp_st_data {
263 void __iomem *io_base_st;
264 bool running;
265 bool enabled;
266 s16 taps[128]; /* Sidetone filter coefficients */
267 int nr_taps; /* Number of filter coefficients in use */
268 s16 ch0gain;
269 s16 ch1gain;
270};
271
272struct omap_mcbsp_data {
273 struct omap_mcbsp_reg_cfg regs;
274 struct omap_pcm_dma_data dma_data[2];
275 unsigned int fmt;
276 /*
277 * Flags indicating is the bus already activated and configured by
278 * another substream
279 */
280 int active;
281 int configured;
282 unsigned int in_freq;
283 int clk_div;
284 int wlen;
285};
286
287struct omap_mcbsp {
288 struct device *dev;
289 unsigned long phys_base;
290 unsigned long phys_dma_base;
291 void __iomem *io_base;
292 u8 id;
293 u8 free;
294
295 int rx_irq;
296 int tx_irq;
297
298 /* DMA stuff */
299 u8 dma_rx_sync;
300 u8 dma_tx_sync;
301
302 /* Protect the field .free, while checking if the mcbsp is in use */
303 spinlock_t lock;
304 struct omap_mcbsp_platform_data *pdata;
305 struct clk *fclk;
306 struct omap_mcbsp_st_data *st_data;
307 struct omap_mcbsp_data mcbsp_data;
308 int dma_op_mode;
309 u16 max_tx_thres;
310 u16 max_rx_thres;
311 void *reg_cache;
312 int reg_cache_size;
313};
314
315void omap_mcbsp_config(struct omap_mcbsp *mcbsp,
261 const struct omap_mcbsp_reg_cfg *config); 316 const struct omap_mcbsp_reg_cfg *config);
262void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold); 317void omap_mcbsp_set_tx_threshold(struct omap_mcbsp *mcbsp, u16 threshold);
263void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold); 318void omap_mcbsp_set_rx_threshold(struct omap_mcbsp *mcbsp, u16 threshold);
264u16 omap_mcbsp_get_max_tx_threshold(unsigned int id); 319u16 omap_mcbsp_get_max_tx_threshold(struct omap_mcbsp *mcbsp);
265u16 omap_mcbsp_get_max_rx_threshold(unsigned int id); 320u16 omap_mcbsp_get_max_rx_threshold(struct omap_mcbsp *mcbsp);
266u16 omap_mcbsp_get_fifo_size(unsigned int id); 321u16 omap_mcbsp_get_fifo_size(struct omap_mcbsp *mcbsp);
267u16 omap_mcbsp_get_tx_delay(unsigned int id); 322u16 omap_mcbsp_get_tx_delay(struct omap_mcbsp *mcbsp);
268u16 omap_mcbsp_get_rx_delay(unsigned int id); 323u16 omap_mcbsp_get_rx_delay(struct omap_mcbsp *mcbsp);
269int omap_mcbsp_get_dma_op_mode(unsigned int id); 324int omap_mcbsp_get_dma_op_mode(struct omap_mcbsp *mcbsp);
270int omap_mcbsp_request(unsigned int id); 325int omap_mcbsp_request(struct omap_mcbsp *mcbsp);
271void omap_mcbsp_free(unsigned int id); 326void omap_mcbsp_free(struct omap_mcbsp *mcbsp);
272void omap_mcbsp_start(unsigned int id, int tx, int rx); 327void omap_mcbsp_start(struct omap_mcbsp *mcbsp, int tx, int rx);
273void omap_mcbsp_stop(unsigned int id, int tx, int rx); 328void omap_mcbsp_stop(struct omap_mcbsp *mcbsp, int tx, int rx);
274 329
275/* McBSP functional clock source changing function */ 330/* McBSP functional clock source changing function */
276int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id); 331int omap2_mcbsp_set_clks_src(struct omap_mcbsp *mcbsp, u8 fck_src_id);
277 332
278/* McBSP signal muxing API */ 333/* McBSP signal muxing API */
279void omap2_mcbsp1_mux_clkr_src(u8 mux); 334void omap2_mcbsp1_mux_clkr_src(struct omap_mcbsp *mcbsp, u8 mux);
280void omap2_mcbsp1_mux_fsr_src(u8 mux); 335void omap2_mcbsp1_mux_fsr_src(struct omap_mcbsp *mcbsp, u8 mux);
281 336
282int omap_mcbsp_dma_ch_params(unsigned int id, unsigned int stream); 337int omap_mcbsp_dma_ch_params(struct omap_mcbsp *mcbsp, unsigned int stream);
283int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream); 338int omap_mcbsp_dma_reg_params(struct omap_mcbsp *mcbsp, unsigned int stream);
284 339
285/* Sidetone specific API */ 340/* Sidetone specific API */
286int omap_st_set_chgain(unsigned int id, int channel, s16 chgain); 341int omap_st_set_chgain(struct omap_mcbsp *mcbsp, int channel, s16 chgain);
287int omap_st_get_chgain(unsigned int id, int channel, s16 *chgain); 342int omap_st_get_chgain(struct omap_mcbsp *mcbsp, int channel, s16 *chgain);
288int omap_st_enable(unsigned int id); 343int omap_st_enable(struct omap_mcbsp *mcbsp);
289int omap_st_disable(unsigned int id); 344int omap_st_disable(struct omap_mcbsp *mcbsp);
290int omap_st_is_enabled(unsigned int id); 345int omap_st_is_enabled(struct omap_mcbsp *mcbsp);
346
347int __devinit omap_mcbsp_probe(struct platform_device *pdev);
348int __devexit omap_mcbsp_remove(struct platform_device *pdev);
291 349
292#endif /* __ASOC_MCBSP_H */ 350#endif /* __ASOC_MCBSP_H */