diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2012-02-14 20:20:58 +0400 |
---|---|---|
committer | Liam Girdwood <lrg@ti.com> | 2012-03-12 17:34:19 +0400 |
commit | 45656b44f6d1968d838f3abcf3a264ee9fa2fc62 (patch) | |
tree | af489389d8565bdd83f756115239524814b902d9 /sound/soc/omap/mcbsp.h | |
parent | 219f43164e8c611c6b8e7b628def9183098b430b (diff) | |
download | linux-45656b44f6d1968d838f3abcf3a264ee9fa2fc62.tar.xz |
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.h | 104 |
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 @@ #ifndef __ASOC_MCBSP_H #define __ASOC_MCBSP_H +#include "omap-pcm.h" + /* McBSP register numbers. Register address offset = num * reg_step */ enum { /* Common registers */ @@ -257,36 +259,92 @@ struct omap_mcbsp_reg_cfg { u16 rccr; }; -void omap_mcbsp_config(unsigned int id, +struct omap_mcbsp_st_data { + void __iomem *io_base_st; + bool running; + bool enabled; + s16 taps[128]; /* Sidetone filter coefficients */ + int nr_taps; /* Number of filter coefficients in use */ + s16 ch0gain; + s16 ch1gain; +}; + +struct omap_mcbsp_data { + struct omap_mcbsp_reg_cfg regs; + struct omap_pcm_dma_data dma_data[2]; + unsigned int fmt; + /* + * Flags indicating is the bus already activated and configured by + * another substream + */ + int active; + int configured; + unsigned int in_freq; + int clk_div; + int wlen; +}; + +struct omap_mcbsp { + struct device *dev; + unsigned long phys_base; + unsigned long phys_dma_base; + void __iomem *io_base; + u8 id; + u8 free; + + int rx_irq; + int tx_irq; + + /* DMA stuff */ + u8 dma_rx_sync; + u8 dma_tx_sync; + + /* Protect the field .free, while checking if the mcbsp is in use */ + spinlock_t lock; + struct omap_mcbsp_platform_data *pdata; + struct clk *fclk; + struct omap_mcbsp_st_data *st_data; + struct omap_mcbsp_data mcbsp_data; + int dma_op_mode; + u16 max_tx_thres; + u16 max_rx_thres; + void *reg_cache; + int reg_cache_size; +}; + +void omap_mcbsp_config(struct omap_mcbsp *mcbsp, const struct omap_mcbsp_reg_cfg *config); -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_fifo_size(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); -int omap_mcbsp_request(unsigned int id); -void omap_mcbsp_free(unsigned int id); -void omap_mcbsp_start(unsigned int id, int tx, int rx); -void omap_mcbsp_stop(unsigned int id, int tx, int rx); +void omap_mcbsp_set_tx_threshold(struct omap_mcbsp *mcbsp, u16 threshold); +void omap_mcbsp_set_rx_threshold(struct omap_mcbsp *mcbsp, u16 threshold); +u16 omap_mcbsp_get_max_tx_threshold(struct omap_mcbsp *mcbsp); +u16 omap_mcbsp_get_max_rx_threshold(struct omap_mcbsp *mcbsp); +u16 omap_mcbsp_get_fifo_size(struct omap_mcbsp *mcbsp); +u16 omap_mcbsp_get_tx_delay(struct omap_mcbsp *mcbsp); +u16 omap_mcbsp_get_rx_delay(struct omap_mcbsp *mcbsp); +int omap_mcbsp_get_dma_op_mode(struct omap_mcbsp *mcbsp); +int omap_mcbsp_request(struct omap_mcbsp *mcbsp); +void omap_mcbsp_free(struct omap_mcbsp *mcbsp); +void omap_mcbsp_start(struct omap_mcbsp *mcbsp, int tx, int rx); +void omap_mcbsp_stop(struct omap_mcbsp *mcbsp, int tx, int rx); /* McBSP functional clock source changing function */ -int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id); +int omap2_mcbsp_set_clks_src(struct omap_mcbsp *mcbsp, u8 fck_src_id); /* McBSP signal muxing API */ -void omap2_mcbsp1_mux_clkr_src(u8 mux); -void omap2_mcbsp1_mux_fsr_src(u8 mux); +void omap2_mcbsp1_mux_clkr_src(struct omap_mcbsp *mcbsp, u8 mux); +void omap2_mcbsp1_mux_fsr_src(struct omap_mcbsp *mcbsp, u8 mux); -int omap_mcbsp_dma_ch_params(unsigned int id, unsigned int stream); -int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream); +int omap_mcbsp_dma_ch_params(struct omap_mcbsp *mcbsp, unsigned int stream); +int omap_mcbsp_dma_reg_params(struct omap_mcbsp *mcbsp, unsigned int stream); /* Sidetone specific API */ -int omap_st_set_chgain(unsigned int id, int channel, s16 chgain); -int omap_st_get_chgain(unsigned int id, int channel, s16 *chgain); -int omap_st_enable(unsigned int id); -int omap_st_disable(unsigned int id); -int omap_st_is_enabled(unsigned int id); +int omap_st_set_chgain(struct omap_mcbsp *mcbsp, int channel, s16 chgain); +int omap_st_get_chgain(struct omap_mcbsp *mcbsp, int channel, s16 *chgain); +int omap_st_enable(struct omap_mcbsp *mcbsp); +int omap_st_disable(struct omap_mcbsp *mcbsp); +int omap_st_is_enabled(struct omap_mcbsp *mcbsp); + +int __devinit omap_mcbsp_probe(struct platform_device *pdev); +int __devexit omap_mcbsp_remove(struct platform_device *pdev); #endif /* __ASOC_MCBSP_H */ |