aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap
diff options
context:
space:
mode:
authorKishon Vijay Abraham I <kishon@ti.com>2011-02-24 04:46:55 -0500
committerTony Lindgren <tony@atomide.com>2011-02-24 16:03:52 -0500
commit9504ba64f014cfd50a64106e49c8ba729522db5b (patch)
treeacc4df7736ad2bdd435394c7d783caf49eb15bef /arch/arm/plat-omap
parente95496d4acadd0b72c4947be61e8d44700fdaae7 (diff)
OMAP: McBSP: APIs to pass DMA params from McBSP driver to client drivers
After McBSP driver is hwmod adapted, the information about the hw would be obtained from the hwmod database by the mcbsp driver. Since DMA programming is handled by the client driver, APIs are provided to pass the DMA channel number and base address of data register required by the client driver for DMA programming. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Charulatha V <charu@ti.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Acked-by: Jarkko Nikula <jhnikula@gmail.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/plat-omap')
-rw-r--r--arch/arm/plat-omap/include/plat/mcbsp.h7
-rw-r--r--arch/arm/plat-omap/mcbsp.c64
2 files changed, 71 insertions, 0 deletions
diff --git a/arch/arm/plat-omap/include/plat/mcbsp.h b/arch/arm/plat-omap/include/plat/mcbsp.h
index 964a940c475d..21c9b104c615 100644
--- a/arch/arm/plat-omap/include/plat/mcbsp.h
+++ b/arch/arm/plat-omap/include/plat/mcbsp.h
@@ -81,6 +81,8 @@ static struct platform_device omap_mcbsp##port_nr = { \
81#define OMAP_MCBSP_REG_DRR1 0x02 81#define OMAP_MCBSP_REG_DRR1 0x02
82#define OMAP_MCBSP_REG_DXR2 0x04 82#define OMAP_MCBSP_REG_DXR2 0x04
83#define OMAP_MCBSP_REG_DXR1 0x06 83#define OMAP_MCBSP_REG_DXR1 0x06
84#define OMAP_MCBSP_REG_DRR 0x02
85#define OMAP_MCBSP_REG_DXR 0x06
84#define OMAP_MCBSP_REG_SPCR2 0x08 86#define OMAP_MCBSP_REG_SPCR2 0x08
85#define OMAP_MCBSP_REG_SPCR1 0x0a 87#define OMAP_MCBSP_REG_SPCR1 0x0a
86#define OMAP_MCBSP_REG_RCR2 0x0c 88#define OMAP_MCBSP_REG_RCR2 0x0c
@@ -423,6 +425,7 @@ struct omap_mcbsp_platform_data {
423 unsigned long phys_base_st; 425 unsigned long phys_base_st;
424#endif 426#endif
425 u16 buffer_size; 427 u16 buffer_size;
428 unsigned int mcbsp_config_type;
426}; 429};
427 430
428struct omap_mcbsp_st_data { 431struct omap_mcbsp_st_data {
@@ -473,6 +476,7 @@ struct omap_mcbsp {
473 u16 max_rx_thres; 476 u16 max_rx_thres;
474#endif 477#endif
475 void *reg_cache; 478 void *reg_cache;
479 unsigned int mcbsp_config_type;
476}; 480};
477 481
478/** 482/**
@@ -541,6 +545,9 @@ int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type);
541void omap2_mcbsp1_mux_clkr_src(u8 mux); 545void omap2_mcbsp1_mux_clkr_src(u8 mux);
542void omap2_mcbsp1_mux_fsr_src(u8 mux); 546void omap2_mcbsp1_mux_fsr_src(u8 mux);
543 547
548int omap_mcbsp_dma_ch_params(unsigned int id, unsigned int stream);
549int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream);
550
544#ifdef CONFIG_ARCH_OMAP3 551#ifdef CONFIG_ARCH_OMAP3
545/* Sidetone specific API */ 552/* Sidetone specific API */
546int omap_st_set_chgain(unsigned int id, int channel, s16 chgain); 553int omap_st_set_chgain(unsigned int id, int channel, s16 chgain);
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index 6d230164b4f9..d598d9fd65ac 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -229,6 +229,69 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config)
229} 229}
230EXPORT_SYMBOL(omap_mcbsp_config); 230EXPORT_SYMBOL(omap_mcbsp_config);
231 231
232/**
233 * omap_mcbsp_dma_params - returns the dma channel number
234 * @id - mcbsp id
235 * @stream - indicates the direction of data flow (rx or tx)
236 *
237 * Returns the dma channel number for the rx channel or tx channel
238 * based on the value of @stream for the requested mcbsp given by @id
239 */
240int omap_mcbsp_dma_ch_params(unsigned int id, unsigned int stream)
241{
242 struct omap_mcbsp *mcbsp;
243
244 if (!omap_mcbsp_check_valid_id(id)) {
245 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
246 return -ENODEV;
247 }
248 mcbsp = id_to_mcbsp_ptr(id);
249
250 if (stream)
251 return mcbsp->dma_rx_sync;
252 else
253 return mcbsp->dma_tx_sync;
254}
255EXPORT_SYMBOL(omap_mcbsp_dma_ch_params);
256
257/**
258 * omap_mcbsp_dma_reg_params - returns the address of mcbsp data register
259 * @id - mcbsp id
260 * @stream - indicates the direction of data flow (rx or tx)
261 *
262 * Returns the address of mcbsp data transmit register or data receive register
263 * to be used by DMA for transferring/receiving data based on the value of
264 * @stream for the requested mcbsp given by @id
265 */
266int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream)
267{
268 struct omap_mcbsp *mcbsp;
269 int data_reg;
270
271 if (!omap_mcbsp_check_valid_id(id)) {
272 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
273 return -ENODEV;
274 }
275 mcbsp = id_to_mcbsp_ptr(id);
276
277 data_reg = mcbsp->phys_dma_base;
278
279 if (mcbsp->mcbsp_config_type < MCBSP_CONFIG_TYPE2) {
280 if (stream)
281 data_reg += OMAP_MCBSP_REG_DRR1;
282 else
283 data_reg += OMAP_MCBSP_REG_DXR1;
284 } else {
285 if (stream)
286 data_reg += OMAP_MCBSP_REG_DRR;
287 else
288 data_reg += OMAP_MCBSP_REG_DXR;
289 }
290
291 return data_reg;
292}
293EXPORT_SYMBOL(omap_mcbsp_dma_reg_params);
294
232#ifdef CONFIG_ARCH_OMAP3 295#ifdef CONFIG_ARCH_OMAP3
233static struct omap_device *find_omap_device_by_dev(struct device *dev) 296static struct omap_device *find_omap_device_by_dev(struct device *dev)
234{ 297{
@@ -1835,6 +1898,7 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
1835 mcbsp->pdata = pdata; 1898 mcbsp->pdata = pdata;
1836 mcbsp->dev = &pdev->dev; 1899 mcbsp->dev = &pdev->dev;
1837 mcbsp_ptr[id] = mcbsp; 1900 mcbsp_ptr[id] = mcbsp;
1901 mcbsp->mcbsp_config_type = pdata->mcbsp_config_type;
1838 platform_set_drvdata(pdev, mcbsp); 1902 platform_set_drvdata(pdev, mcbsp);
1839 pm_runtime_enable(mcbsp->dev); 1903 pm_runtime_enable(mcbsp->dev);
1840 1904