[alsa-devel] [RFC 00/11]O MAP/ASoC: Move and merge McBSP driver under ASoC
Hello,
The aim of this series is to move the plat-omap/mcbsp.c driver out to sound/soc/omap/ By doing this we can combine the two levels of McBSP driver stack into a single one. Formally we had omap-mcbsp.[1-X] drivers (plat-omap/mcbsp.c), and omap-mcbsp-dai.[0-(X-1) drivers (sound/soc/omap/omap-mcbsp.c). We had global, shared structures, variables, pointers. The API between the two driver was a set of exported function calls where one of the parameter was the McBSP port id.
With this series we will have one driver for McBSP (omap-mcbsp.[1-X]) which is basically the ASoC dai driver. All exported/shared global structures are gone since we can use driver data for all ports in this way.
With the code in one place we can do further clean up in the McBSP driver, and adding new features will be much easier in the future. Also the DT support for McBSP will be significantly easier if we have one set of driver.
McBSP is only used by audio, there are no known other users of the OMAP McBSP (well, Nokia n700 has the WLAN connected through McBSP but we do not have driver for that anyway).
The series was created against Takashi's topic/asoc branch. I have tested it on Beagle xM, and compile tested it for OMAP1, OMAP2, and OMAP4 as well.
I'm going to do more work on the cleanup, and the plan is to merge the two files into one (mcbsp.c -> omap-mcbsp.c) eventually.
Comments, testers are welcome...
CC-ing Samuel as well since he is the original author of the plat-omap/mcbsp.c driver.
Regards, Peter --- Peter Ujfalusi (11): ARM: OMAP: mcbsp: Convert core driver to proper platform driver OMAP: mcbsp: Move core driver under sound/soc/omap ASoC: OMAP: McBSP: Consolidate plat/mcbsp.h content ASoC: core - Add API call to register dai kcontrols. ASoC: omap-mcbsp: Create a single driver for McBSP ARM: OMAP: Do not register omap-mcbsp-dai device ASoC: OMAP: mcbsp.h: Clean up bit definitions ASoC: OMAP McBSP: Remove redundant accessors ASoC: omap-mcbsp: Cleanup of module probe/remove code ASoC: omap-mcbsp: Merge the omap_mcbsp_data into omap_mcbsp structure ASoC: omap-mcbsp: Simplify DMA configuration
arch/arm/mach-omap1/devices.c | 9 - arch/arm/mach-omap1/mcbsp.c | 14 +- arch/arm/mach-omap2/devices.c | 22 -- arch/arm/mach-omap2/mcbsp.c | 8 +- arch/arm/plat-omap/Kconfig | 8 - arch/arm/plat-omap/Makefile | 2 - arch/arm/plat-omap/include/plat/mcbsp.h | 321 ---------------- include/sound/soc.h | 2 + sound/soc/omap/Kconfig | 4 + sound/soc/omap/Makefile | 1 + sound/soc/omap/am3517evm.c | 2 +- sound/soc/omap/ams-delta.c | 2 +- sound/soc/omap/igep0020.c | 2 +- {arch/arm/plat-omap => sound/soc/omap}/mcbsp.c | 463 ++++-------------------- sound/soc/omap/mcbsp.h | 337 +++++++++++++++++ sound/soc/omap/n810.c | 2 +- sound/soc/omap/omap-mcbsp.c | 287 ++++++++------- sound/soc/omap/omap-mcbsp.h | 2 +- sound/soc/omap/omap-pcm.h | 2 + sound/soc/omap/omap3beagle.c | 2 +- sound/soc/omap/omap3evm.c | 2 +- sound/soc/omap/omap3pandora.c | 4 +- sound/soc/omap/osk5912.c | 2 +- sound/soc/omap/overo.c | 2 +- sound/soc/omap/rx51.c | 4 +- sound/soc/omap/sdp3430.c | 4 +- sound/soc/omap/zoom2.c | 4 +- sound/soc/soc-core.c | 31 ++ 28 files changed, 631 insertions(+), 914 deletions(-) rename {arch/arm/plat-omap => sound/soc/omap}/mcbsp.c (69%) create mode 100644 sound/soc/omap/mcbsp.h
Convert the plat-omap/mcbsp.c driver to be proper platform driver. Remove the omap_mcbsp_init function call which was called from mach-omap1/2/mcbsp.c to register the platform driver for the just created platform device in the same function.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com --- arch/arm/mach-omap1/mcbsp.c | 2 +- arch/arm/mach-omap2/mcbsp.c | 2 +- arch/arm/plat-omap/include/plat/mcbsp.h | 1 - arch/arm/plat-omap/mcbsp.c | 11 ++++++----- 4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/arm/mach-omap1/mcbsp.c b/arch/arm/mach-omap1/mcbsp.c index 91f9abb..fe11e13 100644 --- a/arch/arm/mach-omap1/mcbsp.c +++ b/arch/arm/mach-omap1/mcbsp.c @@ -449,7 +449,7 @@ static int __init omap1_mcbsp_init(void) omap16xx_mcbsp_pdata, OMAP16XX_MCBSP_COUNT);
- return omap_mcbsp_init(); + return 0; }
arch_initcall(omap1_mcbsp_init); diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c index fb4bcf8..b36d443 100644 --- a/arch/arm/mach-omap2/mcbsp.c +++ b/arch/arm/mach-omap2/mcbsp.c @@ -193,6 +193,6 @@ static int __init omap2_mcbsp_init(void) if (!mcbsp_ptr) return -ENOMEM;
- return omap_mcbsp_init(); + return 0; } arch_initcall(omap2_mcbsp_init); diff --git a/arch/arm/plat-omap/include/plat/mcbsp.h b/arch/arm/plat-omap/include/plat/mcbsp.h index 8fa74e2..7e4f893 100644 --- a/arch/arm/plat-omap/include/plat/mcbsp.h +++ b/arch/arm/plat-omap/include/plat/mcbsp.h @@ -360,7 +360,6 @@ struct omap_mcbsp_dev_attr { extern struct omap_mcbsp **mcbsp_ptr; extern int omap_mcbsp_count;
-int omap_mcbsp_init(void); void omap_mcbsp_config(unsigned int id, 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); diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c index 4b15cd7..3c704f3 100644 --- a/arch/arm/plat-omap/mcbsp.c +++ b/arch/arm/plat-omap/mcbsp.c @@ -1354,8 +1354,9 @@ static struct platform_driver omap_mcbsp_driver = { }, };
-int __init omap_mcbsp_init(void) -{ - /* Register the McBSP driver */ - return platform_driver_register(&omap_mcbsp_driver); -} +module_platform_driver(omap_mcbsp_driver); + +MODULE_AUTHOR("Samuel Ortiz samuel.ortiz@nokia.com"); +MODULE_DESCRIPTION("OMAP McBSP core driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:omap-mcbsp");
* Peter Ujfalusi peter.ujfalusi@ti.com [120215 07:06]:
Convert the plat-omap/mcbsp.c driver to be proper platform driver. Remove the omap_mcbsp_init function call which was called from mach-omap1/2/mcbsp.c to register the platform driver for the just created platform device in the same function.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com
Acked-by: Tony Lindgren tony@atomide.com
In order to consolidate the McBSP driver move it out from arch/arm/plat-omap directory under sound/soc/omap/
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com --- arch/arm/plat-omap/Kconfig | 8 -------- arch/arm/plat-omap/Makefile | 2 -- sound/soc/omap/Kconfig | 4 ++++ sound/soc/omap/Makefile | 1 + {arch/arm/plat-omap => sound/soc/omap}/mcbsp.c | 4 +++- 5 files changed, 8 insertions(+), 11 deletions(-) rename {arch/arm/plat-omap => sound/soc/omap}/mcbsp.c (99%)
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig index aa59f42..8f81503 100644 --- a/arch/arm/plat-omap/Kconfig +++ b/arch/arm/plat-omap/Kconfig @@ -110,14 +110,6 @@ config OMAP_MUX_WARNINGS to change the pin multiplexing setup. When there are no warnings printed, it's safe to deselect OMAP_MUX for your product.
-config OMAP_MCBSP - bool "McBSP support" - depends on ARCH_OMAP - default y - help - Say Y here if you want support for the OMAP Multichannel - Buffered Serial Port. - config OMAP_MBOX_FWK tristate "Mailbox framework support" depends on ARCH_OMAP diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile index 9a58461..c0fe275 100644 --- a/arch/arm/plat-omap/Makefile +++ b/arch/arm/plat-omap/Makefile @@ -17,8 +17,6 @@ obj-$(CONFIG_ARCH_OMAP2) += omap_device.o obj-$(CONFIG_ARCH_OMAP3) += omap_device.o obj-$(CONFIG_ARCH_OMAP4) += omap_device.o
-obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o - obj-$(CONFIG_OMAP_DM_TIMER) += dmtimer.o obj-$(CONFIG_OMAP_DEBUG_DEVICES) += debug-devices.o obj-$(CONFIG_OMAP_DEBUG_LEDS) += debug-leds.o diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index 47b23fe..27a3a29 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig @@ -5,6 +5,10 @@ config SND_OMAP_SOC config SND_OMAP_SOC_DMIC tristate
+config OMAP_MCBSP + tristate + depends on ARCH_OMAP + config SND_OMAP_SOC_MCBSP tristate select OMAP_MCBSP diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile index 123ac18..9f8fbd5 100644 --- a/sound/soc/omap/Makefile +++ b/sound/soc/omap/Makefile @@ -7,6 +7,7 @@ snd-soc-omap-hdmi-objs := omap-hdmi.o
obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.o obj-$(CONFIG_SND_OMAP_SOC_DMIC) += snd-soc-omap-dmic.o +obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o obj-$(CONFIG_SND_OMAP_SOC_MCBSP) += snd-soc-omap-mcbsp.o obj-$(CONFIG_SND_OMAP_SOC_MCPDM) += snd-soc-omap-mcpdm.o obj-$(CONFIG_SND_OMAP_SOC_HDMI) += snd-soc-omap-hdmi.o diff --git a/arch/arm/plat-omap/mcbsp.c b/sound/soc/omap/mcbsp.c similarity index 99% rename from arch/arm/plat-omap/mcbsp.c rename to sound/soc/omap/mcbsp.c index 3c704f3..36d83b0 100644 --- a/arch/arm/plat-omap/mcbsp.c +++ b/sound/soc/omap/mcbsp.c @@ -1,9 +1,11 @@ /* - * linux/arch/arm/plat-omap/mcbsp.c + * sound/soc/omap/mcbsp.c * * Copyright (C) 2004 Nokia Corporation * Author: Samuel Ortiz samuel.ortiz@nokia.com * + * Contact: Jarkko Nikula jarkko.nikula@bitmer.com + * Peter Ujfalusi peter.ujfalusi@ti.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
* Peter Ujfalusi peter.ujfalusi@ti.com [120215 07:07]:
In order to consolidate the McBSP driver move it out from arch/arm/plat-omap directory under sound/soc/omap/
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com
Thanks for doing this! These may cause some minor merge conflicts with the planned header clean-up, but those should be trivial to deal with.
Acked-by: Tony Lindgren tony@atomide.com
Move most of the content of the plat/mcbsp.h header file under sound/soc/omap/ to help further cleanups.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com --- arch/arm/plat-omap/include/plat/mcbsp.h | 273 ----------------------------- sound/soc/omap/mcbsp.c | 2 + sound/soc/omap/mcbsp.h | 292 +++++++++++++++++++++++++++++++ sound/soc/omap/omap-mcbsp.c | 10 + 4 files changed, 304 insertions(+), 273 deletions(-) create mode 100644 sound/soc/omap/mcbsp.h
diff --git a/arch/arm/plat-omap/include/plat/mcbsp.h b/arch/arm/plat-omap/include/plat/mcbsp.h index 7e4f893..1a9e98f 100644 --- a/arch/arm/plat-omap/include/plat/mcbsp.h +++ b/arch/arm/plat-omap/include/plat/mcbsp.h @@ -38,210 +38,6 @@ static struct platform_device omap_mcbsp##port_nr = { \ #define MCBSP_CONFIG_TYPE3 0x3 #define MCBSP_CONFIG_TYPE4 0x4
-/* McBSP register numbers. Register address offset = num * reg_step */ -enum { - /* Common registers */ - OMAP_MCBSP_REG_SPCR2 = 4, - OMAP_MCBSP_REG_SPCR1, - OMAP_MCBSP_REG_RCR2, - OMAP_MCBSP_REG_RCR1, - OMAP_MCBSP_REG_XCR2, - OMAP_MCBSP_REG_XCR1, - OMAP_MCBSP_REG_SRGR2, - OMAP_MCBSP_REG_SRGR1, - OMAP_MCBSP_REG_MCR2, - OMAP_MCBSP_REG_MCR1, - OMAP_MCBSP_REG_RCERA, - OMAP_MCBSP_REG_RCERB, - OMAP_MCBSP_REG_XCERA, - OMAP_MCBSP_REG_XCERB, - OMAP_MCBSP_REG_PCR0, - OMAP_MCBSP_REG_RCERC, - OMAP_MCBSP_REG_RCERD, - OMAP_MCBSP_REG_XCERC, - OMAP_MCBSP_REG_XCERD, - OMAP_MCBSP_REG_RCERE, - OMAP_MCBSP_REG_RCERF, - OMAP_MCBSP_REG_XCERE, - OMAP_MCBSP_REG_XCERF, - OMAP_MCBSP_REG_RCERG, - OMAP_MCBSP_REG_RCERH, - OMAP_MCBSP_REG_XCERG, - OMAP_MCBSP_REG_XCERH, - - /* OMAP1-OMAP2420 registers */ - OMAP_MCBSP_REG_DRR2 = 0, - OMAP_MCBSP_REG_DRR1, - OMAP_MCBSP_REG_DXR2, - OMAP_MCBSP_REG_DXR1, - - /* OMAP2430 and onwards */ - OMAP_MCBSP_REG_DRR = 0, - OMAP_MCBSP_REG_DXR = 2, - OMAP_MCBSP_REG_SYSCON = 35, - OMAP_MCBSP_REG_THRSH2, - OMAP_MCBSP_REG_THRSH1, - OMAP_MCBSP_REG_IRQST = 40, - OMAP_MCBSP_REG_IRQEN, - OMAP_MCBSP_REG_WAKEUPEN, - OMAP_MCBSP_REG_XCCR, - OMAP_MCBSP_REG_RCCR, - OMAP_MCBSP_REG_XBUFFSTAT, - OMAP_MCBSP_REG_RBUFFSTAT, - OMAP_MCBSP_REG_SSELCR, -}; - -/* OMAP3 sidetone control registers */ -#define OMAP_ST_REG_REV 0x00 -#define OMAP_ST_REG_SYSCONFIG 0x10 -#define OMAP_ST_REG_IRQSTATUS 0x18 -#define OMAP_ST_REG_IRQENABLE 0x1C -#define OMAP_ST_REG_SGAINCR 0x24 -#define OMAP_ST_REG_SFIRCR 0x28 -#define OMAP_ST_REG_SSELCR 0x2C - -/************************** McBSP SPCR1 bit definitions ***********************/ -#define RRST 0x0001 -#define RRDY 0x0002 -#define RFULL 0x0004 -#define RSYNC_ERR 0x0008 -#define RINTM(value) ((value)<<4) /* bits 4:5 */ -#define ABIS 0x0040 -#define DXENA 0x0080 -#define CLKSTP(value) ((value)<<11) /* bits 11:12 */ -#define RJUST(value) ((value)<<13) /* bits 13:14 */ -#define ALB 0x8000 -#define DLB 0x8000 - -/************************** McBSP SPCR2 bit definitions ***********************/ -#define XRST 0x0001 -#define XRDY 0x0002 -#define XEMPTY 0x0004 -#define XSYNC_ERR 0x0008 -#define XINTM(value) ((value)<<4) /* bits 4:5 */ -#define GRST 0x0040 -#define FRST 0x0080 -#define SOFT 0x0100 -#define FREE 0x0200 - -/************************** McBSP PCR bit definitions *************************/ -#define CLKRP 0x0001 -#define CLKXP 0x0002 -#define FSRP 0x0004 -#define FSXP 0x0008 -#define DR_STAT 0x0010 -#define DX_STAT 0x0020 -#define CLKS_STAT 0x0040 -#define SCLKME 0x0080 -#define CLKRM 0x0100 -#define CLKXM 0x0200 -#define FSRM 0x0400 -#define FSXM 0x0800 -#define RIOEN 0x1000 -#define XIOEN 0x2000 -#define IDLE_EN 0x4000 - -/************************** McBSP RCR1 bit definitions ************************/ -#define RWDLEN1(value) ((value)<<5) /* Bits 5:7 */ -#define RFRLEN1(value) ((value)<<8) /* Bits 8:14 */ - -/************************** McBSP XCR1 bit definitions ************************/ -#define XWDLEN1(value) ((value)<<5) /* Bits 5:7 */ -#define XFRLEN1(value) ((value)<<8) /* Bits 8:14 */ - -/*************************** McBSP RCR2 bit definitions ***********************/ -#define RDATDLY(value) (value) /* Bits 0:1 */ -#define RFIG 0x0004 -#define RCOMPAND(value) ((value)<<3) /* Bits 3:4 */ -#define RWDLEN2(value) ((value)<<5) /* Bits 5:7 */ -#define RFRLEN2(value) ((value)<<8) /* Bits 8:14 */ -#define RPHASE 0x8000 - -/*************************** McBSP XCR2 bit definitions ***********************/ -#define XDATDLY(value) (value) /* Bits 0:1 */ -#define XFIG 0x0004 -#define XCOMPAND(value) ((value)<<3) /* Bits 3:4 */ -#define XWDLEN2(value) ((value)<<5) /* Bits 5:7 */ -#define XFRLEN2(value) ((value)<<8) /* Bits 8:14 */ -#define XPHASE 0x8000 - -/************************* McBSP SRGR1 bit definitions ************************/ -#define CLKGDV(value) (value) /* Bits 0:7 */ -#define FWID(value) ((value)<<8) /* Bits 8:15 */ - -/************************* McBSP SRGR2 bit definitions ************************/ -#define FPER(value) (value) /* Bits 0:11 */ -#define FSGM 0x1000 -#define CLKSM 0x2000 -#define CLKSP 0x4000 -#define GSYNC 0x8000 - -/************************* McBSP MCR1 bit definitions *************************/ -#define RMCM 0x0001 -#define RCBLK(value) ((value)<<2) /* Bits 2:4 */ -#define RPABLK(value) ((value)<<5) /* Bits 5:6 */ -#define RPBBLK(value) ((value)<<7) /* Bits 7:8 */ - -/************************* McBSP MCR2 bit definitions *************************/ -#define XMCM(value) (value) /* Bits 0:1 */ -#define XCBLK(value) ((value)<<2) /* Bits 2:4 */ -#define XPABLK(value) ((value)<<5) /* Bits 5:6 */ -#define XPBBLK(value) ((value)<<7) /* Bits 7:8 */ - -/*********************** McBSP XCCR bit definitions *************************/ -#define EXTCLKGATE 0x8000 -#define PPCONNECT 0x4000 -#define DXENDLY(value) ((value)<<12) /* Bits 12:13 */ -#define XFULL_CYCLE 0x0800 -#define DILB 0x0020 -#define XDMAEN 0x0008 -#define XDISABLE 0x0001 - -/********************** McBSP RCCR bit definitions *************************/ -#define RFULL_CYCLE 0x0800 -#define RDMAEN 0x0008 -#define RDISABLE 0x0001 - -/********************** McBSP SYSCONFIG bit definitions ********************/ -#define CLOCKACTIVITY(value) ((value)<<8) -#define SIDLEMODE(value) ((value)<<3) -#define ENAWAKEUP 0x0004 -#define SOFTRST 0x0002 - -/********************** McBSP SSELCR bit definitions ***********************/ -#define SIDETONEEN 0x0400 - -/********************** McBSP Sidetone SYSCONFIG bit definitions ***********/ -#define ST_AUTOIDLE 0x0001 - -/********************** McBSP Sidetone SGAINCR bit definitions *************/ -#define ST_CH1GAIN(value) ((value<<16)) /* Bits 16:31 */ -#define ST_CH0GAIN(value) (value) /* Bits 0:15 */ - -/********************** McBSP Sidetone SFIRCR bit definitions **************/ -#define ST_FIRCOEFF(value) (value) /* Bits 0:15 */ - -/********************** McBSP Sidetone SSELCR bit definitions **************/ -#define ST_COEFFWRDONE 0x0004 -#define ST_COEFFWREN 0x0002 -#define ST_SIDETONEEN 0x0001 - -/********************** McBSP DMA operating modes **************************/ -#define MCBSP_DMA_MODE_ELEMENT 0 -#define MCBSP_DMA_MODE_THRESHOLD 1 -#define MCBSP_DMA_MODE_FRAME 2 - -/********************** McBSP WAKEUPEN bit definitions *********************/ -#define XEMPTYEOFEN 0x4000 -#define XRDYEN 0x0400 -#define XEOFEN 0x0200 -#define XFSXEN 0x0100 -#define XSYNCERREN 0x0080 -#define RRDYEN 0x0008 -#define REOFEN 0x0004 -#define RFSREN 0x0002 -#define RSYNCERREN 0x0001 - /* CLKR signal muxing options */ #define CLKR_SRC_CLKR 0 #define CLKR_SRC_CLKX 1 @@ -254,44 +50,6 @@ enum { #define MCBSP_CLKS_PRCM_SRC 0 #define MCBSP_CLKS_PAD_SRC 1
-/* we don't do multichannel for now */ -struct omap_mcbsp_reg_cfg { - u16 spcr2; - u16 spcr1; - u16 rcr2; - u16 rcr1; - u16 xcr2; - u16 xcr1; - u16 srgr2; - u16 srgr1; - u16 mcr2; - u16 mcr1; - u16 pcr0; - u16 rcerc; - u16 rcerd; - u16 xcerc; - u16 xcerd; - u16 rcere; - u16 rcerf; - u16 xcere; - u16 xcerf; - u16 rcerg; - u16 rcerh; - u16 xcerg; - u16 xcerh; - u16 xccr; - u16 rccr; -}; - -typedef enum { - OMAP_MCBSP_WORD_8 = 0, - OMAP_MCBSP_WORD_12, - OMAP_MCBSP_WORD_16, - OMAP_MCBSP_WORD_20, - OMAP_MCBSP_WORD_24, - OMAP_MCBSP_WORD_32, -} omap_mcbsp_word_length; - /* Platform specific configuration */ struct omap_mcbsp_ops { void (*request)(unsigned int); @@ -360,35 +118,4 @@ struct omap_mcbsp_dev_attr { extern struct omap_mcbsp **mcbsp_ptr; extern int omap_mcbsp_count;
-void omap_mcbsp_config(unsigned int id, 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); - -/* McBSP functional clock source changing function */ -extern int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id); - -/* McBSP signal muxing API */ -void omap2_mcbsp1_mux_clkr_src(u8 mux); -void omap2_mcbsp1_mux_fsr_src(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); - -/* 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); - #endif diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c index 36d83b0..20d46bf 100644 --- a/sound/soc/omap/mcbsp.c +++ b/sound/soc/omap/mcbsp.c @@ -28,6 +28,8 @@ #include <plat/mcbsp.h> #include <linux/pm_runtime.h>
+#include "mcbsp.h" + struct omap_mcbsp **mcbsp_ptr; int omap_mcbsp_count;
diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h new file mode 100644 index 0000000..5590ab2 --- /dev/null +++ b/sound/soc/omap/mcbsp.h @@ -0,0 +1,292 @@ +/* + * sound/soc/omap/mcbsp.h + * + * OMAP Multi-Channel Buffered Serial Port + * + * Contact: Jarkko Nikula jarkko.nikula@bitmer.com + * Peter Ujfalusi peter.ujfalusi@ti.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#ifndef __ASOC_MCBSP_H +#define __ASOC_MCBSP_H + +/* McBSP register numbers. Register address offset = num * reg_step */ +enum { + /* Common registers */ + OMAP_MCBSP_REG_SPCR2 = 4, + OMAP_MCBSP_REG_SPCR1, + OMAP_MCBSP_REG_RCR2, + OMAP_MCBSP_REG_RCR1, + OMAP_MCBSP_REG_XCR2, + OMAP_MCBSP_REG_XCR1, + OMAP_MCBSP_REG_SRGR2, + OMAP_MCBSP_REG_SRGR1, + OMAP_MCBSP_REG_MCR2, + OMAP_MCBSP_REG_MCR1, + OMAP_MCBSP_REG_RCERA, + OMAP_MCBSP_REG_RCERB, + OMAP_MCBSP_REG_XCERA, + OMAP_MCBSP_REG_XCERB, + OMAP_MCBSP_REG_PCR0, + OMAP_MCBSP_REG_RCERC, + OMAP_MCBSP_REG_RCERD, + OMAP_MCBSP_REG_XCERC, + OMAP_MCBSP_REG_XCERD, + OMAP_MCBSP_REG_RCERE, + OMAP_MCBSP_REG_RCERF, + OMAP_MCBSP_REG_XCERE, + OMAP_MCBSP_REG_XCERF, + OMAP_MCBSP_REG_RCERG, + OMAP_MCBSP_REG_RCERH, + OMAP_MCBSP_REG_XCERG, + OMAP_MCBSP_REG_XCERH, + + /* OMAP1-OMAP2420 registers */ + OMAP_MCBSP_REG_DRR2 = 0, + OMAP_MCBSP_REG_DRR1, + OMAP_MCBSP_REG_DXR2, + OMAP_MCBSP_REG_DXR1, + + /* OMAP2430 and onwards */ + OMAP_MCBSP_REG_DRR = 0, + OMAP_MCBSP_REG_DXR = 2, + OMAP_MCBSP_REG_SYSCON = 35, + OMAP_MCBSP_REG_THRSH2, + OMAP_MCBSP_REG_THRSH1, + OMAP_MCBSP_REG_IRQST = 40, + OMAP_MCBSP_REG_IRQEN, + OMAP_MCBSP_REG_WAKEUPEN, + OMAP_MCBSP_REG_XCCR, + OMAP_MCBSP_REG_RCCR, + OMAP_MCBSP_REG_XBUFFSTAT, + OMAP_MCBSP_REG_RBUFFSTAT, + OMAP_MCBSP_REG_SSELCR, +}; + +/* OMAP3 sidetone control registers */ +#define OMAP_ST_REG_REV 0x00 +#define OMAP_ST_REG_SYSCONFIG 0x10 +#define OMAP_ST_REG_IRQSTATUS 0x18 +#define OMAP_ST_REG_IRQENABLE 0x1C +#define OMAP_ST_REG_SGAINCR 0x24 +#define OMAP_ST_REG_SFIRCR 0x28 +#define OMAP_ST_REG_SSELCR 0x2C + +/************************** McBSP SPCR1 bit definitions ***********************/ +#define RRST 0x0001 +#define RRDY 0x0002 +#define RFULL 0x0004 +#define RSYNC_ERR 0x0008 +#define RINTM(value) ((value)<<4) /* bits 4:5 */ +#define ABIS 0x0040 +#define DXENA 0x0080 +#define CLKSTP(value) ((value)<<11) /* bits 11:12 */ +#define RJUST(value) ((value)<<13) /* bits 13:14 */ +#define ALB 0x8000 +#define DLB 0x8000 + +/************************** McBSP SPCR2 bit definitions ***********************/ +#define XRST 0x0001 +#define XRDY 0x0002 +#define XEMPTY 0x0004 +#define XSYNC_ERR 0x0008 +#define XINTM(value) ((value)<<4) /* bits 4:5 */ +#define GRST 0x0040 +#define FRST 0x0080 +#define SOFT 0x0100 +#define FREE 0x0200 + +/************************** McBSP PCR bit definitions *************************/ +#define CLKRP 0x0001 +#define CLKXP 0x0002 +#define FSRP 0x0004 +#define FSXP 0x0008 +#define DR_STAT 0x0010 +#define DX_STAT 0x0020 +#define CLKS_STAT 0x0040 +#define SCLKME 0x0080 +#define CLKRM 0x0100 +#define CLKXM 0x0200 +#define FSRM 0x0400 +#define FSXM 0x0800 +#define RIOEN 0x1000 +#define XIOEN 0x2000 +#define IDLE_EN 0x4000 + +/************************** McBSP RCR1 bit definitions ************************/ +#define RWDLEN1(value) ((value)<<5) /* Bits 5:7 */ +#define RFRLEN1(value) ((value)<<8) /* Bits 8:14 */ + +/************************** McBSP XCR1 bit definitions ************************/ +#define XWDLEN1(value) ((value)<<5) /* Bits 5:7 */ +#define XFRLEN1(value) ((value)<<8) /* Bits 8:14 */ + +/*************************** McBSP RCR2 bit definitions ***********************/ +#define RDATDLY(value) (value) /* Bits 0:1 */ +#define RFIG 0x0004 +#define RCOMPAND(value) ((value)<<3) /* Bits 3:4 */ +#define RWDLEN2(value) ((value)<<5) /* Bits 5:7 */ +#define RFRLEN2(value) ((value)<<8) /* Bits 8:14 */ +#define RPHASE 0x8000 + +/*************************** McBSP XCR2 bit definitions ***********************/ +#define XDATDLY(value) (value) /* Bits 0:1 */ +#define XFIG 0x0004 +#define XCOMPAND(value) ((value)<<3) /* Bits 3:4 */ +#define XWDLEN2(value) ((value)<<5) /* Bits 5:7 */ +#define XFRLEN2(value) ((value)<<8) /* Bits 8:14 */ +#define XPHASE 0x8000 + +/************************* McBSP SRGR1 bit definitions ************************/ +#define CLKGDV(value) (value) /* Bits 0:7 */ +#define FWID(value) ((value)<<8) /* Bits 8:15 */ + +/************************* McBSP SRGR2 bit definitions ************************/ +#define FPER(value) (value) /* Bits 0:11 */ +#define FSGM 0x1000 +#define CLKSM 0x2000 +#define CLKSP 0x4000 +#define GSYNC 0x8000 + +/************************* McBSP MCR1 bit definitions *************************/ +#define RMCM 0x0001 +#define RCBLK(value) ((value)<<2) /* Bits 2:4 */ +#define RPABLK(value) ((value)<<5) /* Bits 5:6 */ +#define RPBBLK(value) ((value)<<7) /* Bits 7:8 */ + +/************************* McBSP MCR2 bit definitions *************************/ +#define XMCM(value) (value) /* Bits 0:1 */ +#define XCBLK(value) ((value)<<2) /* Bits 2:4 */ +#define XPABLK(value) ((value)<<5) /* Bits 5:6 */ +#define XPBBLK(value) ((value)<<7) /* Bits 7:8 */ + +/*********************** McBSP XCCR bit definitions *************************/ +#define EXTCLKGATE 0x8000 +#define PPCONNECT 0x4000 +#define DXENDLY(value) ((value)<<12) /* Bits 12:13 */ +#define XFULL_CYCLE 0x0800 +#define DILB 0x0020 +#define XDMAEN 0x0008 +#define XDISABLE 0x0001 + +/********************** McBSP RCCR bit definitions *************************/ +#define RFULL_CYCLE 0x0800 +#define RDMAEN 0x0008 +#define RDISABLE 0x0001 + +/********************** McBSP SYSCONFIG bit definitions ********************/ +#define CLOCKACTIVITY(value) ((value)<<8) +#define SIDLEMODE(value) ((value)<<3) +#define ENAWAKEUP 0x0004 +#define SOFTRST 0x0002 + +/********************** McBSP SSELCR bit definitions ***********************/ +#define SIDETONEEN 0x0400 + +/********************** McBSP Sidetone SYSCONFIG bit definitions ***********/ +#define ST_AUTOIDLE 0x0001 + +/********************** McBSP Sidetone SGAINCR bit definitions *************/ +#define ST_CH1GAIN(value) ((value<<16)) /* Bits 16:31 */ +#define ST_CH0GAIN(value) (value) /* Bits 0:15 */ + +/********************** McBSP Sidetone SFIRCR bit definitions **************/ +#define ST_FIRCOEFF(value) (value) /* Bits 0:15 */ + +/********************** McBSP Sidetone SSELCR bit definitions **************/ +#define ST_COEFFWRDONE 0x0004 +#define ST_COEFFWREN 0x0002 +#define ST_SIDETONEEN 0x0001 + +/********************** McBSP DMA operating modes **************************/ +#define MCBSP_DMA_MODE_ELEMENT 0 +#define MCBSP_DMA_MODE_THRESHOLD 1 +#define MCBSP_DMA_MODE_FRAME 2 + +/********************** McBSP WAKEUPEN bit definitions *********************/ +#define XEMPTYEOFEN 0x4000 +#define XRDYEN 0x0400 +#define XEOFEN 0x0200 +#define XFSXEN 0x0100 +#define XSYNCERREN 0x0080 +#define RRDYEN 0x0008 +#define REOFEN 0x0004 +#define RFSREN 0x0002 +#define RSYNCERREN 0x0001 + +/* we don't do multichannel for now */ +struct omap_mcbsp_reg_cfg { + u16 spcr2; + u16 spcr1; + u16 rcr2; + u16 rcr1; + u16 xcr2; + u16 xcr1; + u16 srgr2; + u16 srgr1; + u16 mcr2; + u16 mcr1; + u16 pcr0; + u16 rcerc; + u16 rcerd; + u16 xcerc; + u16 xcerd; + u16 rcere; + u16 rcerf; + u16 xcere; + u16 xcerf; + u16 rcerg; + u16 rcerh; + u16 xcerg; + u16 xcerh; + u16 xccr; + u16 rccr; +}; + +void omap_mcbsp_config(unsigned int id, + 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); + +/* McBSP functional clock source changing function */ +int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id); + +/* McBSP signal muxing API */ +void omap2_mcbsp1_mux_clkr_src(u8 mux); +void omap2_mcbsp1_mux_fsr_src(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); + +/* 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); + +#endif /* __ASOC_MCBSP_H */ diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 0173719..0b30e3f 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -33,6 +33,7 @@
#include <plat/dma.h> #include <plat/mcbsp.h> +#include "mcbsp.h" #include "omap-mcbsp.h" #include "omap-pcm.h"
@@ -46,6 +47,15 @@ .private_value = (unsigned long) &(struct soc_mixer_control) \ {.min = xmin, .max = xmax} }
+enum { + OMAP_MCBSP_WORD_8 = 0, + OMAP_MCBSP_WORD_12, + OMAP_MCBSP_WORD_16, + OMAP_MCBSP_WORD_20, + OMAP_MCBSP_WORD_24, + OMAP_MCBSP_WORD_32, +}; + struct omap_mcbsp_data { unsigned int bus_id; struct omap_mcbsp_reg_cfg regs;
Allow dai drivers to register kcontrols.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com --- include/sound/soc.h | 2 ++ sound/soc/soc-core.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 2f687ed..f513758 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -372,6 +372,8 @@ int snd_soc_add_controls(struct snd_soc_codec *codec, const struct snd_kcontrol_new *controls, int num_controls); int snd_soc_add_platform_controls(struct snd_soc_platform *platform, const struct snd_kcontrol_new *controls, int num_controls); +int snd_soc_add_dai_controls(struct snd_soc_dai *dai, + const struct snd_kcontrol_new *controls, int num_controls); int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 35a1e63..d04a029 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2080,6 +2080,37 @@ int snd_soc_add_platform_controls(struct snd_soc_platform *platform, EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls);
/** + * snd_soc_add_dai_controls - add an array of controls to a dai. + * Convienience function to add a list of controls. + * + * @dai: dai to add controls to + * @controls: array of controls to add + * @num_controls: number of elements in the array + * + * Return 0 for success, else error. + */ +int snd_soc_add_dai_controls(struct snd_soc_dai *dai, + const struct snd_kcontrol_new *controls, int num_controls) +{ + struct snd_card *card = dai->card->snd_card; + int err, i; + + for (i = 0; i < num_controls; i++) { + const struct snd_kcontrol_new *control = &controls[i]; + err = snd_ctl_add(card, snd_soc_cnew(control, dai, + control->name, NULL)); + if (err < 0) { + dev_err(dai->dev, "Failed to add %s %d\n", + control->name, err); + return err; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_add_dai_controls); + +/** * snd_soc_info_enum_double - enumerated double mixer info callback * @kcontrol: mixer control * @uinfo: control element information
On Wed, 2012-02-15 at 17:37 +0200, Peter Ujfalusi wrote:
Allow dai drivers to register kcontrols.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com
include/sound/soc.h | 2 ++ sound/soc/soc-core.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 0 deletions(-)
This feature has already been applied.
Regards
Liam
On Wed, Feb 15, 2012 at 5:46 PM, Liam Girdwood lrg@ti.com wrote:
On Wed, 2012-02-15 at 17:37 +0200, Peter Ujfalusi wrote:
Allow dai drivers to register kcontrols.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com
include/sound/soc.h | 2 ++ sound/soc/soc-core.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 0 deletions(-)
This feature has already been applied.
Oh, I'll take a look and use the existing feature.
Thanks, Péter
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 --- arch/arm/mach-omap1/mcbsp.c | 12 -- arch/arm/mach-omap2/mcbsp.c | 6 - arch/arm/plat-omap/include/plat/mcbsp.h | 40 ----- sound/soc/omap/am3517evm.c | 2 +- sound/soc/omap/ams-delta.c | 2 +- sound/soc/omap/igep0020.c | 2 +- sound/soc/omap/mcbsp.c | 278 +++++-------------------------- sound/soc/omap/mcbsp.h | 104 +++++++++--- sound/soc/omap/n810.c | 2 +- sound/soc/omap/omap-mcbsp.c | 201 +++++++++++------------ sound/soc/omap/omap-mcbsp.h | 2 +- sound/soc/omap/omap-pcm.h | 2 + sound/soc/omap/omap3beagle.c | 2 +- sound/soc/omap/omap3evm.c | 2 +- sound/soc/omap/omap3pandora.c | 4 +- sound/soc/omap/osk5912.c | 2 +- sound/soc/omap/overo.c | 2 +- sound/soc/omap/rx51.c | 4 +- sound/soc/omap/sdp3430.c | 4 +- sound/soc/omap/zoom2.c | 4 +- 20 files changed, 234 insertions(+), 443 deletions(-)
diff --git a/arch/arm/mach-omap1/mcbsp.c b/arch/arm/mach-omap1/mcbsp.c index fe11e13..3e8410a 100644 --- a/arch/arm/mach-omap1/mcbsp.c +++ b/arch/arm/mach-omap1/mcbsp.c @@ -420,18 +420,6 @@ static int __init omap1_mcbsp_init(void) return -ENODEV;
if (cpu_is_omap7xx()) - omap_mcbsp_count = OMAP7XX_MCBSP_COUNT; - else if (cpu_is_omap15xx()) - omap_mcbsp_count = OMAP15XX_MCBSP_COUNT; - else if (cpu_is_omap16xx()) - omap_mcbsp_count = OMAP16XX_MCBSP_COUNT; - - mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *), - GFP_KERNEL); - if (!mcbsp_ptr) - return -ENOMEM; - - if (cpu_is_omap7xx()) omap_mcbsp_register_board_cfg(omap7xx_mcbsp_res_0, OMAP7XX_MCBSP_RES_SZ, omap7xx_mcbsp_pdata, diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c index b36d443..49ff5b8 100644 --- a/arch/arm/mach-omap2/mcbsp.c +++ b/arch/arm/mach-omap2/mcbsp.c @@ -180,7 +180,6 @@ static int omap_init_mcbsp(struct omap_hwmod *oh, void *unused) name, oh->name); return PTR_ERR(pdev); } - omap_mcbsp_count++; return 0; }
@@ -188,11 +187,6 @@ static int __init omap2_mcbsp_init(void) { omap_hwmod_for_each_by_class("mcbsp", omap_init_mcbsp, NULL);
- mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *), - GFP_KERNEL); - if (!mcbsp_ptr) - return -ENOMEM; - return 0; } arch_initcall(omap2_mcbsp_init); diff --git a/arch/arm/plat-omap/include/plat/mcbsp.h b/arch/arm/plat-omap/include/plat/mcbsp.h index 1a9e98f..437e375 100644 --- a/arch/arm/plat-omap/include/plat/mcbsp.h +++ b/arch/arm/plat-omap/include/plat/mcbsp.h @@ -70,43 +70,6 @@ struct omap_mcbsp_platform_data { int (*mux_signal)(struct device *dev, const char *signal, const char *src); };
-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 { - 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; - int dma_op_mode; - u16 max_tx_thres; - u16 max_rx_thres; - void *reg_cache; - int reg_cache_size; -}; - /** * omap_mcbsp_dev_attr - OMAP McBSP device attributes for omap_hwmod * @sidetone: name of the sidetone device @@ -115,7 +78,4 @@ struct omap_mcbsp_dev_attr { const char *sidetone; };
-extern struct omap_mcbsp **mcbsp_ptr; -extern int omap_mcbsp_count; - #endif diff --git a/sound/soc/omap/am3517evm.c b/sound/soc/omap/am3517evm.c index add4866..009533a 100644 --- a/sound/soc/omap/am3517evm.c +++ b/sound/soc/omap/am3517evm.c @@ -95,7 +95,7 @@ static const struct snd_soc_dapm_route audio_map[] = { static struct snd_soc_dai_link am3517evm_dai = { .name = "TLV320AIC23", .stream_name = "AIC23", - .cpu_dai_name ="omap-mcbsp-dai.0", + .cpu_dai_name = "omap-mcbsp.1", .codec_dai_name = "tlv320aic23-hifi", .platform_name = "omap-pcm-audio", .codec_name = "tlv320aic23-codec.2-001a", diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index a67f437..6d8081d 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c @@ -584,7 +584,7 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) static struct snd_soc_dai_link ams_delta_dai_link = { .name = "CX20442", .stream_name = "CX20442", - .cpu_dai_name ="omap-mcbsp-dai.0", + .cpu_dai_name = "omap-mcbsp.1", .codec_dai_name = "cx20442-voice", .init = ams_delta_cx20442_init, .platform_name = "omap-pcm-audio", diff --git a/sound/soc/omap/igep0020.c b/sound/soc/omap/igep0020.c index ccae58a..e835781 100644 --- a/sound/soc/omap/igep0020.c +++ b/sound/soc/omap/igep0020.c @@ -60,7 +60,7 @@ static struct snd_soc_ops igep2_ops = { static struct snd_soc_dai_link igep2_dai = { .name = "TWL4030", .stream_name = "TWL4030", - .cpu_dai_name = "omap-mcbsp-dai.1", + .cpu_dai_name = "omap-mcbsp.2", .codec_dai_name = "twl4030-hifi", .platform_name = "omap-pcm-audio", .codec_name = "twl4030-codec", diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c index 20d46bf..f255b923 100644 --- a/sound/soc/omap/mcbsp.c +++ b/sound/soc/omap/mcbsp.c @@ -30,12 +30,6 @@
#include "mcbsp.h"
-struct omap_mcbsp **mcbsp_ptr; -int omap_mcbsp_count; - -#define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count) -#define id_to_mcbsp_ptr(id) mcbsp_ptr[id]; - static void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) { void __iomem *addr = mcbsp->io_base + reg * mcbsp->pdata->reg_step; @@ -84,10 +78,8 @@ static int omap_mcbsp_st_read(struct omap_mcbsp *mcbsp, u16 reg) #define MCBSP_ST_WRITE(mcbsp, reg, val) \ omap_mcbsp_st_write(mcbsp, OMAP_ST_REG_##reg, val)
-static void omap_mcbsp_dump_reg(u8 id) +static void omap_mcbsp_dump_reg(struct omap_mcbsp *mcbsp) { - struct omap_mcbsp *mcbsp = id_to_mcbsp_ptr(id); - dev_dbg(mcbsp->dev, "**** McBSP%d regs ****\n", mcbsp->id); dev_dbg(mcbsp->dev, "DRR2: 0x%04x\n", MCBSP_READ(mcbsp, DRR2)); @@ -160,16 +152,9 @@ static irqreturn_t omap_mcbsp_rx_irq_handler(int irq, void *dev_id) * You either call this function or set the McBSP registers * by yourself before calling omap_mcbsp_start(). */ -void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config) +void omap_mcbsp_config(struct omap_mcbsp *mcbsp, + const struct omap_mcbsp_reg_cfg *config) { - struct omap_mcbsp *mcbsp; - - if (!omap_mcbsp_check_valid_id(id)) { - printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); - return; - } - mcbsp = id_to_mcbsp_ptr(id); - dev_dbg(mcbsp->dev, "Configuring McBSP%d phys_base: 0x%08lx\n", mcbsp->id, mcbsp->phys_base);
@@ -190,7 +175,6 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config) MCBSP_WRITE(mcbsp, RCCR, config->rccr); } } -EXPORT_SYMBOL(omap_mcbsp_config);
/** * omap_mcbsp_dma_params - returns the dma channel number @@ -200,22 +184,13 @@ EXPORT_SYMBOL(omap_mcbsp_config); * Returns the dma channel number for the rx channel or tx channel * based on the value of @stream for the requested mcbsp given by @id */ -int omap_mcbsp_dma_ch_params(unsigned int id, unsigned int stream) +int omap_mcbsp_dma_ch_params(struct omap_mcbsp *mcbsp, unsigned int stream) { - struct omap_mcbsp *mcbsp; - - 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); - if (stream) return mcbsp->dma_rx_sync; else return mcbsp->dma_tx_sync; } -EXPORT_SYMBOL(omap_mcbsp_dma_ch_params);
/** * omap_mcbsp_dma_reg_params - returns the address of mcbsp data register @@ -226,17 +201,10 @@ EXPORT_SYMBOL(omap_mcbsp_dma_ch_params); * to be used by DMA for transferring/receiving data based on the value of * @stream for the requested mcbsp given by @id */ -int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream) +int omap_mcbsp_dma_reg_params(struct omap_mcbsp *mcbsp, unsigned int stream) { - struct omap_mcbsp *mcbsp; int data_reg;
- 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); - if (mcbsp->pdata->reg_size == 2) { if (stream) data_reg = OMAP_MCBSP_REG_DRR1; @@ -251,7 +219,6 @@ int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream)
return mcbsp->phys_dma_base + data_reg * mcbsp->pdata->reg_step; } -EXPORT_SYMBOL(omap_mcbsp_dma_reg_params);
static void omap_st_on(struct omap_mcbsp *mcbsp) { @@ -320,18 +287,11 @@ static void omap_st_chgain(struct omap_mcbsp *mcbsp) ST_CH1GAIN(st_data->ch1gain)); }
-int omap_st_set_chgain(unsigned int id, int channel, s16 chgain) +int omap_st_set_chgain(struct omap_mcbsp *mcbsp, int channel, s16 chgain) { - struct omap_mcbsp *mcbsp; struct omap_mcbsp_st_data *st_data; int ret = 0;
- 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); st_data = mcbsp->st_data;
if (!st_data) @@ -351,20 +311,12 @@ int omap_st_set_chgain(unsigned int id, int channel, s16 chgain)
return ret; } -EXPORT_SYMBOL(omap_st_set_chgain);
-int omap_st_get_chgain(unsigned int id, int channel, s16 *chgain) +int omap_st_get_chgain(struct omap_mcbsp *mcbsp, int channel, s16 *chgain) { - struct omap_mcbsp *mcbsp; struct omap_mcbsp_st_data *st_data; int ret = 0;
- 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); st_data = mcbsp->st_data;
if (!st_data) @@ -381,7 +333,6 @@ int omap_st_get_chgain(unsigned int id, int channel, s16 *chgain)
return ret; } -EXPORT_SYMBOL(omap_st_get_chgain);
static int omap_st_start(struct omap_mcbsp *mcbsp) { @@ -400,17 +351,10 @@ static int omap_st_start(struct omap_mcbsp *mcbsp) return 0; }
-int omap_st_enable(unsigned int id) +int omap_st_enable(struct omap_mcbsp *mcbsp) { - struct omap_mcbsp *mcbsp; struct omap_mcbsp_st_data *st_data;
- 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); st_data = mcbsp->st_data;
if (!st_data) @@ -423,7 +367,6 @@ int omap_st_enable(unsigned int id)
return 0; } -EXPORT_SYMBOL(omap_st_enable);
static int omap_st_stop(struct omap_mcbsp *mcbsp) { @@ -439,18 +382,11 @@ static int omap_st_stop(struct omap_mcbsp *mcbsp) return 0; }
-int omap_st_disable(unsigned int id) +int omap_st_disable(struct omap_mcbsp *mcbsp) { - struct omap_mcbsp *mcbsp; struct omap_mcbsp_st_data *st_data; int ret = 0;
- 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); st_data = mcbsp->st_data;
if (!st_data) @@ -463,19 +399,11 @@ int omap_st_disable(unsigned int id)
return ret; } -EXPORT_SYMBOL(omap_st_disable);
-int omap_st_is_enabled(unsigned int id) +int omap_st_is_enabled(struct omap_mcbsp *mcbsp) { - struct omap_mcbsp *mcbsp; struct omap_mcbsp_st_data *st_data;
- 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); st_data = mcbsp->st_data;
if (!st_data) @@ -484,115 +412,65 @@ int omap_st_is_enabled(unsigned int id)
return st_data->enabled; } -EXPORT_SYMBOL(omap_st_is_enabled);
/* * omap_mcbsp_set_rx_threshold configures the transmit threshold in words. * The threshold parameter is 1 based, and it is converted (threshold - 1) * for the THRSH2 register. */ -void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold) +void omap_mcbsp_set_tx_threshold(struct omap_mcbsp *mcbsp, u16 threshold) { - struct omap_mcbsp *mcbsp; - - if (!omap_mcbsp_check_valid_id(id)) { - printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); - return; - } - mcbsp = id_to_mcbsp_ptr(id); if (mcbsp->pdata->buffer_size == 0) return;
if (threshold && threshold <= mcbsp->max_tx_thres) MCBSP_WRITE(mcbsp, THRSH2, threshold - 1); } -EXPORT_SYMBOL(omap_mcbsp_set_tx_threshold);
/* * omap_mcbsp_set_rx_threshold configures the receive threshold in words. * The threshold parameter is 1 based, and it is converted (threshold - 1) * for the THRSH1 register. */ -void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold) +void omap_mcbsp_set_rx_threshold(struct omap_mcbsp *mcbsp, u16 threshold) { - struct omap_mcbsp *mcbsp; - - if (!omap_mcbsp_check_valid_id(id)) { - printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); - return; - } - mcbsp = id_to_mcbsp_ptr(id); if (mcbsp->pdata->buffer_size == 0) return;
if (threshold && threshold <= mcbsp->max_rx_thres) MCBSP_WRITE(mcbsp, THRSH1, threshold - 1); } -EXPORT_SYMBOL(omap_mcbsp_set_rx_threshold);
/* * omap_mcbsp_get_max_tx_thres just return the current configured * maximum threshold for transmission */ -u16 omap_mcbsp_get_max_tx_threshold(unsigned int id) +u16 omap_mcbsp_get_max_tx_threshold(struct omap_mcbsp *mcbsp) { - struct omap_mcbsp *mcbsp; - - 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); - return mcbsp->max_tx_thres; } -EXPORT_SYMBOL(omap_mcbsp_get_max_tx_threshold);
/* * omap_mcbsp_get_max_rx_thres just return the current configured * maximum threshold for reception */ -u16 omap_mcbsp_get_max_rx_threshold(unsigned int id) +u16 omap_mcbsp_get_max_rx_threshold(struct omap_mcbsp *mcbsp) { - struct omap_mcbsp *mcbsp; - - 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); - return mcbsp->max_rx_thres; } -EXPORT_SYMBOL(omap_mcbsp_get_max_rx_threshold);
-u16 omap_mcbsp_get_fifo_size(unsigned int id) +u16 omap_mcbsp_get_fifo_size(struct omap_mcbsp *mcbsp) { - struct omap_mcbsp *mcbsp; - - 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); - return mcbsp->pdata->buffer_size; } -EXPORT_SYMBOL(omap_mcbsp_get_fifo_size);
/* * omap_mcbsp_get_tx_delay returns the number of used slots in the McBSP FIFO */ -u16 omap_mcbsp_get_tx_delay(unsigned int id) +u16 omap_mcbsp_get_tx_delay(struct omap_mcbsp *mcbsp) { - 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); if (mcbsp->pdata->buffer_size == 0) return 0;
@@ -602,22 +480,15 @@ u16 omap_mcbsp_get_tx_delay(unsigned int id) /* Number of slots are different in McBSP ports */ return mcbsp->pdata->buffer_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) +u16 omap_mcbsp_get_rx_delay(struct omap_mcbsp *mcbsp) { - 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); if (mcbsp->pdata->buffer_size == 0) return 0;
@@ -632,41 +503,25 @@ u16 omap_mcbsp_get_rx_delay(unsigned int id) 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 */ -int omap_mcbsp_get_dma_op_mode(unsigned int id) +int omap_mcbsp_get_dma_op_mode(struct omap_mcbsp *mcbsp) { - struct omap_mcbsp *mcbsp; int dma_op_mode;
- if (!omap_mcbsp_check_valid_id(id)) { - printk(KERN_ERR "%s: Invalid id (%u)\n", __func__, id + 1); - return -ENODEV; - } - mcbsp = id_to_mcbsp_ptr(id); - dma_op_mode = mcbsp->dma_op_mode;
return dma_op_mode; } -EXPORT_SYMBOL(omap_mcbsp_get_dma_op_mode);
-int omap_mcbsp_request(unsigned int id) +int omap_mcbsp_request(struct omap_mcbsp *mcbsp) { - struct omap_mcbsp *mcbsp; void *reg_cache; int err;
- 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); - reg_cache = kzalloc(mcbsp->reg_cache_size, GFP_KERNEL); if (!reg_cache) { return -ENOMEM; @@ -685,7 +540,7 @@ int omap_mcbsp_request(unsigned int id) spin_unlock(&mcbsp->lock);
if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request) - mcbsp->pdata->ops->request(id); + mcbsp->pdata->ops->request(mcbsp->id - 1);
pm_runtime_get_sync(mcbsp->dev);
@@ -726,7 +581,7 @@ err_free_irq: free_irq(mcbsp->tx_irq, (void *)mcbsp); err_clk_disable: if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free) - mcbsp->pdata->ops->free(id); + mcbsp->pdata->ops->free(mcbsp->id - 1);
/* Disable wakeup behavior */ if (mcbsp->pdata->has_wakeup) @@ -743,21 +598,13 @@ err_kfree:
return err; } -EXPORT_SYMBOL(omap_mcbsp_request);
-void omap_mcbsp_free(unsigned int id) +void omap_mcbsp_free(struct omap_mcbsp *mcbsp) { - struct omap_mcbsp *mcbsp; void *reg_cache;
- if (!omap_mcbsp_check_valid_id(id)) { - printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); - return; - } - mcbsp = id_to_mcbsp_ptr(id); - if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free) - mcbsp->pdata->ops->free(id); + mcbsp->pdata->ops->free(mcbsp->id - 1);
/* Disable wakeup behavior */ if (mcbsp->pdata->has_wakeup) @@ -782,25 +629,17 @@ void omap_mcbsp_free(unsigned int id) if (reg_cache) kfree(reg_cache); } -EXPORT_SYMBOL(omap_mcbsp_free);
/* * Here we start the McBSP, by enabling transmitter, receiver or both. * If no transmitter or receiver is active prior calling, then sample-rate * generator and frame sync are started. */ -void omap_mcbsp_start(unsigned int id, int tx, int rx) +void omap_mcbsp_start(struct omap_mcbsp *mcbsp, int tx, int rx) { - struct omap_mcbsp *mcbsp; int enable_srg = 0; u16 w;
- if (!omap_mcbsp_check_valid_id(id)) { - printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); - return; - } - mcbsp = id_to_mcbsp_ptr(id); - if (mcbsp->st_data) omap_st_start(mcbsp);
@@ -850,23 +689,14 @@ void omap_mcbsp_start(unsigned int id, int tx, int rx) }
/* Dump McBSP Regs */ - omap_mcbsp_dump_reg(id); + omap_mcbsp_dump_reg(mcbsp); } -EXPORT_SYMBOL(omap_mcbsp_start);
-void omap_mcbsp_stop(unsigned int id, int tx, int rx) +void omap_mcbsp_stop(struct omap_mcbsp *mcbsp, int tx, int rx) { - struct omap_mcbsp *mcbsp; int idle; u16 w;
- if (!omap_mcbsp_check_valid_id(id)) { - printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); - return; - } - - mcbsp = id_to_mcbsp_ptr(id); - /* Reset transmitter */ tx &= 1; if (mcbsp->pdata->has_ccr) { @@ -899,19 +729,11 @@ void omap_mcbsp_stop(unsigned int id, int tx, int rx) if (mcbsp->st_data) omap_st_stop(mcbsp); } -EXPORT_SYMBOL(omap_mcbsp_stop);
-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) { - struct omap_mcbsp *mcbsp; const char *src;
- if (!omap_mcbsp_check_valid_id(id)) { - pr_err("%s: Invalid id (%d)\n", __func__, id + 1); - return -EINVAL; - } - mcbsp = id_to_mcbsp_ptr(id); - if (fck_src_id == MCBSP_CLKS_PAD_SRC) src = "clks_ext"; else if (fck_src_id == MCBSP_CLKS_PRCM_SRC) @@ -924,13 +746,14 @@ int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id) else return -EINVAL; } -EXPORT_SYMBOL(omap2_mcbsp_set_clks_src);
-void omap2_mcbsp1_mux_clkr_src(u8 mux) +void omap2_mcbsp1_mux_clkr_src(struct omap_mcbsp *mcbsp, u8 mux) { - struct omap_mcbsp *mcbsp; const char *src;
+ if (mcbsp->id != 1) + return; + if (mux == CLKR_SRC_CLKR) src = "clkr"; else if (mux == CLKR_SRC_CLKX) @@ -938,17 +761,17 @@ void omap2_mcbsp1_mux_clkr_src(u8 mux) else return;
- mcbsp = id_to_mcbsp_ptr(0); if (mcbsp->pdata->mux_signal) mcbsp->pdata->mux_signal(mcbsp->dev, "clkr", src); } -EXPORT_SYMBOL(omap2_mcbsp1_mux_clkr_src);
-void omap2_mcbsp1_mux_fsr_src(u8 mux) +void omap2_mcbsp1_mux_fsr_src(struct omap_mcbsp *mcbsp, u8 mux) { - struct omap_mcbsp *mcbsp; const char *src;
+ if (mcbsp->id != 1) + return; + if (mux == FSR_SRC_FSR) src = "fsr"; else if (mux == FSR_SRC_FSX) @@ -956,11 +779,9 @@ void omap2_mcbsp1_mux_fsr_src(u8 mux) else return;
- mcbsp = id_to_mcbsp_ptr(0); if (mcbsp->pdata->mux_signal) mcbsp->pdata->mux_signal(mcbsp->dev, "fsr", src); } -EXPORT_SYMBOL(omap2_mcbsp1_mux_fsr_src);
#define max_thres(m) (mcbsp->pdata->buffer_size) #define valid_threshold(m, val) ((val) <= max_thres(m)) @@ -1177,11 +998,10 @@ static void __devexit omap_st_remove(struct omap_mcbsp *mcbsp) * McBSP1 and McBSP3 are directly mapped on 1610 and 1510. * 730 has only 2 McBSP, and both of them are MPU peripherals. */ -static int __devinit omap_mcbsp_probe(struct platform_device *pdev) +int __devinit omap_mcbsp_probe(struct platform_device *pdev) { struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data; struct omap_mcbsp *mcbsp; - int id = pdev->id - 1; struct resource *res; int ret = 0;
@@ -1194,12 +1014,6 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "Initializing OMAP McBSP (%d).\n", pdev->id);
- if (id >= omap_mcbsp_count) { - dev_err(&pdev->dev, "Invalid McBSP device id (%d)\n", id); - ret = -EINVAL; - goto exit; - } - mcbsp = kzalloc(sizeof(struct omap_mcbsp), GFP_KERNEL); if (!mcbsp) { ret = -ENOMEM; @@ -1207,7 +1021,7 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev) }
spin_lock_init(&mcbsp->lock); - mcbsp->id = id + 1; + mcbsp->id = pdev->id; mcbsp->free = true;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); @@ -1268,7 +1082,6 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
mcbsp->pdata = pdata; mcbsp->dev = &pdev->dev; - mcbsp_ptr[id] = mcbsp; platform_set_drvdata(pdev, mcbsp); pm_runtime_enable(mcbsp->dev);
@@ -1323,7 +1136,7 @@ exit: return ret; }
-static int __devexit omap_mcbsp_remove(struct platform_device *pdev) +int __devexit omap_mcbsp_remove(struct platform_device *pdev) { struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev);
@@ -1349,18 +1162,3 @@ static int __devexit omap_mcbsp_remove(struct platform_device *pdev)
return 0; } - -static struct platform_driver omap_mcbsp_driver = { - .probe = omap_mcbsp_probe, - .remove = __devexit_p(omap_mcbsp_remove), - .driver = { - .name = "omap-mcbsp", - }, -}; - -module_platform_driver(omap_mcbsp_driver); - -MODULE_AUTHOR("Samuel Ortiz samuel.ortiz@nokia.com"); -MODULE_DESCRIPTION("OMAP McBSP core driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:omap-mcbsp"); diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h index 5590ab2..6d57993 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 */ diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index 597be41..82d23f5 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c @@ -276,7 +276,7 @@ static int n810_aic33_init(struct snd_soc_pcm_runtime *rtd) static struct snd_soc_dai_link n810_dai = { .name = "TLV320AIC33", .stream_name = "AIC33", - .cpu_dai_name = "omap-mcbsp-dai.1", + .cpu_dai_name = "omap-mcbsp.2", .platform_name = "omap-pcm-audio", .codec_name = "tlv320aic3x-codec.2-0018", .codec_dai_name = "tlv320aic3x-hifi", diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 0b30e3f..8924002 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -56,36 +56,18 @@ enum { OMAP_MCBSP_WORD_32, };
-struct omap_mcbsp_data { - unsigned int bus_id; - struct omap_mcbsp_reg_cfg regs; - 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; -}; - -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]; - static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; struct omap_pcm_dma_data *dma_data; - int dma_op_mode = omap_mcbsp_get_dma_op_mode(mcbsp_data->bus_id); + int dma_op_mode = omap_mcbsp_get_dma_op_mode(mcbsp); int words;
dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); @@ -107,9 +89,9 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream)
/* Configure McBSP internal buffer usage */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - omap_mcbsp_set_tx_threshold(mcbsp_data->bus_id, words); + omap_mcbsp_set_tx_threshold(mcbsp, words); else - omap_mcbsp_set_rx_threshold(mcbsp_data->bus_id, words); + omap_mcbsp_set_rx_threshold(mcbsp, words); }
static int omap_mcbsp_hwrule_min_buffersize(struct snd_pcm_hw_params *params, @@ -119,12 +101,12 @@ static int omap_mcbsp_hwrule_min_buffersize(struct snd_pcm_hw_params *params, SNDRV_PCM_HW_PARAM_BUFFER_SIZE); struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - struct omap_mcbsp_data *mcbsp_data = rule->private; + struct omap_mcbsp *mcbsp = rule->private; struct snd_interval frames; int size;
snd_interval_any(&frames); - size = omap_mcbsp_get_fifo_size(mcbsp_data->bus_id); + size = omap_mcbsp_get_fifo_size(mcbsp);
frames.min = size / channels->min; frames.integer = 1; @@ -134,12 +116,11 @@ static int omap_mcbsp_hwrule_min_buffersize(struct snd_pcm_hw_params *params, static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { - struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); - int bus_id = mcbsp_data->bus_id; + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); int err = 0;
if (!cpu_dai->active) - err = omap_mcbsp_request(bus_id); + err = omap_mcbsp_request(mcbsp);
/* * OMAP3 McBSP FIFO is word structured. @@ -156,7 +137,7 @@ static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream, * 2 channels (stereo): size is 128 / 2 = 64 frames (2 * 64 words) * 4 channels: size is 128 / 4 = 32 frames (4 * 32 words) */ - if (cpu_is_omap34xx() || cpu_is_omap44xx()) { + if (mcbsp->pdata->buffer_size) { /* * Rule for the buffer size. We should not allow * smaller buffer than the FIFO size to avoid underruns @@ -164,7 +145,7 @@ static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream, snd_pcm_hw_rule_add(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, omap_mcbsp_hwrule_min_buffersize, - mcbsp_data, + mcbsp, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, -1);
/* Make sure, that the period size is always even */ @@ -178,10 +159,11 @@ static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream, static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { - struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data;
if (!cpu_dai->active) { - omap_mcbsp_free(mcbsp_data->bus_id); + omap_mcbsp_free(mcbsp); mcbsp_data->configured = 0; } } @@ -189,7 +171,8 @@ static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream, static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *cpu_dai) { - struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; int err = 0, play = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
switch (cmd) { @@ -197,13 +180,13 @@ static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: mcbsp_data->active++; - omap_mcbsp_start(mcbsp_data->bus_id, play, !play); + omap_mcbsp_start(mcbsp, play, !play); break;
case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - omap_mcbsp_stop(mcbsp_data->bus_id, play, !play); + omap_mcbsp_stop(mcbsp, play, !play); mcbsp_data->active--; break; default: @@ -219,14 +202,14 @@ static snd_pcm_sframes_t omap_mcbsp_dai_delay( { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); u16 fifo_use; snd_pcm_sframes_t delay;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - fifo_use = omap_mcbsp_get_tx_delay(mcbsp_data->bus_id); + fifo_use = omap_mcbsp_get_tx_delay(mcbsp); else - fifo_use = omap_mcbsp_get_rx_delay(mcbsp_data->bus_id); + fifo_use = omap_mcbsp_get_rx_delay(mcbsp);
/* * Divide the used locations with the channel count to get the @@ -242,19 +225,20 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *cpu_dai) { - struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; struct omap_pcm_dma_data *dma_data; - int dma, bus_id = mcbsp_data->bus_id; + int dma; int wlen, channels, wpf, sync_mode = OMAP_DMA_SYNC_ELEMENT; int pkt_size = 0; unsigned long port; unsigned int format, div, framesize, master;
- dma_data = &omap_mcbsp_dai_dma_params[cpu_dai->id][substream->stream]; + dma_data = &mcbsp_data->dma_data[substream->stream];
- dma = omap_mcbsp_dma_ch_params(bus_id, substream->stream); - port = omap_mcbsp_dma_reg_params(bus_id, substream->stream); + dma = omap_mcbsp_dma_ch_params(mcbsp, substream->stream); + port = omap_mcbsp_dma_reg_params(mcbsp, substream->stream);
switch (params_format(params)) { case SNDRV_PCM_FORMAT_S16_LE: @@ -268,20 +252,20 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, default: return -EINVAL; } - if (cpu_is_omap34xx() || cpu_is_omap44xx()) { + if (mcbsp->pdata->buffer_size) { dma_data->set_threshold = omap_mcbsp_set_threshold; /* TODO: Currently, MODE_ELEMENT == MODE_FRAME */ - if (omap_mcbsp_get_dma_op_mode(bus_id) == + if (omap_mcbsp_get_dma_op_mode(mcbsp) == MCBSP_DMA_MODE_THRESHOLD) { int period_words, max_thrsh;
period_words = params_period_bytes(params) / (wlen / 8); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) max_thrsh = omap_mcbsp_get_max_tx_threshold( - mcbsp_data->bus_id); + mcbsp); else max_thrsh = omap_mcbsp_get_max_rx_threshold( - mcbsp_data->bus_id); + mcbsp); /* * If the period contains less or equal number of words, * we are using the original threshold mode setup: @@ -398,7 +382,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, break; }
- omap_mcbsp_config(bus_id, &mcbsp_data->regs); + omap_mcbsp_config(mcbsp, &mcbsp_data->regs); mcbsp_data->wlen = wlen; mcbsp_data->configured = 1;
@@ -412,7 +396,8 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) { - struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; bool inv_fs = false;
@@ -514,7 +499,8 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai, static int omap_mcbsp_dai_set_clkdiv(struct snd_soc_dai *cpu_dai, int div_id, int div) { - struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
if (div_id != OMAP_MCBSP_CLKGDV) @@ -531,7 +517,8 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, unsigned int freq, int dir) { - struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); + struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; int err = 0;
@@ -547,7 +534,7 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, clk_id == OMAP_MCBSP_CLKR_SRC_CLKX || clk_id == OMAP_MCBSP_FSR_SRC_FSR || clk_id == OMAP_MCBSP_FSR_SRC_FSX) - if (cpu_class_is_omap1() || mcbsp_data->bus_id != 0) + if (cpu_class_is_omap1() || cpu_dai->id != 1) return -EINVAL;
mcbsp_data->in_freq = freq; @@ -563,7 +550,7 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, err = -EINVAL; break; } - err = omap2_mcbsp_set_clks_src(mcbsp_data->bus_id, + err = omap2_mcbsp_set_clks_src(mcbsp, MCBSP_CLKS_PRCM_SRC); break; case OMAP_MCBSP_SYSCLK_CLKS_EXT: @@ -571,7 +558,7 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, err = 0; break; } - err = omap2_mcbsp_set_clks_src(mcbsp_data->bus_id, + err = omap2_mcbsp_set_clks_src(mcbsp, MCBSP_CLKS_PAD_SRC); break;
@@ -585,22 +572,22 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, case OMAP_MCBSP_CLKR_SRC_CLKR: if (cpu_class_is_omap1()) break; - omap2_mcbsp1_mux_clkr_src(CLKR_SRC_CLKR); + omap2_mcbsp1_mux_clkr_src(mcbsp, CLKR_SRC_CLKR); break; case OMAP_MCBSP_CLKR_SRC_CLKX: if (cpu_class_is_omap1()) break; - omap2_mcbsp1_mux_clkr_src(CLKR_SRC_CLKX); + omap2_mcbsp1_mux_clkr_src(mcbsp, CLKR_SRC_CLKX); break; case OMAP_MCBSP_FSR_SRC_FSR: if (cpu_class_is_omap1()) break; - omap2_mcbsp1_mux_fsr_src(FSR_SRC_FSR); + omap2_mcbsp1_mux_fsr_src(mcbsp, FSR_SRC_FSR); break; case OMAP_MCBSP_FSR_SRC_FSX: if (cpu_class_is_omap1()) break; - omap2_mcbsp1_mux_fsr_src(FSR_SRC_FSX); + omap2_mcbsp1_mux_fsr_src(mcbsp, FSR_SRC_FSX); break; default: err = -ENODEV; @@ -620,15 +607,7 @@ static const struct snd_soc_dai_ops mcbsp_dai_ops = { .set_sysclk = omap_mcbsp_dai_set_dai_sysclk, };
-static int mcbsp_dai_probe(struct snd_soc_dai *dai) -{ - mcbsp_data[dai->id].bus_id = dai->id; - snd_soc_dai_set_drvdata(dai, &mcbsp_data[dai->id].bus_id); - return 0; -} - static struct snd_soc_dai_driver omap_mcbsp_dai = { - .probe = mcbsp_dai_probe, .playback = { .channels_min = 1, .channels_max = 16, @@ -659,11 +638,13 @@ static int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol, return 0; }
-#define OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(id, channel) \ +#define OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(channel) \ static int \ -omap_mcbsp##id##_set_st_ch##channel##_volume(struct snd_kcontrol *kc, \ +omap_mcbsp_set_st_ch##channel##_volume(struct snd_kcontrol *kc, \ struct snd_ctl_elem_value *uc) \ { \ + struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kc); \ + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); \ struct soc_mixer_control *mc = \ (struct soc_mixer_control *)kc->private_value; \ int max = mc->max; \ @@ -674,46 +655,44 @@ omap_mcbsp##id##_set_st_ch##channel##_volume(struct snd_kcontrol *kc, \ return -EINVAL; \ \ /* OMAP McBSP implementation uses index values 0..4 */ \ - return omap_st_set_chgain((id)-1, channel, val); \ + return omap_st_set_chgain(mcbsp, channel, val); \ }
-#define OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(id, channel) \ +#define OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(channel) \ static int \ -omap_mcbsp##id##_get_st_ch##channel##_volume(struct snd_kcontrol *kc, \ +omap_mcbsp_get_st_ch##channel##_volume(struct snd_kcontrol *kc, \ struct snd_ctl_elem_value *uc) \ { \ + struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kc); \ + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); \ s16 chgain; \ \ - if (omap_st_get_chgain((id)-1, channel, &chgain)) \ + if (omap_st_get_chgain(mcbsp, channel, &chgain)) \ return -EAGAIN; \ \ uc->value.integer.value[0] = chgain; \ return 0; \ }
-OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 0) -OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 1) -OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 0) -OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 1) -OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 0) -OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 1) -OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 0) -OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 1) +OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(0) +OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(1) +OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(0) +OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(1)
static int omap_mcbsp_st_put_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; + struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol); + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); u8 value = ucontrol->value.integer.value[0];
- if (value == omap_st_is_enabled(mc->reg)) + if (value == omap_st_is_enabled(mcbsp)) return 0;
if (value) - omap_st_enable(mc->reg); + omap_st_enable(mcbsp); else - omap_st_disable(mc->reg); + omap_st_disable(mcbsp);
return 1; } @@ -721,10 +700,10 @@ static int omap_mcbsp_st_put_mode(struct snd_kcontrol *kcontrol, static int omap_mcbsp_st_get_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; + struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol); + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
- ucontrol->value.integer.value[0] = omap_st_is_enabled(mc->reg); + ucontrol->value.integer.value[0] = omap_st_is_enabled(mcbsp); return 0; }
@@ -733,12 +712,12 @@ static const struct snd_kcontrol_new omap_mcbsp2_st_controls[] = { omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode), OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 0 Volume", -32768, 32767, - omap_mcbsp2_get_st_ch0_volume, - omap_mcbsp2_set_st_ch0_volume), + omap_mcbsp_get_st_ch0_volume, + omap_mcbsp_set_st_ch0_volume), OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 1 Volume", -32768, 32767, - omap_mcbsp2_get_st_ch1_volume, - omap_mcbsp2_set_st_ch1_volume), + omap_mcbsp_get_st_ch1_volume, + omap_mcbsp_set_st_ch1_volume), };
static const struct snd_kcontrol_new omap_mcbsp3_st_controls[] = { @@ -746,25 +725,30 @@ static const struct snd_kcontrol_new omap_mcbsp3_st_controls[] = { omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode), OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 0 Volume", -32768, 32767, - omap_mcbsp3_get_st_ch0_volume, - omap_mcbsp3_set_st_ch0_volume), + omap_mcbsp_get_st_ch0_volume, + omap_mcbsp_set_st_ch0_volume), OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 1 Volume", -32768, 32767, - omap_mcbsp3_get_st_ch1_volume, - omap_mcbsp3_set_st_ch1_volume), + omap_mcbsp_get_st_ch1_volume, + omap_mcbsp_set_st_ch1_volume), };
-int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id) +int omap_mcbsp_st_add_controls(struct snd_soc_pcm_runtime *rtd) { - if (!cpu_is_omap34xx()) + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); + + if (!mcbsp->st_data) return -ENODEV;
- switch (mcbsp_id) { - case 1: /* McBSP 2 */ - return snd_soc_add_controls(codec, omap_mcbsp2_st_controls, + switch (cpu_dai->id) { + case 2: /* McBSP 2 */ + return snd_soc_add_dai_controls(cpu_dai, + omap_mcbsp2_st_controls, ARRAY_SIZE(omap_mcbsp2_st_controls)); - case 2: /* McBSP 3 */ - return snd_soc_add_controls(codec, omap_mcbsp3_st_controls, + case 3: /* McBSP 3 */ + return snd_soc_add_dai_controls(cpu_dai, + omap_mcbsp3_st_controls, ARRAY_SIZE(omap_mcbsp3_st_controls)); default: break; @@ -776,18 +760,25 @@ EXPORT_SYMBOL_GPL(omap_mcbsp_st_add_controls);
static __devinit int asoc_mcbsp_probe(struct platform_device *pdev) { - return snd_soc_register_dai(&pdev->dev, &omap_mcbsp_dai); + int ret; + + ret = omap_mcbsp_probe(pdev); + if (!ret) + return snd_soc_register_dai(&pdev->dev, &omap_mcbsp_dai); + + return ret; }
static int __devexit asoc_mcbsp_remove(struct platform_device *pdev) { + omap_mcbsp_remove(pdev); snd_soc_unregister_dai(&pdev->dev); return 0; }
static struct platform_driver asoc_mcbsp_driver = { .driver = { - .name = "omap-mcbsp-dai", + .name = "omap-mcbsp", .owner = THIS_MODULE, },
diff --git a/sound/soc/omap/omap-mcbsp.h b/sound/soc/omap/omap-mcbsp.h index 65cde9d..f877b16 100644 --- a/sound/soc/omap/omap-mcbsp.h +++ b/sound/soc/omap/omap-mcbsp.h @@ -59,6 +59,6 @@ enum omap_mcbsp_div { #define NUM_LINKS 5 #endif
-int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id); +int omap_mcbsp_st_add_controls(struct snd_soc_pcm_runtime *rtd);
#endif diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h index f95fe30..b92248c 100644 --- a/sound/soc/omap/omap-pcm.h +++ b/sound/soc/omap/omap-pcm.h @@ -25,6 +25,8 @@ #ifndef __OMAP_PCM_H__ #define __OMAP_PCM_H__
+struct snd_pcm_substream; + struct omap_pcm_dma_data { char *name; /* stream identifier */ int dma_req; /* DMA request line */ diff --git a/sound/soc/omap/omap3beagle.c b/sound/soc/omap/omap3beagle.c index 3357dcc..2830dfd 100644 --- a/sound/soc/omap/omap3beagle.c +++ b/sound/soc/omap/omap3beagle.c @@ -91,7 +91,7 @@ static struct snd_soc_ops omap3beagle_ops = { static struct snd_soc_dai_link omap3beagle_dai = { .name = "TWL4030", .stream_name = "TWL4030", - .cpu_dai_name = "omap-mcbsp-dai.1", + .cpu_dai_name = "omap-mcbsp.2", .platform_name = "omap-pcm-audio", .codec_dai_name = "twl4030-hifi", .codec_name = "twl4030-codec", diff --git a/sound/soc/omap/omap3evm.c b/sound/soc/omap/omap3evm.c index 071fcb0..3d468c9 100644 --- a/sound/soc/omap/omap3evm.c +++ b/sound/soc/omap/omap3evm.c @@ -58,7 +58,7 @@ static struct snd_soc_ops omap3evm_ops = { static struct snd_soc_dai_link omap3evm_dai = { .name = "TWL4030", .stream_name = "TWL4030", - .cpu_dai_name = "omap-mcbsp-dai.1", + .cpu_dai_name = "omap-mcbsp.2", .codec_dai_name = "twl4030-hifi", .platform_name = "omap-pcm-audio", .codec_name = "twl4030-codec", diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c index 07794bd..4c3a097 100644 --- a/sound/soc/omap/omap3pandora.c +++ b/sound/soc/omap/omap3pandora.c @@ -208,7 +208,7 @@ static struct snd_soc_dai_link omap3pandora_dai[] = { { .name = "PCM1773", .stream_name = "HiFi Out", - .cpu_dai_name = "omap-mcbsp-dai.1", + .cpu_dai_name = "omap-mcbsp.2", .codec_dai_name = "twl4030-hifi", .platform_name = "omap-pcm-audio", .codec_name = "twl4030-codec", @@ -219,7 +219,7 @@ static struct snd_soc_dai_link omap3pandora_dai[] = { }, { .name = "TWL4030", .stream_name = "Line/Mic In", - .cpu_dai_name = "omap-mcbsp-dai.3", + .cpu_dai_name = "omap-mcbsp.4", .codec_dai_name = "twl4030-hifi", .platform_name = "omap-pcm-audio", .codec_name = "twl4030-codec", diff --git a/sound/soc/omap/osk5912.c b/sound/soc/omap/osk5912.c index d859b59..b1a9d64 100644 --- a/sound/soc/omap/osk5912.c +++ b/sound/soc/omap/osk5912.c @@ -96,7 +96,7 @@ static const struct snd_soc_dapm_route audio_map[] = { static struct snd_soc_dai_link osk_dai = { .name = "TLV320AIC23", .stream_name = "AIC23", - .cpu_dai_name = "omap-mcbsp-dai.0", + .cpu_dai_name = "omap-mcbsp.1", .codec_dai_name = "tlv320aic23-hifi", .platform_name = "omap-pcm-audio", .codec_name = "tlv320aic23-codec", diff --git a/sound/soc/omap/overo.c b/sound/soc/omap/overo.c index 2ee889c..6ac3e0c 100644 --- a/sound/soc/omap/overo.c +++ b/sound/soc/omap/overo.c @@ -60,7 +60,7 @@ static struct snd_soc_ops overo_ops = { static struct snd_soc_dai_link overo_dai = { .name = "TWL4030", .stream_name = "TWL4030", - .cpu_dai_name = "omap-mcbsp-dai.1", + .cpu_dai_name = "omap-mcbsp.2", .codec_dai_name = "twl4030-hifi", .platform_name = "omap-pcm-audio", .codec_name = "twl4030-codec", diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index fada6ef..28c87f4 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c @@ -314,7 +314,7 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) return err; snd_soc_limit_volume(codec, "TPA6130A2 Headphone Playback Volume", 42);
- err = omap_mcbsp_st_add_controls(codec, 1); + err = omap_mcbsp_st_add_controls(rtd); if (err < 0) return err;
@@ -354,7 +354,7 @@ static struct snd_soc_dai_link rx51_dai[] = { { .name = "TLV320AIC34", .stream_name = "AIC34", - .cpu_dai_name = "omap-mcbsp-dai.1", + .cpu_dai_name = "omap-mcbsp.2", .codec_dai_name = "tlv320aic3x-hifi", .platform_name = "omap-pcm-audio", .codec_name = "tlv320aic3x-codec.2-0018", diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c index 2c85066..0e28322 100644 --- a/sound/soc/omap/sdp3430.c +++ b/sound/soc/omap/sdp3430.c @@ -187,7 +187,7 @@ static struct snd_soc_dai_link sdp3430_dai[] = { { .name = "TWL4030 I2S", .stream_name = "TWL4030 Audio", - .cpu_dai_name = "omap-mcbsp-dai.1", + .cpu_dai_name = "omap-mcbsp.2", .codec_dai_name = "twl4030-hifi", .platform_name = "omap-pcm-audio", .codec_name = "twl4030-codec", @@ -199,7 +199,7 @@ static struct snd_soc_dai_link sdp3430_dai[] = { { .name = "TWL4030 PCM", .stream_name = "TWL4030 Voice", - .cpu_dai_name = "omap-mcbsp-dai.2", + .cpu_dai_name = "omap-mcbsp.3", .codec_dai_name = "twl4030-voice", .platform_name = "omap-pcm-audio", .codec_name = "twl4030-codec", diff --git a/sound/soc/omap/zoom2.c b/sound/soc/omap/zoom2.c index 981616d..920e0d9 100644 --- a/sound/soc/omap/zoom2.c +++ b/sound/soc/omap/zoom2.c @@ -131,7 +131,7 @@ static struct snd_soc_dai_link zoom2_dai[] = { { .name = "TWL4030 I2S", .stream_name = "TWL4030 Audio", - .cpu_dai_name = "omap-mcbsp-dai.1", + .cpu_dai_name = "omap-mcbsp.2", .codec_dai_name = "twl4030-hifi", .platform_name = "omap-pcm-audio", .codec_name = "twl4030-codec", @@ -143,7 +143,7 @@ static struct snd_soc_dai_link zoom2_dai[] = { { .name = "TWL4030 PCM", .stream_name = "TWL4030 Voice", - .cpu_dai_name = "omap-mcbsp-dai.2", + .cpu_dai_name = "omap-mcbsp.3", .codec_dai_name = "twl4030-voice", .platform_name = "omap-pcm-audio", .codec_name = "twl4030-codec",
The driver for omap-mcbsp-dai no longer exist since it has been merged with the omap-mcbsp driver.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com --- arch/arm/mach-omap1/devices.c | 9 --------- arch/arm/mach-omap2/devices.c | 22 ---------------------- arch/arm/plat-omap/include/plat/mcbsp.h | 7 ------- 3 files changed, 0 insertions(+), 38 deletions(-)
diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c index 1d76a63..187b2fe 100644 --- a/arch/arm/mach-omap1/devices.c +++ b/arch/arm/mach-omap1/devices.c @@ -28,7 +28,6 @@ #include <plat/mux.h> #include <plat/mmc.h> #include <plat/omap7xx.h> -#include <plat/mcbsp.h>
#include "clock.h"
@@ -250,16 +249,8 @@ static struct platform_device omap_pcm = { .id = -1, };
-OMAP_MCBSP_PLATFORM_DEVICE(1); -OMAP_MCBSP_PLATFORM_DEVICE(2); -OMAP_MCBSP_PLATFORM_DEVICE(3); - static void omap_init_audio(void) { - platform_device_register(&omap_mcbsp1); - platform_device_register(&omap_mcbsp2); - if (!cpu_is_omap7xx()) - platform_device_register(&omap_mcbsp3); platform_device_register(&omap_pcm); }
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index 0b510ad..ba540aa 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c @@ -26,7 +26,6 @@
#include <plat/tc.h> #include <plat/board.h> -#include <plat/mcbsp.h> #include <plat/mmc.h> #include <plat/dma.h> #include <plat/omap_hwmod.h> @@ -304,29 +303,8 @@ static struct platform_device omap_pcm = { .id = -1, };
-/* - * OMAP2420 has 2 McBSP ports - * OMAP2430 has 5 McBSP ports - * OMAP3 has 5 McBSP ports - * OMAP4 has 4 McBSP ports - */ -OMAP_MCBSP_PLATFORM_DEVICE(1); -OMAP_MCBSP_PLATFORM_DEVICE(2); -OMAP_MCBSP_PLATFORM_DEVICE(3); -OMAP_MCBSP_PLATFORM_DEVICE(4); -OMAP_MCBSP_PLATFORM_DEVICE(5); - static void omap_init_audio(void) { - platform_device_register(&omap_mcbsp1); - platform_device_register(&omap_mcbsp2); - if (cpu_is_omap243x() || cpu_is_omap34xx() || cpu_is_omap44xx()) { - platform_device_register(&omap_mcbsp3); - platform_device_register(&omap_mcbsp4); - } - if (cpu_is_omap243x() || cpu_is_omap34xx()) - platform_device_register(&omap_mcbsp5); - platform_device_register(&omap_pcm); }
diff --git a/arch/arm/plat-omap/include/plat/mcbsp.h b/arch/arm/plat-omap/include/plat/mcbsp.h index 437e375..8eb9b0e 100644 --- a/arch/arm/plat-omap/include/plat/mcbsp.h +++ b/arch/arm/plat-omap/include/plat/mcbsp.h @@ -27,13 +27,6 @@ #include <linux/spinlock.h> #include <linux/clk.h>
-/* macro for building platform_device for McBSP ports */ -#define OMAP_MCBSP_PLATFORM_DEVICE(port_nr) \ -static struct platform_device omap_mcbsp##port_nr = { \ - .name = "omap-mcbsp-dai", \ - .id = port_nr - 1, \ -} - #define MCBSP_CONFIG_TYPE2 0x2 #define MCBSP_CONFIG_TYPE3 0x3 #define MCBSP_CONFIG_TYPE4 0x4
Use BIT() for bit position, correct field definition by adding mask to them, and also adding the missing spaces around '<<'
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com --- sound/soc/omap/mcbsp.h | 194 ++++++++++++++++++++++++------------------------ 1 files changed, 97 insertions(+), 97 deletions(-)
diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h index 6d57993..ec00c27 100644 --- a/sound/soc/omap/mcbsp.h +++ b/sound/soc/omap/mcbsp.h @@ -89,130 +89,130 @@ enum { #define OMAP_ST_REG_SSELCR 0x2C
/************************** McBSP SPCR1 bit definitions ***********************/ -#define RRST 0x0001 -#define RRDY 0x0002 -#define RFULL 0x0004 -#define RSYNC_ERR 0x0008 -#define RINTM(value) ((value)<<4) /* bits 4:5 */ -#define ABIS 0x0040 -#define DXENA 0x0080 -#define CLKSTP(value) ((value)<<11) /* bits 11:12 */ -#define RJUST(value) ((value)<<13) /* bits 13:14 */ -#define ALB 0x8000 -#define DLB 0x8000 +#define RRST BIT(0) +#define RRDY BIT(1) +#define RFULL BIT(2) +#define RSYNC_ERR BIT(3) +#define RINTM(value) (((value) & 0x3) << 4) /* bits 4:5 */ +#define ABIS BIT(6) +#define DXENA BIT(7) +#define CLKSTP(value) (((value) & 0x3) << 11) /* bits 11:12 */ +#define RJUST(value) (((value) & 0x3) << 13) /* bits 13:14 */ +#define ALB BIT(15) +#define DLB BIT(15)
/************************** McBSP SPCR2 bit definitions ***********************/ -#define XRST 0x0001 -#define XRDY 0x0002 -#define XEMPTY 0x0004 -#define XSYNC_ERR 0x0008 -#define XINTM(value) ((value)<<4) /* bits 4:5 */ -#define GRST 0x0040 -#define FRST 0x0080 -#define SOFT 0x0100 -#define FREE 0x0200 +#define XRST BIT(0) +#define XRDY BIT(1) +#define XEMPTY BIT(2) +#define XSYNC_ERR BIT(3) +#define XINTM(value) (((value) & 0x3) << 4) /* bits 4:5 */ +#define GRST BIT(6) +#define FRST BIT(7) +#define SOFT BIT(8) +#define FREE BIT(9)
/************************** McBSP PCR bit definitions *************************/ -#define CLKRP 0x0001 -#define CLKXP 0x0002 -#define FSRP 0x0004 -#define FSXP 0x0008 -#define DR_STAT 0x0010 -#define DX_STAT 0x0020 -#define CLKS_STAT 0x0040 -#define SCLKME 0x0080 -#define CLKRM 0x0100 -#define CLKXM 0x0200 -#define FSRM 0x0400 -#define FSXM 0x0800 -#define RIOEN 0x1000 -#define XIOEN 0x2000 -#define IDLE_EN 0x4000 +#define CLKRP BIT(0) +#define CLKXP BIT(1) +#define FSRP BIT(2) +#define FSXP BIT(3) +#define DR_STAT BIT(4) +#define DX_STAT BIT(5) +#define CLKS_STAT BIT(6) +#define SCLKME BIT(7) +#define CLKRM BIT(8) +#define CLKXM BIT(9) +#define FSRM BIT(10) +#define FSXM BIT(11) +#define RIOEN BIT(12) +#define XIOEN BIT(13) +#define IDLE_EN BIT(14)
/************************** McBSP RCR1 bit definitions ************************/ -#define RWDLEN1(value) ((value)<<5) /* Bits 5:7 */ -#define RFRLEN1(value) ((value)<<8) /* Bits 8:14 */ +#define RWDLEN1(value) (((value) & 0x7) << 5) /* Bits 5:7 */ +#define RFRLEN1(value) (((value) & 0x7f) << 8) /* Bits 8:14 */
/************************** McBSP XCR1 bit definitions ************************/ -#define XWDLEN1(value) ((value)<<5) /* Bits 5:7 */ -#define XFRLEN1(value) ((value)<<8) /* Bits 8:14 */ +#define XWDLEN1(value) (((value) & 0x7) << 5) /* Bits 5:7 */ +#define XFRLEN1(value) (((value) & 0x7f) << 8) /* Bits 8:14 */
/*************************** McBSP RCR2 bit definitions ***********************/ -#define RDATDLY(value) (value) /* Bits 0:1 */ -#define RFIG 0x0004 -#define RCOMPAND(value) ((value)<<3) /* Bits 3:4 */ -#define RWDLEN2(value) ((value)<<5) /* Bits 5:7 */ -#define RFRLEN2(value) ((value)<<8) /* Bits 8:14 */ -#define RPHASE 0x8000 +#define RDATDLY(value) ((value) & 0x3) /* Bits 0:1 */ +#define RFIG BIT(2) +#define RCOMPAND(value) (((value) & 0x3) << 3) /* Bits 3:4 */ +#define RWDLEN2(value) (((value) & 0x7) << 5) /* Bits 5:7 */ +#define RFRLEN2(value) (((value) & 0x7f) << 8) /* Bits 8:14 */ +#define RPHASE BIT(15)
/*************************** McBSP XCR2 bit definitions ***********************/ -#define XDATDLY(value) (value) /* Bits 0:1 */ -#define XFIG 0x0004 -#define XCOMPAND(value) ((value)<<3) /* Bits 3:4 */ -#define XWDLEN2(value) ((value)<<5) /* Bits 5:7 */ -#define XFRLEN2(value) ((value)<<8) /* Bits 8:14 */ -#define XPHASE 0x8000 +#define XDATDLY(value) ((value) & 0x3) /* Bits 0:1 */ +#define XFIG BIT(2) +#define XCOMPAND(value) (((value) & 0x3) << 3) /* Bits 3:4 */ +#define XWDLEN2(value) (((value) & 0x7) << 5) /* Bits 5:7 */ +#define XFRLEN2(value) (((value) & 0x7f) << 8) /* Bits 8:14 */ +#define XPHASE BIT(15)
/************************* McBSP SRGR1 bit definitions ************************/ -#define CLKGDV(value) (value) /* Bits 0:7 */ -#define FWID(value) ((value)<<8) /* Bits 8:15 */ +#define CLKGDV(value) ((value) & 0x7f) /* Bits 0:7 */ +#define FWID(value) (((value) & 0xff) << 8) /* Bits 8:15 */
/************************* McBSP SRGR2 bit definitions ************************/ -#define FPER(value) (value) /* Bits 0:11 */ -#define FSGM 0x1000 -#define CLKSM 0x2000 -#define CLKSP 0x4000 -#define GSYNC 0x8000 +#define FPER(value) ((value) & 0x0fff) /* Bits 0:11 */ +#define FSGM BIT(12) +#define CLKSM BIT(13) +#define CLKSP BIT(14) +#define GSYNC BIT(15)
/************************* McBSP MCR1 bit definitions *************************/ -#define RMCM 0x0001 -#define RCBLK(value) ((value)<<2) /* Bits 2:4 */ -#define RPABLK(value) ((value)<<5) /* Bits 5:6 */ -#define RPBBLK(value) ((value)<<7) /* Bits 7:8 */ +#define RMCM BIT(0) +#define RCBLK(value) (((value) & 0x7) << 2) /* Bits 2:4 */ +#define RPABLK(value) (((value) & 0x3) << 5) /* Bits 5:6 */ +#define RPBBLK(value) (((value) & 0x3) << 7) /* Bits 7:8 */
/************************* McBSP MCR2 bit definitions *************************/ -#define XMCM(value) (value) /* Bits 0:1 */ -#define XCBLK(value) ((value)<<2) /* Bits 2:4 */ -#define XPABLK(value) ((value)<<5) /* Bits 5:6 */ -#define XPBBLK(value) ((value)<<7) /* Bits 7:8 */ +#define XMCM(value) ((value) & 0x3) /* Bits 0:1 */ +#define XCBLK(value) (((value) & 0x7) << 2) /* Bits 2:4 */ +#define XPABLK(value) (((value) & 0x3) << 5) /* Bits 5:6 */ +#define XPBBLK(value) (((value) & 0x3) << 7) /* Bits 7:8 */
/*********************** McBSP XCCR bit definitions *************************/ -#define EXTCLKGATE 0x8000 -#define PPCONNECT 0x4000 -#define DXENDLY(value) ((value)<<12) /* Bits 12:13 */ -#define XFULL_CYCLE 0x0800 -#define DILB 0x0020 -#define XDMAEN 0x0008 -#define XDISABLE 0x0001 +#define XDISABLE BIT(0) +#define XDMAEN BIT(3) +#define DILB BIT(5) +#define XFULL_CYCLE BIT(11) +#define DXENDLY(value) (((value) & 0x3) << 12) /* Bits 12:13 */ +#define PPCONNECT BIT(14) +#define EXTCLKGATE BIT(15)
/********************** McBSP RCCR bit definitions *************************/ -#define RFULL_CYCLE 0x0800 -#define RDMAEN 0x0008 -#define RDISABLE 0x0001 +#define RDISABLE BIT(0) +#define RDMAEN BIT(3) +#define RFULL_CYCLE BIT(11)
/********************** McBSP SYSCONFIG bit definitions ********************/ -#define CLOCKACTIVITY(value) ((value)<<8) -#define SIDLEMODE(value) ((value)<<3) -#define ENAWAKEUP 0x0004 -#define SOFTRST 0x0002 +#define SOFTRST BIT(1) +#define ENAWAKEUP BIT(2) +#define SIDLEMODE(value) (((value) & 0x3) << 3) +#define CLOCKACTIVITY(value) (((value) & 0x3) << 8)
/********************** McBSP SSELCR bit definitions ***********************/ -#define SIDETONEEN 0x0400 +#define SIDETONEEN BIT(10)
/********************** McBSP Sidetone SYSCONFIG bit definitions ***********/ -#define ST_AUTOIDLE 0x0001 +#define ST_AUTOIDLE BIT(0)
/********************** McBSP Sidetone SGAINCR bit definitions *************/ -#define ST_CH1GAIN(value) ((value<<16)) /* Bits 16:31 */ -#define ST_CH0GAIN(value) (value) /* Bits 0:15 */ +#define ST_CH0GAIN(value) ((value) & 0xffff) /* Bits 0:15 */ +#define ST_CH1GAIN(value) (((value) & 0xffff) << 16) /* Bits 16:31 */
/********************** McBSP Sidetone SFIRCR bit definitions **************/ -#define ST_FIRCOEFF(value) (value) /* Bits 0:15 */ +#define ST_FIRCOEFF(value) ((value) & 0xffff) /* Bits 0:15 */
/********************** McBSP Sidetone SSELCR bit definitions **************/ -#define ST_COEFFWRDONE 0x0004 -#define ST_COEFFWREN 0x0002 -#define ST_SIDETONEEN 0x0001 +#define ST_SIDETONEEN BIT(0) +#define ST_COEFFWREN BIT(1) +#define ST_COEFFWRDONE BIT(2)
/********************** McBSP DMA operating modes **************************/ #define MCBSP_DMA_MODE_ELEMENT 0 @@ -220,15 +220,15 @@ enum { #define MCBSP_DMA_MODE_FRAME 2
/********************** McBSP WAKEUPEN bit definitions *********************/ -#define XEMPTYEOFEN 0x4000 -#define XRDYEN 0x0400 -#define XEOFEN 0x0200 -#define XFSXEN 0x0100 -#define XSYNCERREN 0x0080 -#define RRDYEN 0x0008 -#define REOFEN 0x0004 -#define RFSREN 0x0002 -#define RSYNCERREN 0x0001 +#define RSYNCERREN BIT(0) +#define RFSREN BIT(1) +#define REOFEN BIT(2) +#define RRDYEN BIT(3) +#define XSYNCERREN BIT(7) +#define XFSXEN BIT(8) +#define XEOFEN BIT(9) +#define XRDYEN BIT(10) +#define XEMPTYEOFEN BIT(14)
/* we don't do multichannel for now */ struct omap_mcbsp_reg_cfg {
We no longer need accessor functions for max_tx/rx_threshold, dma_op_mode or for the FIFO size.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com --- sound/soc/omap/mcbsp.c | 36 ------------------------------------ sound/soc/omap/mcbsp.h | 3 --- sound/soc/omap/omap-mcbsp.c | 14 +++++--------- 3 files changed, 5 insertions(+), 48 deletions(-)
diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c index f255b923..bd76588 100644 --- a/sound/soc/omap/mcbsp.c +++ b/sound/soc/omap/mcbsp.c @@ -442,29 +442,6 @@ void omap_mcbsp_set_rx_threshold(struct omap_mcbsp *mcbsp, u16 threshold) }
/* - * omap_mcbsp_get_max_tx_thres just return the current configured - * maximum threshold for transmission - */ -u16 omap_mcbsp_get_max_tx_threshold(struct omap_mcbsp *mcbsp) -{ - return mcbsp->max_tx_thres; -} - -/* - * omap_mcbsp_get_max_rx_thres just return the current configured - * maximum threshold for reception - */ -u16 omap_mcbsp_get_max_rx_threshold(struct omap_mcbsp *mcbsp) -{ - return mcbsp->max_rx_thres; -} - -u16 omap_mcbsp_get_fifo_size(struct omap_mcbsp *mcbsp) -{ - return mcbsp->pdata->buffer_size; -} - -/* * omap_mcbsp_get_tx_delay returns the number of used slots in the McBSP FIFO */ u16 omap_mcbsp_get_tx_delay(struct omap_mcbsp *mcbsp) @@ -504,19 +481,6 @@ u16 omap_mcbsp_get_rx_delay(struct omap_mcbsp *mcbsp) return threshold - buffstat; }
-/* - * omap_mcbsp_get_dma_op_mode just return the current configured - * operating mode for the mcbsp channel - */ -int omap_mcbsp_get_dma_op_mode(struct omap_mcbsp *mcbsp) -{ - int dma_op_mode; - - dma_op_mode = mcbsp->dma_op_mode; - - return dma_op_mode; -} - int omap_mcbsp_request(struct omap_mcbsp *mcbsp) { void *reg_cache; diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h index ec00c27..a991e1d 100644 --- a/sound/soc/omap/mcbsp.h +++ b/sound/soc/omap/mcbsp.h @@ -316,9 +316,6 @@ void omap_mcbsp_config(struct omap_mcbsp *mcbsp, const struct omap_mcbsp_reg_cfg *config); 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); diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 8924002..9c703f1 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -67,13 +67,12 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream) struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; struct omap_pcm_dma_data *dma_data; - int dma_op_mode = omap_mcbsp_get_dma_op_mode(mcbsp); int words;
dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
/* TODO: Currently, MODE_ELEMENT == MODE_FRAME */ - if (dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) + if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) /* * Configure McBSP threshold based on either: * packet_size, when the sDMA is in packet mode, or @@ -106,7 +105,7 @@ static int omap_mcbsp_hwrule_min_buffersize(struct snd_pcm_hw_params *params, int size;
snd_interval_any(&frames); - size = omap_mcbsp_get_fifo_size(mcbsp); + size = mcbsp->pdata->buffer_size;
frames.min = size / channels->min; frames.integer = 1; @@ -255,17 +254,14 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, if (mcbsp->pdata->buffer_size) { dma_data->set_threshold = omap_mcbsp_set_threshold; /* TODO: Currently, MODE_ELEMENT == MODE_FRAME */ - if (omap_mcbsp_get_dma_op_mode(mcbsp) == - MCBSP_DMA_MODE_THRESHOLD) { + if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) { int period_words, max_thrsh;
period_words = params_period_bytes(params) / (wlen / 8); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - max_thrsh = omap_mcbsp_get_max_tx_threshold( - mcbsp); + max_thrsh = mcbsp->max_tx_thres; else - max_thrsh = omap_mcbsp_get_max_rx_threshold( - mcbsp); + max_thrsh = mcbsp->max_rx_thres; /* * If the period contains less or equal number of words, * we are using the original threshold mode setup:
Use devm_* where it is possible to save on cleanup path. Start merging the two mcbsp file content. Move pm_runtime_enable/disable calls to ASoC probe, remove from module probe/remove time.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com --- sound/soc/omap/mcbsp.c | 135 +++++++++++-------------------------------- sound/soc/omap/mcbsp.h | 4 +- sound/soc/omap/omap-mcbsp.c | 51 ++++++++++++++++- 3 files changed, 85 insertions(+), 105 deletions(-)
diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c index bd76588..98f1c9f 100644 --- a/sound/soc/omap/mcbsp.c +++ b/sound/soc/omap/mcbsp.c @@ -921,90 +921,56 @@ static int __devinit omap_st_add(struct omap_mcbsp *mcbsp, struct omap_mcbsp_st_data *st_data; int err;
- st_data = kzalloc(sizeof(*mcbsp->st_data), GFP_KERNEL); - if (!st_data) { - err = -ENOMEM; - goto err1; - } + st_data = devm_kzalloc(mcbsp->dev, sizeof(*mcbsp->st_data), GFP_KERNEL); + if (!st_data) + return -ENOMEM;
- st_data->io_base_st = ioremap(res->start, resource_size(res)); - if (!st_data->io_base_st) { - err = -ENOMEM; - goto err2; - } + st_data->io_base_st = devm_ioremap(mcbsp->dev, res->start, + resource_size(res)); + if (!st_data->io_base_st) + return -ENOMEM;
err = sysfs_create_group(&mcbsp->dev->kobj, &sidetone_attr_group); if (err) - goto err3; + return err;
mcbsp->st_data = st_data; return 0; - -err3: - iounmap(st_data->io_base_st); -err2: - kfree(st_data); -err1: - return err; - -} - -static void __devexit omap_st_remove(struct omap_mcbsp *mcbsp) -{ - struct omap_mcbsp_st_data *st_data = mcbsp->st_data; - - sysfs_remove_group(&mcbsp->dev->kobj, &sidetone_attr_group); - iounmap(st_data->io_base_st); - kfree(st_data); }
/* * McBSP1 and McBSP3 are directly mapped on 1610 and 1510. * 730 has only 2 McBSP, and both of them are MPU peripherals. */ -int __devinit omap_mcbsp_probe(struct platform_device *pdev) +int __devinit omap_mcbsp_init(struct platform_device *pdev) { - struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data; - struct omap_mcbsp *mcbsp; + struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev); struct resource *res; int ret = 0;
- if (!pdata) { - dev_err(&pdev->dev, "McBSP device initialized without" - "platform data\n"); - ret = -EINVAL; - goto exit; - } - - dev_dbg(&pdev->dev, "Initializing OMAP McBSP (%d).\n", pdev->id); - - mcbsp = kzalloc(sizeof(struct omap_mcbsp), GFP_KERNEL); - if (!mcbsp) { - ret = -ENOMEM; - goto exit; - } - spin_lock_init(&mcbsp->lock); - mcbsp->id = pdev->id; mcbsp->free = true;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); if (!res) { res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { - dev_err(&pdev->dev, "%s:mcbsp%d has invalid memory" - "resource\n", __func__, pdev->id); - ret = -ENOMEM; - goto exit; + dev_err(mcbsp->dev, "invalid memory resource\n"); + return -ENOMEM; } } + if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res), + dev_name(&pdev->dev))) { + dev_err(mcbsp->dev, "memory region already claimed\n"); + return -ENODEV; + } + mcbsp->phys_base = res->start; mcbsp->reg_cache_size = resource_size(res); - mcbsp->io_base = ioremap(res->start, resource_size(res)); - if (!mcbsp->io_base) { - ret = -ENOMEM; - goto err_ioremap; - } + mcbsp->io_base = devm_ioremap(&pdev->dev, res->start, + resource_size(res)); + if (!mcbsp->io_base) + return -ENOMEM;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma"); if (!res) @@ -1021,34 +987,25 @@ int __devinit omap_mcbsp_probe(struct platform_device *pdev)
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx"); if (!res) { - dev_err(&pdev->dev, "%s:mcbsp%d has invalid rx DMA channel\n", - __func__, pdev->id); - ret = -ENODEV; - goto err_res; + dev_err(&pdev->dev, "invalid rx DMA channel\n"); + return -ENODEV; } mcbsp->dma_rx_sync = res->start;
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx"); if (!res) { - dev_err(&pdev->dev, "%s:mcbsp%d has invalid tx DMA channel\n", - __func__, pdev->id); - ret = -ENODEV; - goto err_res; + dev_err(&pdev->dev, "invalid tx DMA channel\n"); + return -ENODEV; } mcbsp->dma_tx_sync = res->start;
mcbsp->fclk = clk_get(&pdev->dev, "fck"); if (IS_ERR(mcbsp->fclk)) { ret = PTR_ERR(mcbsp->fclk); - dev_err(&pdev->dev, "unable to get fck: %d\n", ret); - goto err_res; + dev_err(mcbsp->dev, "unable to get fck: %d\n", ret); + return ret; }
- mcbsp->pdata = pdata; - mcbsp->dev = &pdev->dev; - platform_set_drvdata(pdev, mcbsp); - pm_runtime_enable(mcbsp->dev); - mcbsp->dma_op_mode = MCBSP_DMA_MODE_ELEMENT; if (mcbsp->pdata->buffer_size) { /* @@ -1088,41 +1045,17 @@ int __devinit omap_mcbsp_probe(struct platform_device *pdev)
err_st: if (mcbsp->pdata->buffer_size) - sysfs_remove_group(&mcbsp->dev->kobj, - &additional_attr_group); + sysfs_remove_group(&mcbsp->dev->kobj, &additional_attr_group); err_thres: clk_put(mcbsp->fclk); -err_res: - iounmap(mcbsp->io_base); -err_ioremap: - kfree(mcbsp); -exit: return ret; }
-int __devexit omap_mcbsp_remove(struct platform_device *pdev) +void __devexit omap_mcbsp_sysfs_remove(struct omap_mcbsp *mcbsp) { - struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev); - - platform_set_drvdata(pdev, NULL); - if (mcbsp) { - - if (mcbsp->pdata && mcbsp->pdata->ops && - mcbsp->pdata->ops->free) - mcbsp->pdata->ops->free(mcbsp->id); - - if (mcbsp->pdata->buffer_size) - sysfs_remove_group(&mcbsp->dev->kobj, - &additional_attr_group); - - if (mcbsp->st_data) - omap_st_remove(mcbsp); - - clk_put(mcbsp->fclk); - - iounmap(mcbsp->io_base); - kfree(mcbsp); - } + if (mcbsp->pdata->buffer_size) + sysfs_remove_group(&mcbsp->dev->kobj, &additional_attr_group);
- return 0; + if (mcbsp->st_data) + sysfs_remove_group(&mcbsp->dev->kobj, &sidetone_attr_group); } diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h index a991e1d..ac90c1a 100644 --- a/sound/soc/omap/mcbsp.h +++ b/sound/soc/omap/mcbsp.h @@ -341,7 +341,7 @@ 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); +int __devinit omap_mcbsp_init(struct platform_device *pdev); +void __devexit omap_mcbsp_sysfs_remove(struct omap_mcbsp *mcbsp);
#endif /* __ASOC_MCBSP_H */ diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 9c703f1..69a44aa 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -25,6 +25,7 @@ #include <linux/init.h> #include <linux/module.h> #include <linux/device.h> +#include <linux/pm_runtime.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> @@ -603,7 +604,27 @@ static const struct snd_soc_dai_ops mcbsp_dai_ops = { .set_sysclk = omap_mcbsp_dai_set_dai_sysclk, };
+static int omap_mcbsp_probe(struct snd_soc_dai *dai) +{ + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(dai); + + pm_runtime_enable(mcbsp->dev); + + return 0; +} + +static int omap_mcbsp_remove(struct snd_soc_dai *dai) +{ + struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(dai); + + pm_runtime_disable(mcbsp->dev); + + return 0; +} + static struct snd_soc_dai_driver omap_mcbsp_dai = { + .probe = omap_mcbsp_probe, + .remove = omap_mcbsp_remove, .playback = { .channels_min = 1, .channels_max = 16, @@ -756,9 +777,24 @@ EXPORT_SYMBOL_GPL(omap_mcbsp_st_add_controls);
static __devinit int asoc_mcbsp_probe(struct platform_device *pdev) { + struct omap_mcbsp_platform_data *pdata = dev_get_platdata(&pdev->dev); + struct omap_mcbsp *mcbsp; int ret;
- ret = omap_mcbsp_probe(pdev); + if (!pdata) { + dev_err(&pdev->dev, "missing platform data.\n"); + return -EINVAL; + } + mcbsp = devm_kzalloc(&pdev->dev, sizeof(struct omap_mcbsp), GFP_KERNEL); + if (!mcbsp) + return -ENOMEM; + + mcbsp->id = pdev->id; + mcbsp->pdata = pdata; + mcbsp->dev = &pdev->dev; + platform_set_drvdata(pdev, mcbsp); + + ret = omap_mcbsp_init(pdev); if (!ret) return snd_soc_register_dai(&pdev->dev, &omap_mcbsp_dai);
@@ -767,8 +803,19 @@ static __devinit int asoc_mcbsp_probe(struct platform_device *pdev)
static int __devexit asoc_mcbsp_remove(struct platform_device *pdev) { - omap_mcbsp_remove(pdev); + struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev); + snd_soc_unregister_dai(&pdev->dev); + + if (mcbsp->pdata->ops && mcbsp->pdata->ops->free) + mcbsp->pdata->ops->free(mcbsp->id); + + omap_mcbsp_sysfs_remove(mcbsp); + + clk_put(mcbsp->fclk); + + platform_set_drvdata(pdev, NULL); + return 0; }
Since the drivers has been merged, merge the two structures together.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com --- sound/soc/omap/mcbsp.h | 33 ++++++++++++-------------- sound/soc/omap/omap-mcbsp.c | 53 ++++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 48 deletions(-)
diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h index ac90c1a..d250bcc 100644 --- a/sound/soc/omap/mcbsp.h +++ b/sound/soc/omap/mcbsp.h @@ -269,27 +269,20 @@ struct omap_mcbsp_st_data { 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; + struct clk *fclk; + spinlock_t lock; unsigned long phys_base; unsigned long phys_dma_base; void __iomem *io_base; u8 id; + /* + * Flags indicating is the bus already activated and configured by + * another substream + */ + int active; + int configured; u8 free;
int rx_irq; @@ -300,16 +293,20 @@ struct omap_mcbsp { 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; + struct omap_mcbsp_reg_cfg cfg_regs; + struct omap_pcm_dma_data dma_data[2]; int dma_op_mode; u16 max_tx_thres; u16 max_rx_thres; void *reg_cache; int reg_cache_size; + + unsigned int fmt; + unsigned int in_freq; + int clk_div; + int wlen; };
void omap_mcbsp_config(struct omap_mcbsp *mcbsp, diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 69a44aa..4cd7af8 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -66,7 +66,6 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); - struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; struct omap_pcm_dma_data *dma_data; int words;
@@ -83,7 +82,7 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream) words = dma_data->packet_size; else words = snd_pcm_lib_period_bytes(substream) / - (mcbsp_data->wlen / 8); + (mcbsp->wlen / 8); else words = 1;
@@ -160,11 +159,10 @@ static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); - struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data;
if (!cpu_dai->active) { omap_mcbsp_free(mcbsp); - mcbsp_data->configured = 0; + mcbsp->configured = 0; } }
@@ -172,14 +170,13 @@ static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *cpu_dai) { struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); - struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; int err = 0, play = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - mcbsp_data->active++; + mcbsp->active++; omap_mcbsp_start(mcbsp, play, !play); break;
@@ -187,7 +184,7 @@ static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: omap_mcbsp_stop(mcbsp, play, !play); - mcbsp_data->active--; + mcbsp->active--; break; default: err = -EINVAL; @@ -226,8 +223,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); - struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; - struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; + struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs; struct omap_pcm_dma_data *dma_data; int dma; int wlen, channels, wpf, sync_mode = OMAP_DMA_SYNC_ELEMENT; @@ -235,7 +231,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, unsigned long port; unsigned int format, div, framesize, master;
- dma_data = &mcbsp_data->dma_data[substream->stream]; + dma_data = &mcbsp->dma_data[substream->stream];
dma = omap_mcbsp_dma_ch_params(mcbsp, substream->stream); port = omap_mcbsp_dma_reg_params(mcbsp, substream->stream); @@ -303,7 +299,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data);
- if (mcbsp_data->configured) { + if (mcbsp->configured) { /* McBSP already configured by another stream */ return 0; } @@ -312,7 +308,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, regs->xcr2 &= ~(RPHASE | XFRLEN2(0x7f) | XWDLEN2(7)); regs->rcr1 &= ~(RFRLEN1(0x7f) | RWDLEN1(7)); regs->xcr1 &= ~(XFRLEN1(0x7f) | XWDLEN1(7)); - format = mcbsp_data->fmt & SND_SOC_DAIFMT_FORMAT_MASK; + format = mcbsp->fmt & SND_SOC_DAIFMT_FORMAT_MASK; wpf = channels = params_channels(params); if (channels == 2 && (format == SND_SOC_DAIFMT_I2S || format == SND_SOC_DAIFMT_LEFT_J)) { @@ -350,10 +346,10 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
/* In McBSP master modes, FRAME (i.e. sample rate) is generated * by _counting_ BCLKs. Calculate frame size in BCLKs */ - master = mcbsp_data->fmt & SND_SOC_DAIFMT_MASTER_MASK; + master = mcbsp->fmt & SND_SOC_DAIFMT_MASTER_MASK; if (master == SND_SOC_DAIFMT_CBS_CFS) { - div = mcbsp_data->clk_div ? mcbsp_data->clk_div : 1; - framesize = (mcbsp_data->in_freq / div) / params_rate(params); + div = mcbsp->clk_div ? mcbsp->clk_div : 1; + framesize = (mcbsp->in_freq / div) / params_rate(params);
if (framesize < wlen * channels) { printk(KERN_ERR "%s: not enough bandwidth for desired rate and " @@ -379,9 +375,9 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, break; }
- omap_mcbsp_config(mcbsp, &mcbsp_data->regs); - mcbsp_data->wlen = wlen; - mcbsp_data->configured = 1; + omap_mcbsp_config(mcbsp, &mcbsp->cfg_regs); + mcbsp->wlen = wlen; + mcbsp->configured = 1;
return 0; } @@ -394,14 +390,13 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) { struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); - struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; - struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; + struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs; bool inv_fs = false;
- if (mcbsp_data->configured) + if (mcbsp->configured) return 0;
- mcbsp_data->fmt = fmt; + mcbsp->fmt = fmt; memset(regs, 0, sizeof(*regs)); /* Generic McBSP register settings */ regs->spcr2 |= XINTM(3) | FREE; @@ -497,13 +492,12 @@ static int omap_mcbsp_dai_set_clkdiv(struct snd_soc_dai *cpu_dai, int div_id, int div) { struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); - struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; - struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; + struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs;
if (div_id != OMAP_MCBSP_CLKGDV) return -ENODEV;
- mcbsp_data->clk_div = div; + mcbsp->clk_div = div; regs->srgr1 &= ~CLKGDV(0xff); regs->srgr1 |= CLKGDV(div - 1);
@@ -515,12 +509,11 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, int dir) { struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); - struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; - struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; + struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs; int err = 0;
- if (mcbsp_data->active) { - if (freq == mcbsp_data->in_freq) + if (mcbsp->active) { + if (freq == mcbsp->in_freq) return 0; else return -EBUSY; @@ -534,7 +527,7 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, if (cpu_class_is_omap1() || cpu_dai->id != 1) return -EINVAL;
- mcbsp_data->in_freq = freq; + mcbsp->in_freq = freq; regs->srgr2 &= ~CLKSM; regs->pcr0 &= ~SCLKME;
Configure the DMA request line, port address, and stream name at probe time instead of every time we start a stream. These settings are static in the system.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com --- sound/soc/omap/mcbsp.c | 29 ++++++++++------------------- sound/soc/omap/mcbsp.h | 7 ------- sound/soc/omap/omap-mcbsp.c | 8 -------- 3 files changed, 10 insertions(+), 34 deletions(-)
diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c index 98f1c9f..a941a3c 100644 --- a/sound/soc/omap/mcbsp.c +++ b/sound/soc/omap/mcbsp.c @@ -177,22 +177,6 @@ void omap_mcbsp_config(struct omap_mcbsp *mcbsp, }
/** - * omap_mcbsp_dma_params - returns the dma channel number - * @id - mcbsp id - * @stream - indicates the direction of data flow (rx or tx) - * - * Returns the dma channel number for the rx channel or tx channel - * based on the value of @stream for the requested mcbsp given by @id - */ -int omap_mcbsp_dma_ch_params(struct omap_mcbsp *mcbsp, unsigned int stream) -{ - if (stream) - return mcbsp->dma_rx_sync; - else - return mcbsp->dma_tx_sync; -} - -/** * omap_mcbsp_dma_reg_params - returns the address of mcbsp data register * @id - mcbsp id * @stream - indicates the direction of data flow (rx or tx) @@ -201,7 +185,8 @@ int omap_mcbsp_dma_ch_params(struct omap_mcbsp *mcbsp, unsigned int stream) * to be used by DMA for transferring/receiving data based on the value of * @stream for the requested mcbsp given by @id */ -int omap_mcbsp_dma_reg_params(struct omap_mcbsp *mcbsp, unsigned int stream) +static int omap_mcbsp_dma_reg_params(struct omap_mcbsp *mcbsp, + unsigned int stream) { int data_reg;
@@ -990,14 +975,20 @@ int __devinit omap_mcbsp_init(struct platform_device *pdev) dev_err(&pdev->dev, "invalid rx DMA channel\n"); return -ENODEV; } - mcbsp->dma_rx_sync = res->start; + /* RX DMA request number, and port address configuration */ + mcbsp->dma_data[1].name = "Audio Capture"; + mcbsp->dma_data[1].dma_req = res->start; + mcbsp->dma_data[1].port_addr = omap_mcbsp_dma_reg_params(mcbsp, 1);
res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx"); if (!res) { dev_err(&pdev->dev, "invalid tx DMA channel\n"); return -ENODEV; } - mcbsp->dma_tx_sync = res->start; + /* TX DMA request number, and port address configuration */ + mcbsp->dma_data[0].name = "Audio Playback"; + mcbsp->dma_data[0].dma_req = res->start; + mcbsp->dma_data[0].port_addr = omap_mcbsp_dma_reg_params(mcbsp, 0);
mcbsp->fclk = clk_get(&pdev->dev, "fck"); if (IS_ERR(mcbsp->fclk)) { diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h index d250bcc..a5518d7 100644 --- a/sound/soc/omap/mcbsp.h +++ b/sound/soc/omap/mcbsp.h @@ -288,10 +288,6 @@ struct omap_mcbsp { 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 */ struct omap_mcbsp_platform_data *pdata; struct omap_mcbsp_st_data *st_data; @@ -328,9 +324,6 @@ int omap2_mcbsp_set_clks_src(struct omap_mcbsp *mcbsp, u8 fck_src_id); 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(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(struct omap_mcbsp *mcbsp, int channel, s16 chgain); int omap_st_get_chgain(struct omap_mcbsp *mcbsp, int channel, s16 *chgain); diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 4cd7af8..10eb645 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -225,17 +225,12 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs; struct omap_pcm_dma_data *dma_data; - int dma; int wlen, channels, wpf, sync_mode = OMAP_DMA_SYNC_ELEMENT; int pkt_size = 0; - unsigned long port; unsigned int format, div, framesize, master;
dma_data = &mcbsp->dma_data[substream->stream];
- dma = omap_mcbsp_dma_ch_params(mcbsp, substream->stream); - port = omap_mcbsp_dma_reg_params(mcbsp, substream->stream); - switch (params_format(params)) { case SNDRV_PCM_FORMAT_S16_LE: dma_data->data_type = OMAP_DMA_DATA_TYPE_S16; @@ -291,9 +286,6 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, } }
- dma_data->name = substream->stream ? "Audio Capture" : "Audio Playback"; - dma_data->dma_req = dma; - dma_data->port_addr = port; dma_data->sync_mode = sync_mode; dma_data->packet_size = pkt_size;
Hi,
CC-ing Janusz, since he is the only one I know who have, and use OMAP1 with audio... Janusz: if your time allows would you be able to test this series on OMAP1 (it compiles...)?
Thanks, Péter
On Wed, Feb 15, 2012 at 5:37 PM, Peter Ujfalusi peter.ujfalusi@ti.com wrote:
Hello,
The aim of this series is to move the plat-omap/mcbsp.c driver out to sound/soc/omap/ By doing this we can combine the two levels of McBSP driver stack into a single one. Formally we had omap-mcbsp.[1-X] drivers (plat-omap/mcbsp.c), and omap-mcbsp-dai.[0-(X-1) drivers (sound/soc/omap/omap-mcbsp.c). We had global, shared structures, variables, pointers. The API between the two driver was a set of exported function calls where one of the parameter was the McBSP port id.
With this series we will have one driver for McBSP (omap-mcbsp.[1-X]) which is basically the ASoC dai driver. All exported/shared global structures are gone since we can use driver data for all ports in this way.
With the code in one place we can do further clean up in the McBSP driver, and adding new features will be much easier in the future. Also the DT support for McBSP will be significantly easier if we have one set of driver.
McBSP is only used by audio, there are no known other users of the OMAP McBSP (well, Nokia n700 has the WLAN connected through McBSP but we do not have driver for that anyway).
The series was created against Takashi's topic/asoc branch. I have tested it on Beagle xM, and compile tested it for OMAP1, OMAP2, and OMAP4 as well.
I'm going to do more work on the cleanup, and the plan is to merge the two files into one (mcbsp.c -> omap-mcbsp.c) eventually.
Comments, testers are welcome...
CC-ing Samuel as well since he is the original author of the plat-omap/mcbsp.c driver.
Regards, Peter
Peter Ujfalusi (11): ARM: OMAP: mcbsp: Convert core driver to proper platform driver OMAP: mcbsp: Move core driver under sound/soc/omap ASoC: OMAP: McBSP: Consolidate plat/mcbsp.h content ASoC: core - Add API call to register dai kcontrols. ASoC: omap-mcbsp: Create a single driver for McBSP ARM: OMAP: Do not register omap-mcbsp-dai device ASoC: OMAP: mcbsp.h: Clean up bit definitions ASoC: OMAP McBSP: Remove redundant accessors ASoC: omap-mcbsp: Cleanup of module probe/remove code ASoC: omap-mcbsp: Merge the omap_mcbsp_data into omap_mcbsp structure ASoC: omap-mcbsp: Simplify DMA configuration
arch/arm/mach-omap1/devices.c | 9 - arch/arm/mach-omap1/mcbsp.c | 14 +- arch/arm/mach-omap2/devices.c | 22 -- arch/arm/mach-omap2/mcbsp.c | 8 +- arch/arm/plat-omap/Kconfig | 8 - arch/arm/plat-omap/Makefile | 2 - arch/arm/plat-omap/include/plat/mcbsp.h | 321 ---------------- include/sound/soc.h | 2 + sound/soc/omap/Kconfig | 4 + sound/soc/omap/Makefile | 1 + sound/soc/omap/am3517evm.c | 2 +- sound/soc/omap/ams-delta.c | 2 +- sound/soc/omap/igep0020.c | 2 +- {arch/arm/plat-omap => sound/soc/omap}/mcbsp.c | 463 ++++-------------------- sound/soc/omap/mcbsp.h | 337 +++++++++++++++++ sound/soc/omap/n810.c | 2 +- sound/soc/omap/omap-mcbsp.c | 287 ++++++++------- sound/soc/omap/omap-mcbsp.h | 2 +- sound/soc/omap/omap-pcm.h | 2 + sound/soc/omap/omap3beagle.c | 2 +- sound/soc/omap/omap3evm.c | 2 +- sound/soc/omap/omap3pandora.c | 4 +- sound/soc/omap/osk5912.c | 2 +- sound/soc/omap/overo.c | 2 +- sound/soc/omap/rx51.c | 4 +- sound/soc/omap/sdp3430.c | 4 +- sound/soc/omap/zoom2.c | 4 +- sound/soc/soc-core.c | 31 ++ 28 files changed, 631 insertions(+), 914 deletions(-) rename {arch/arm/plat-omap => sound/soc/omap}/mcbsp.c (69%) create mode 100644 sound/soc/omap/mcbsp.h
-- 1.7.8.4
On 02/15/2012 05:56 PM, Ujfalusi, Peter wrote:
Hi,
CC-ing Janusz, since he is the only one I know who have, and use OMAP1 with audio... Janusz: if your time allows would you be able to test this series on OMAP1 (it compiles...)?
Yeah, it would be shame to break omap1, especially considering how much Janusz has put his personal effort on it.
McBSP is only used by audio, there are no known other users of the OMAP McBSP (well, Nokia n700 has the WLAN connected through McBSP but we do not have driver for that anyway).
And since the clock stop mode is not supported in newer omaps there very unlikely won't be.
The series was created against Takashi's topic/asoc branch. I have tested it on Beagle xM, and compile tested it for OMAP1, OMAP2, and OMAP4 as well.
I'm going to do more work on the cleanup, and the plan is to merge the two files into one (mcbsp.c -> omap-mcbsp.c) eventually.
Comments, testers are welcome...
Unfortunately I won't be able to give any test this week but at quick look the set looks good to me.
On Wednesday 15 of February 2012 17:56:15 Ujfalusi, Peter wrote:
Hi,
CC-ing Janusz, since he is the only one I know who have, and use OMAP1 with audio... Janusz: if your time allows would you be able to test this series on OMAP1 (it compiles...)?
for OMAP1:
Tested-by: Janusz Krzysztofik jkrzyszt@tis.icnet.pl
Thanks, Janusz
participants (7)
-
Janusz Krzysztofik
-
Jarkko Nikula
-
Liam Girdwood
-
Mark Brown
-
Peter Ujfalusi
-
Tony Lindgren
-
Ujfalusi, Peter