ASoC: OMAP: McBSP DAI driver updates
cover ASoC: OMAP: McBSP DAI driver updates
Here are updates to OMAP McBSP DAI driver adding support to OMAP2430 & OMAP34xx and adding support for multiple simultaneous DAI links.
Please note that the first patch is not randconfig safe until necessary OMAP McBSP updates come into mainline so I rather don't push these yet until those changes are here.
See
http://marc.info/?l=linux-omap&m=122345107722469&w=2
Signature · 1 line
Jarkko
PATCH 1/3 ASoC: OMAP: Add support for OMAP2430 and OMAP34xx in McBSP DAI driver
Thanks to Arun KS <[email protected]> for fixing one typo in original version of this patch.
--- sound/soc/omap/omap-mcbsp.c | 95 ++++++++++++++++++++++++++++++++++-------- 1 files changed, 77 insertions(+), 18 deletions(-)
sound/soc/omap/omap-mcbsp.c +77 -18
@@ -84,11 +84,22 @@ static const unsigned long omap1_mcbsp_port[][2] = {static const int omap1_dma_reqs[][2 ] = {};static const unsigned long omap1_mcbsp_port[][2 ] = {};#endif -#if defined(CONFIG_ARCH_OMAP2420 ) -static const int omap2420_dma_reqs[][2 ] = { + +#if defined(CONFIG_ARCH_OMAP24XX ) || defined(CONFIG_ARCH_OMAP34XX ) +static const int omap24xx_dma_reqs[][2 ] = { {OMAP24XX_DMA_MCBSP1_TX ,OMAP24XX_DMA_MCBSP1_RX }, {OMAP24XX_DMA_MCBSP2_TX ,OMAP24XX_DMA_MCBSP2_RX }, +#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX) + {OMAP24XX_DMA_MCBSP3_TX ,OMAP24XX_DMA_MCBSP3_RX }, + {OMAP24XX_DMA_MCBSP4_TX ,OMAP24XX_DMA_MCBSP4_RX }, + {OMAP24XX_DMA_MCBSP5_TX ,OMAP24XX_DMA_MCBSP5_RX }, +#endif }; +#else +static const int omap24xx_dma_reqs[][2 ] = {}; +#endif + +#if defined(CONFIG_ARCH_OMAP2420 )static const unsigned long omap2420_mcbsp_port[][2 ] = { {OMAP24XX_MCBSP1_BASE +OMAP_MCBSP_REG_DXR1 , OMAP24XX_MCBSP1_BASE + OMAP_MCBSP_REG_DRR1 },
@@ -96,10 +107,43 @@ static const unsigned long omap2420_mcbsp_port[][2] = { OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1 }, };#else -static const int omap2420_dma_reqs[][2 ] = {};static const unsigned long omap2420_mcbsp_port[][2 ] = {};#endif +#if defined(CONFIG_ARCH_OMAP2430 ) +static const unsigned long omap2430_mcbsp_port[][2 ] = { + {OMAP24XX_MCBSP1_BASE +OMAP_MCBSP_REG_DXR , +OMAP24XX_MCBSP1_BASE +OMAP_MCBSP_REG_DRR }, + {OMAP24XX_MCBSP2_BASE +OMAP_MCBSP_REG_DXR , +OMAP24XX_MCBSP2_BASE +OMAP_MCBSP_REG_DRR }, + {OMAP2430_MCBSP3_BASE +OMAP_MCBSP_REG_DXR , +OMAP2430_MCBSP3_BASE +OMAP_MCBSP_REG_DRR }, + {OMAP2430_MCBSP4_BASE +OMAP_MCBSP_REG_DXR , +OMAP2430_MCBSP4_BASE +OMAP_MCBSP_REG_DRR }, + {OMAP2430_MCBSP5_BASE +OMAP_MCBSP_REG_DXR , +OMAP2430_MCBSP5_BASE +OMAP_MCBSP_REG_DRR }, +}; +#else +static const unsigned long omap2430_mcbsp_port[][2 ] = {}; +#endif + +#if defined(CONFIG_ARCH_OMAP34XX ) +static const unsigned long omap34xx_mcbsp_port[][2 ] = { + {OMAP34XX_MCBSP1_BASE +OMAP_MCBSP_REG_DXR , +OMAP34XX_MCBSP1_BASE +OMAP_MCBSP_REG_DRR }, + {OMAP34XX_MCBSP2_BASE +OMAP_MCBSP_REG_DXR , +OMAP34XX_MCBSP2_BASE +OMAP_MCBSP_REG_DRR }, + {OMAP34XX_MCBSP3_BASE +OMAP_MCBSP_REG_DXR , +OMAP34XX_MCBSP3_BASE +OMAP_MCBSP_REG_DRR }, + {OMAP34XX_MCBSP4_BASE +OMAP_MCBSP_REG_DXR , +OMAP34XX_MCBSP4_BASE +OMAP_MCBSP_REG_DRR }, + {OMAP34XX_MCBSP5_BASE +OMAP_MCBSP_REG_DXR , +OMAP34XX_MCBSP5_BASE +OMAP_MCBSP_REG_DRR }, +}; +#else +static const unsigned long omap34xx_mcbsp_port[][2 ] = {}; +#endif +static int omap_mcbsp_dai_startup (struct snd_pcm_substream *substream) {struct snd_soc_pcm_runtime *rtd = substream->private_data;
@@ -167,12 +211,15 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, dma = omap1_dma_reqs[bus_id][substream->stream]; port = omap1_mcbsp_port[bus_id][substream->stream]; }else if (cpu_is_omap2420 ()) { - dma = omap2420_dma_reqs[bus_id][substream->stream]; + dma = omap24xx_dma_reqs[bus_id][substream->stream]; port = omap2420_mcbsp_port[bus_id][substream->stream]; + }else if (cpu_is_omap2430 ()) { + dma = omap24xx_dma_reqs[bus_id][substream->stream]; + port = omap2430_mcbsp_port[bus_id][substream->stream]; + }else if (cpu_is_omap343x ()) { + dma = omap24xx_dma_reqs[bus_id][substream->stream]; + port = omap34xx_mcbsp_port[bus_id][substream->stream]; }else { -/* -* TODO: Add support for 2430 and 3430 -*/ return -ENODEV ; } omap_mcbsp_dai_dma_params[id][substream->stream].dma_req = dma;
@@ -315,7 +362,7 @@ static int omap_mcbsp_dai_set_clks_src(struct omap_mcbsp_data *mcbsp_data, int clk_id) {int sel_bit; -u16 reg; +u16 reg, reg_devconf1 =OMAP243X_CONTROL_DEVCONF1 ;if (cpu_class_is_omap1 ()) {/* OMAP1's can use only external source clock */
@@ -325,6 +372,12 @@ static int omap_mcbsp_dai_set_clks_src(struct omap_mcbsp_data *mcbsp_data,return 0 ; } +if (cpu_is_omap2420 () && mcbsp_data->bus_id >1 ) +return -EINVAL ; + +if (cpu_is_omap343x ()) + reg_devconf1 =OMAP343X_CONTROL_DEVCONF1 ; +switch (mcbsp_data->bus_id) {case 0 : reg =OMAP2_CONTROL_DEVCONF0 ;
@@ -334,20 +387,26 @@ static int omap_mcbsp_dai_set_clks_src(struct omap_mcbsp_data *mcbsp_data, reg =OMAP2_CONTROL_DEVCONF0 ; sel_bit =6 ;break ; -/* TODO: Support for ports 3 - 5 in OMAP2430 and OMAP34xx */ +case 2 : + reg = reg_devconf1; + sel_bit =0 ; +break ; +case 3 : + reg = reg_devconf1; + sel_bit =2 ; +break ; +case 4 : + reg = reg_devconf1; + sel_bit =4 ; +break ;default :return -EINVAL ; } -if (cpu_class_is_omap2 ()) { -if (clk_id ==OMAP_MCBSP_SYSCLK_CLKS_FCLK ) { -omap_ctrl_writel (omap_ctrl_readl (reg) & - ~(1 << sel_bit), reg); - }else { -omap_ctrl_writel (omap_ctrl_readl (reg) | - (1 << sel_bit), reg); - } - } +if (clk_id ==OMAP_MCBSP_SYSCLK_CLKS_FCLK ) +omap_ctrl_writel (omap_ctrl_readl (reg) & ~(1 << sel_bit), reg); +else +omap_ctrl_writel (omap_ctrl_readl (reg) | (1 << sel_bit), reg);return 0 ; }
Signature · 1 line
1.5.6.5
PATCH 2/3 ASoC: OMAP: Set DMA stream name at runtime in McBSP DAI driver
In reply to Jarkko NikulaThis suits better when adding support for multiple links and different link formats.
--- sound/soc/omap/omap-mcbsp.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-)
sound/soc/omap/omap-mcbsp.c +3 -6
@@ -59,12 +59,7 @@ static struct omap_mcbsp_data mcbsp_data[NUM_LINKS];* Stream DMA parameters. DMA request line and port address are set runtime * since they are different between OMAP1 and later OMAPs */ -static struct omap_pcm_dma_data omap_mcbsp_dai_dma_params[NUM_LINKS ][2 ] = { -{ - { .name ="I2S PCM Stereo out" , }, - { .name ="I2S PCM Stereo in" , }, -}, -}; +static struct omap_pcm_dma_data omap_mcbsp_dai_dma_params[NUM_LINKS ][2 ];#if defined(CONFIG_ARCH_OMAP15XX ) || defined(CONFIG_ARCH_OMAP16XX ) static const int omap1_dma_reqs[][2] = {
@@ -222,6 +217,8 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, }else {return -ENODEV ; } + omap_mcbsp_dai_dma_params[id][substream->stream].name = + substream->stream ?"Audio Capture" :"Audio Playback" ; omap_mcbsp_dai_dma_params[id][substream->stream].dma_req = dma; omap_mcbsp_dai_dma_params[id][substream->stream].port_addr = port; cpu_dai->dma_data = &omap_mcbsp_dai_dma_params[id][substream->stream];
Signature · 1 line
1.5.6.5
PATCH 3/3 ASoC: OMAP: Add multilink support to McBSP DAI driver
In reply to Jarkko Nikula--- sound/soc/omap/omap-mcbsp.c | 72 +++++++++++++++++++++++++------------------ sound/soc/omap/omap-mcbsp.h | 16 ++++++--- 2 files changed, 53 insertions(+), 35 deletions(-)
sound/soc/omap/omap-mcbsp.c +42 -30
@@ -437,37 +437,49 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,return err; } -struct snd_soc_dai omap_mcbsp_dai[NUM_LINKS ] = { -{ - .name ="omap-mcbsp-dai" , - .id =0 , - .type =SND_SOC_DAI_I2S , - .playback = { - .channels_min =2 , - .channels_max =2 , - .rates =OMAP_MCBSP_RATES , - .formats =SNDRV_PCM_FMTBIT_S16_LE , - }, - .capture = { - .channels_min =2 , - .channels_max =2 , - .rates =OMAP_MCBSP_RATES , - .formats =SNDRV_PCM_FMTBIT_S16_LE , - }, - .ops = { - .startup = omap_mcbsp_dai_startup, - .shutdown = omap_mcbsp_dai_shutdown, - .trigger = omap_mcbsp_dai_trigger, - .hw_params = omap_mcbsp_dai_hw_params, - }, - .dai_ops = { - .set_fmt = omap_mcbsp_dai_set_dai_fmt, - .set_clkdiv = omap_mcbsp_dai_set_clkdiv, - .set_sysclk = omap_mcbsp_dai_set_dai_sysclk, - }, - .private_data = &mcbsp_data[0 ].bus_id, -}, +#define OMAP_MCBSP_DAI_BUILDER (link_id) \ +{ \ + .name = "omap-mcbsp-dai-(link_id)", \ + .id = (link_id), \ + .type = SND_SOC_DAI_I2S, \ + .playback = { \ + .channels_min = 2, \ + .channels_max = 2, \ + .rates = OMAP_MCBSP_RATES, \ + .formats = SNDRV_PCM_FMTBIT_S16_LE, \ + }, \ + .capture = { \ + .channels_min = 2, \ + .channels_max = 2, \ + .rates = OMAP_MCBSP_RATES, \ + .formats = SNDRV_PCM_FMTBIT_S16_LE, \ + }, \ + .ops = { \ + .startup = omap_mcbsp_dai_startup, \ + .shutdown = omap_mcbsp_dai_shutdown, \ + .trigger = omap_mcbsp_dai_trigger, \ + .hw_params = omap_mcbsp_dai_hw_params, \ + }, \ + .dai_ops = { \ + .set_fmt = omap_mcbsp_dai_set_dai_fmt, \ + .set_clkdiv = omap_mcbsp_dai_set_clkdiv, \ + .set_sysclk = omap_mcbsp_dai_set_dai_sysclk, \ + }, \ + .private_data = &mcbsp_data[(link_id)].bus_id, \ +} + +struct snd_soc_dai omap_mcbsp_dai[] = { +OMAP_MCBSP_DAI_BUILDER (0 ), +OMAP_MCBSP_DAI_BUILDER (1 ), +#if NUM_LINKS >= 3 +OMAP_MCBSP_DAI_BUILDER (2 ), +#endif +#if NUM_LINKS == 5 +OMAP_MCBSP_DAI_BUILDER (3 ), +OMAP_MCBSP_DAI_BUILDER (4 ), +#endif }; +EXPORT_SYMBOL_GPL (omap_mcbsp_dai);MODULE_AUTHOR ("Jarkko Nikula <[email protected]>" );
sound/soc/omap/omap-mcbsp.h +11 -5
@@ -38,11 +38,17 @@ enum omap_mcbsp_div { OMAP_MCBSP_CLKGDV, /* Sample rate generator divider */ }; -/* -* REVISIT: Preparation for the ASoC v2. Let the number of available links to -* be same than number of McBSP ports found in OMAP(s) we are compiling for. -*/ -#define NUM_LINKS 1 +#if defined(CONFIG_ARCH_OMAP2420 ) +#define NUM_LINKS 2 +#endif +#if defined(CONFIG_ARCH_OMAP15XX ) || defined(CONFIG_ARCH_OMAP16XX ) +#undef NUM_LINKS +#define NUM_LINKS 3 +#endif +#if defined(CONFIG_ARCH_OMAP2430 ) || defined(CONFIG_ARCH_OMAP34XX ) +#undef NUM_LINKS +#define NUM_LINKS 5 +#endif extern struct snd_soc_dai omap_mcbsp_dai[NUM_LINKS ];
Signature · 1 line
1.5.6.5
Quoted 6 lines · Jarkko Nikula
Here are updates to OMAP McBSP DAI driver adding support to OMAP2430 & OMAP34xx and adding support for multiple simultaneous DAI links.
Please note that the first patch is not randconfig safe until necessary OMAP McBSP updates come into mainline so I rather don't push these yet until those changes are here.
These all look good. How do you want to merge them? They could either go in with the McBSP changes they depend on or via ALSA. If via ALSA then if you like I'm happy to queue them up and submit them once their dependencies are merged (I've got some other changes in a similar situation myself). Otherwise I guess you could resubmit them once the McBSP changes are merged.
Anyway,
Quoted 6 lines · Mark Brown
These all look good. How do you want to merge them? They could either go in with the McBSP changes they depend on or via ALSA. If via ALSA then if you like I'm happy to queue them up and submit them once their dependencies are merged (I've got some other changes in a similar situation myself). Otherwise I guess you could resubmit them once the McBSP changes are merged.
Hrm. Looking at the ARM list just now it seems both this and the things my other patches are waiting for are now in rmk's tree so I'm already tracking stuff in the same tree for submission - I guess that makes adding these to my queue the most simple approach?
Quoted 9 lines · Mark Brown
Quoted 6 lines · Mark Brown
These all look good. How do you want to merge them? They could either go in with the McBSP changes they depend on or via ALSA. If via ALSA then if you like I'm happy to queue them up and submit them once their dependencies are merged (I've got some other changes in a similar situation myself). Otherwise I guess you could resubmit them once the McBSP changes are merged.
Quoted 5 lines
Hrm. Looking at the ARM list just now it seems both this and the things my other patches are waiting for are now in rmk's tree so I'm already tracking stuff in the same tree for submission - I guess that makes adding these to my queue the most simple approach?
Commenting from my another address. Yeah, I just saw Russell's mail that he pulled in those McBSP patches so should be safe enough to track these patches via your queue.
Actually devconf register definitions for 2430 and 34xx, what patch 1 is using, are already in mainline and new McBSP DMA port and base address definitions are covered by CONFIG_ARCH_OMAPxxxx so ASoC for osk5912 should still compile.
---
I heard yesterday from Tony Lindgren that TWL4030 changes might be also coming into mainline now. Then Steve would be able send his TWL4030 codec driver and machine driver for Overo. Machine driver for Beagle exists as well and question is should the same machine driver cover both boards since now they are very similar? Current understanding is to keep them separated since Overo will be extended in the future. Some discussion about it:
http://www.mail-archive.com/[email protected]/msg04389.html
Jarkko
Quoted 4 lines · Jarkko Nikula
Actually devconf register definitions for 2430 and 34xx, what patch 1 is using, are already in mainline and new McBSP DMA port and base address definitions are covered by
CONFIG_ARCH_OMAPxxxxso ASoC for osk5912 should still compile.
So they should be safe to push already, then?
Quoted 3 lines
I heard yesterday from Tony Lindgren that TWL4030 changes might be also coming into mainline now. Then Steve would be able send his TWL4030 codec driver and machine driver for Overo. Machine driver for Beagle exists as
Yes, Samuel Ortiz said he'd merged David's patch for the core so the codec driver should be good to go once Linus pulls the MFD tree. Chances are that this will also be about the same time as the other stuff I'm queuing if you want to go that way?
Quoted 5 lines
well and question is should the same machine driver cover both boards since now they are very similar? Current understanding is to keep them separated since Overo will be extended in the future. Some discussion about it:
Given that Overo will be extended beyond what the Beagle board is capable of it probably does make sense to separate the two drivers - using the same one initially might confuse whoever comes along and does the more detailed Overo board support. The main argument for doing them within the one driver would be if the Beagle and Overo boards were generally understood by OMAP users as being subfitted versions of the same family.
Really, whatever makes life easiest for you guys is fine.
Quoted 9 lines · On Thu, 9 Oct 2008 20:49:31 +0100 "ext Mark Brown" <[email protected]>…
Quoted 4 lines · Jarkko Nikula
Actually devconf register definitions for 2430 and 34xx, what patch 1 is using, are already in mainline and new McBSP DMA port and base address definitions are covered by
CONFIG_ARCH_OMAPxxxxso ASoC for osk5912 should still compile.So they should be safe to push already, then?
Yes it should. Compilation for OSK5912 in Takashi's tree goes fine.
make ARCH=arm omap_osk_5912_defconfig
make ARCH=arm menuconfig
+ add support for ASoC OMAP & OSK5912
make ARCH=arm CROSS_COMPILE=arm-linux-
Also support for N810 is not coming to mainline during this merge window so only way to compile omap-mcbsp.c is to select OMAP1 based OSK5912. Currently it's possible to compile only for same OMAP generation processors. I.e. OMAP1, OMAP2 or OMAP3.
Jarkko