twl4030 codec as MFD device
Subsystems (6)
cover twl4030 codec as MFD device
Hello,
The following series adds new MFD device on top of the twl4030 MFD device for the codec part of the chip, and also converts the soc audio driver to use the correct probing (device model).
Reason for the twl4030_codec MFD: the vibra control is actually in the codec part of the twl4030. If both the vibra and the audio functionality is needed from the twl4030 at the same time, than they need to control the codec power and APLL at the same time without breaking the other driver. Also these two has to be able to work without the need for the other driver.
The proposed solution:
Register twl4030_codec as a child for the twl4030 mfd. twl4030_codec is also and mfd and at the moment it has two child:twl4030_codec_audio: for audio codectwl4030_codec_vibra: for vibra driver
The twl4030_codec mfd registers the devices for audio and vibra (if the platform data is not NULL for them), and has - at the moment - functions to enable/disable resources, each of these resources has ref-counts, so the twl4030_codec knows, when the resource is need to be turned on or off.
The interface is quite simple:
int twl4030_codec_enable_resource(enum twl4030_codec_res id); int twl4030_codec_disable_resource(enum twl4030_codec_res id);
These functions are returning the content of the given register after the modification (or negative value, if error - the error handling need to be revisited in a near future), so that the caller can update it's local cache if it need to do (the audio driver needs it).
There are two resource defined:TWL4030_CODEC_RES_POWER: Controlling the power of the codecTWL4030_CODEC_RES_APLL: For APLL
The vibra driver is not part of this series.
I have also included a patch, which changes the board files for those, which in my knowledge uses the twl4030 codec as audio device. I might missed some boards...
To-Do list:
- revisit the error handling in twl4030-codec driver
- add the actual vibra driver ;)
- coexistence related fixes for the audio and vibra driver
- move all audio related configuration from soc machine drivers to the board files (if any)
---
Peter Ujfalusi (4):
MFD: twl4030: add twl4030_codec MFD as a new child to the core
OMAP: Platform support for twl4030_codec MFD
ASoC: TWL4030: Only update the needed bits in *set_dai_sysclk
ASoC: TWL4030: Driver registration via twl4030_codec MFD
arch/arm/mach-omap2/board-3430sdp.c | 9 + arch/arm/mach-omap2/board-omap3beagle.c | 9 + arch/arm/mach-omap2/board-omap3evm.c | 9 + arch/arm/mach-omap2/board-omap3pandora.c | 9 + arch/arm/mach-omap2/board-overo.c | 9 + arch/arm/mach-omap2/board-zoom2.c | 9 + drivers/mfd/Kconfig | 13 ++ drivers/mfd/Makefile | 1 + drivers/mfd/twl4030-codec.c | 245 ++++++++++++++++++++++++++++ drivers/mfd/twl4030-core.c | 14 ++ include/linux/i2c/twl4030.h | 18 ++ include/linux/mfd/twl4030-codec.h | 261 ++++++++++++++++++++++++++++++ sound/soc/codecs/Kconfig | 2 +- sound/soc/codecs/twl4030.c | 225 ++++++++++++++++---------- sound/soc/codecs/twl4030.h | 242 +--------------------------- 15 files changed, 751 insertions(+), 324 deletions(-) create mode 100644 drivers/mfd/twl4030-codec.c create mode 100644 include/linux/mfd/twl4030-codec.h
PATCH 1/4 MFD: twl4030: add twl4030_codec MFD as a new child to the core
New MFD child to twl4030 MFD device.
This MFD device will be used by the drivers, which needs resources from the twl4030 codec like audio and vibra.
The platform specific configuration data is passed along to the child drivers (audio, vibra).
--- drivers/mfd/Kconfig | 13 ++ drivers/mfd/Makefile | 1 + drivers/mfd/twl4030-codec.c | 245 ++++++++++++++++++++++++++++++++++ drivers/mfd/twl4030-core.c | 14 ++ include/linux/i2c/twl4030.h | 18 +++ include/linux/mfd/twl4030-codec.h | 261 +++++++++++++++++++++++++++++++++++++ 6 files changed, 552 insertions(+), 0 deletions(-) create mode 100644 drivers/mfd/twl4030-codec.c create mode 100644 include/linux/mfd/twl4030-codec.h
drivers/mfd/Kconfig +13 -0
@@ -121,6 +121,19 @@ config TWL4030_POWER and load scripts controling which resources are switched off/on or reset when a sleep, wakeup or warm reset event occurs. +config TWL4030_CODEC + bool "Support codec part of the TWL4030 family chips" + depends on TWL4030_CORE + help + Say yes here if you want to use the codec resources on the + TWL4030 family chips. The codec in TWL4030 provides the audio + functionality and also has the vibrator controls. + + This driver provides MFD device to be used for drivers, which needs + access to the codec part, the board-specific data is passed from this + driver to the childs as platform data with the board specific + configuration. + config MFD_TMIO bool default n
drivers/mfd/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_MENELAUS) += menelaus.o obj-$(CONFIG_TWL4030_CORE) += twl4030-core.o twl4030-irq.o obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o +obj-$(CONFIG_TWL4030_CODEC) += twl4030-codec.o obj-$(CONFIG_MFD_MC13783) += mc13783-core.o
drivers/mfd/twl4030-codec.c new file +245 -0
245 lines not on this page · raw message
drivers/mfd/twl4030-core.c +14 -0
@@ -114,6 +114,12 @@#define twl_has_watchdog () false#endif +#if defined(CONFIG_TWL4030_CODEC ) || defined(CONFIG_TWL4030_CODEC_MODULE ) +#define twl_has_codec () true +#else +#define twl_has_codec () false +#endif +/* Triton Core internal information (BEGIN) */ /* Last - for index max*/
@@ -557,6 +563,14 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)return PTR_ERR (child); } +if (twl_has_codec () && pdata->codec) { + child =add_child (1 ,"twl4030_codec" , + pdata->codec,sizeof (*pdata->codec), + false,0 ,0 ); +if (IS_ERR (child)) +return PTR_ERR (child); + } +if (twl_has_regulator ()) {/* child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1);
include/linux/i2c/twl4030.h +18 -0
@@ -401,6 +401,23 @@ struct twl4030_power_data {extern void twl4030_power_init (struct twl4030_power_data *triton2_scripts); +struct twl4030_codec_audio_data { +unsigned int audio_mclk; +unsigned int ramp_delay_value; +unsigned int hs_extmute:1 ; +void (*set_hs_extmute)(int mute); +}; + +struct twl4030_codec_vibra_data { +unsigned int audio_mclk; +unsigned int coexist; +}; + +struct twl4030_codec_data { +struct twl4030_codec_audio_data *audio; +struct twl4030_codec_vibra_data *vibra; +}; +struct twl4030_platform_data {unsigned irq_base, irq_end;struct twl4030_bci_platform_data *bci;
@@ -409,6 +426,7 @@ struct twl4030_platform_data {struct twl4030_keypad_data *keypad;struct twl4030_usb_data *usb;struct twl4030_power_data *power; +struct twl4030_codec_data *codec;/* LDO regulators */ struct regulator_init_data *vdac;
include/linux/mfd/twl4030-codec.h new file +261 -0
261 lines not on this page · raw message
Signature · 1 line
1.6.5.1
PATCH 2/4 OMAP: Platform support for twl4030_codec MFD
Add needed platform data for the twl4030_codec MFD on boards, where the audio part of the twl4030 codec is used.
--- arch/arm/mach-omap2/board-3430sdp.c | 9 +++++++++ arch/arm/mach-omap2/board-omap3beagle.c | 9 +++++++++ arch/arm/mach-omap2/board-omap3evm.c | 9 +++++++++ arch/arm/mach-omap2/board-omap3pandora.c | 9 +++++++++ arch/arm/mach-omap2/board-overo.c | 9 +++++++++ arch/arm/mach-omap2/board-zoom2.c | 9 +++++++++ 6 files changed, 54 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/board-3430sdp.c +9 -0
@@ -410,6 +410,14 @@ static struct regulator_init_data sdp3430_vpll2 = { .consumer_supplies = &sdp3430_vdvi_supply, }; +static struct twl4030_codec_audio_data sdp3430_audio = { + .audio_mclk =26000000 , +}; + +static struct twl4030_codec_data sdp3430_codec = { + .audio = &sdp3430_audio, +}; +static struct twl4030_platform_data sdp3430_twldata = { .irq_base =TWL4030_IRQ_BASE , .irq_end =TWL4030_IRQ_END ,
@@ -420,6 +428,7 @@ static struct twl4030_platform_data sdp3430_twldata = { .madc = &sdp3430_madc_data, .keypad = &sdp3430_kp_data, .usb = &sdp3430_usb_data, + .codec = &sdp3430_codec, .vaux1 = &sdp3430_vaux1, .vaux2 = &sdp3430_vaux2,
arch/arm/mach-omap2/board-omap3beagle.c +9 -0
@@ -254,6 +254,14 @@ static struct twl4030_usb_data beagle_usb_data = { .usb_mode = T2_USB_MODE_ULPI, }; +static struct twl4030_codec_audio_data beagle_audio_data = { + .audio_mclk =26000000 , +}; + +static struct twl4030_codec_data beagle_codec_data = { + .audio = &beagle_audio_data, +}; +static struct twl4030_platform_data beagle_twldata = { .irq_base =TWL4030_IRQ_BASE , .irq_end =TWL4030_IRQ_END ,
@@ -261,6 +269,7 @@ static struct twl4030_platform_data beagle_twldata = {/* platform_data for children goes here */ .usb = &beagle_usb_data, .gpio = &beagle_gpio_data, + .codec = &beagle_codec_data, .vmmc1 = &beagle_vmmc1, .vsim = &beagle_vsim, .vdac = &beagle_vdac,
arch/arm/mach-omap2/board-omap3evm.c +9 -0
@@ -194,6 +194,14 @@ static struct twl4030_madc_platform_data omap3evm_madc_data = { .irq_line = 1, }; +static struct twl4030_codec_audio_data omap3evm_audio_data = { + .audio_mclk =26000000 , +}; + +static struct twl4030_codec_data omap3evm_codec_data = { + .audio = &omap3evm_audio_data, +}; +static struct twl4030_platform_data omap3evm_twldata = { .irq_base =TWL4030_IRQ_BASE , .irq_end =TWL4030_IRQ_END ,
@@ -203,6 +211,7 @@ static struct twl4030_platform_data omap3evm_twldata = { .madc = &omap3evm_madc_data, .usb = &omap3evm_usb_data, .gpio = &omap3evm_gpio_data, + .codec = &omap3evm_codec_data, };static struct i2c_board_info __initdata omap3evm_i2c_boardinfo[] = {
arch/arm/mach-omap2/board-omap3pandora.c +9 -0
@@ -281,11 +281,20 @@ static struct twl4030_usb_data omap3pandora_usb_data = { .usb_mode = T2_USB_MODE_ULPI, }; +static struct twl4030_codec_audio_data omap3pandora_audio_data = { + .audio_mclk =26000000 , +}; + +static struct twl4030_codec_data omap3pandora_codec_data = { + .audio = &omap3pandora_audio_data, +}; +static struct twl4030_platform_data omap3pandora_twldata = { .irq_base =TWL4030_IRQ_BASE , .irq_end =TWL4030_IRQ_END , .gpio = &omap3pandora_gpio_data, .usb = &omap3pandora_usb_data, + .codec = &omap3pandora_codec_data, .vmmc1 = &pandora_vmmc1, .vmmc2 = &pandora_vmmc2, .keypad = &pandora_kp_data,
arch/arm/mach-omap2/board-overo.c +9 -0
@@ -329,6 +329,14 @@ static struct regulator_init_data overo_vmmc1 = { .consumer_supplies = &overo_vmmc1_supply, }; +static struct twl4030_codec_audio_data overo_audio_data = { + .audio_mclk =26000000 , +}; + +static struct twl4030_codec_data overo_codec_data = { + .audio = &overo_audio_data, +}; +/* mmc2 (WLAN) and Bluetooth don't use twl4030 regulators */ static struct twl4030_platform_data overo_twldata = {
@@ -336,6 +344,7 @@ static struct twl4030_platform_data overo_twldata = { .irq_end = TWL4030_IRQ_END, .gpio = &overo_gpio_data, .usb = &overo_usb_data, + .codec = &overo_codec_data, .vmmc1 = &overo_vmmc1, };
arch/arm/mach-omap2/board-zoom2.c +9 -0
@@ -229,6 +229,14 @@ static struct twl4030_madc_platform_data zoom2_madc_data = { .irq_line = 1, }; +static struct twl4030_codec_audio_data zoom2_audio_data = { + .audio_mclk =26000000 , +}; + +static struct twl4030_codec_data zoom2_codec_data = { + .audio = &zoom2_audio_data, +}; +static struct twl4030_platform_data zoom2_twldata = { .irq_base =TWL4030_IRQ_BASE , .irq_end =TWL4030_IRQ_END ,
@@ -239,6 +247,7 @@ static struct twl4030_platform_data zoom2_twldata = { .usb = &zoom2_usb_data, .gpio = &zoom2_gpio_data, .keypad = &zoom2_kp_twl4030_data, + .codec = &zoom2_codec_data, .vmmc1 = &zoom2_vmmc1, .vmmc2 = &zoom2_vmmc2, .vsim = &zoom2_vsim,
Signature · 1 line
1.6.5.1
PATCH 3/4 ASoC: TWL4030: Only update the needed bits in *set_dai_sysclk
Do not rewrite the whole register, but only update the needed bits in set_dai_sysclk functions.
--- sound/soc/codecs/twl4030.c | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-)
sound/soc/codecs/twl4030.c +12 -10
@@ -1785,19 +1785,21 @@ static int twl4030_set_dai_sysclk(struct snd_soc_dai *codec_dai, {struct snd_soc_codec *codec = codec_dai->codec;struct twl4030_priv *twl4030 = codec->private_data; -u8 infreq; +u8 apll_ctrl; + apll_ctrl =twl4030_read_reg_cache (codec,TWL4030_REG_APLL_CTL ); + apll_ctrl &= ~TWL4030_APLL_INFREQ ;switch (freq) {case 19200000 : - infreq =TWL4030_APLL_INFREQ_19200KHZ ; + apll_ctrl |=TWL4030_APLL_INFREQ_19200KHZ ; twl4030->sysclk =19200 ;break ;case 26000000 : - infreq =TWL4030_APLL_INFREQ_26000KHZ ; + apll_ctrl |=TWL4030_APLL_INFREQ_26000KHZ ; twl4030->sysclk =26000 ;break ;case 38400000 : - infreq =TWL4030_APLL_INFREQ_38400KHZ ; + apll_ctrl |=TWL4030_APLL_INFREQ_38400KHZ ; twl4030->sysclk =38400 ;break ;default :
@@ -1806,8 +1808,7 @@ static int twl4030_set_dai_sysclk(struct snd_soc_dai *codec_dai,return -EINVAL ; } - infreq |=TWL4030_APLL_EN ; -twl4030_write (codec,TWL4030_REG_APLL_CTL , infreq); +twl4030_write (codec,TWL4030_REG_APLL_CTL , apll_ctrl);return 0 ; }
@@ -1989,11 +1990,13 @@ static int twl4030_voice_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { struct snd_soc_codec *codec = codec_dai->codec; -u8 infreq; +u8 apll_ctrl; + apll_ctrl =twl4030_read_reg_cache (codec,TWL4030_REG_APLL_CTL ); + apll_ctrl &= ~TWL4030_APLL_INFREQ ;switch (freq) {case 26000000 : - infreq =TWL4030_APLL_INFREQ_26000KHZ ; + apll_ctrl |=TWL4030_APLL_INFREQ_26000KHZ ;break ;default : printk(KERN_ERR "TWL4030 voice set sysclk: unknown rate %d\n",
@@ -2001,8 +2004,7 @@ static int twl4030_voice_set_dai_sysclk(struct snd_soc_dai *codec_dai,return -EINVAL ; } - infreq |=TWL4030_APLL_EN ; -twl4030_write (codec,TWL4030_REG_APLL_CTL , infreq); +twl4030_write (codec,TWL4030_REG_APLL_CTL , apll_ctrl);return 0 ; }
Signature · 1 line
1.6.5.1
PATCH 4/4 ASoC: TWL4030: Driver registration via twl4030_codec MFD
TWL4030 codec is now using the device registration via tlw4030_codec MFD device.
--- sound/soc/codecs/Kconfig | 2 +- sound/soc/codecs/twl4030.c | 203 +++++++++++++++++++++++-------------- sound/soc/codecs/twl4030.h | 242 +------------------------------------------ 3 files changed, 133 insertions(+), 314 deletions(-)
sound/soc/codecs/Kconfig +1 -1
@@ -31,7 +31,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_TLV320AIC3X if I2C select SND_SOC_TPA6130A2 if I2C select SND_SOC_TLV320DAC33 if I2C - select SND_SOC_TWL4030 if TWL4030_CORE + select SND_SOC_TWL4030 if TWL4030_CODEC select SND_SOC_UDA134X select SND_SOC_UDA1380 if I2C select SND_SOC_WM8350 if MFD_WM8350
sound/soc/codecs/twl4030.c +126 -77
322 lines not on this page · raw message
sound/soc/codecs/twl4030.h +6 -236
254 lines not on this page · raw message
Signature · 1 line
1.6.5.1
Re: [PATCH 4/4] ASoC: TWL4030: Driver registration via twl4030_codec MFD
Quoted 2 lines · Peter Ujfalusi
TWL4030 codec is now using the device registration via
tlw4030_codecMFD device.
This looks pretty good but obviously depends on the MFD changes. The major thing that jumps out at me is the removal of the register definitions from the ASoC headers - it might be nice to have that done as part of the MFD patch, or as a separate patch.
You've also got the bias being brought up when the ASoC system comes up rather than when the driver comes up. To be honest it doesn't really make any difference either way, it's just slightly different to other drivers. What is useful with things like twl4030 which take a little while to come up is if you can do the bias bringup out of line from device probe, avoiding blocking system startup on CODEC bringup. That's definitely a separate patch, I'm just mentioning it for interest here.
There's also a couple of debug prints (like in the remove function) and
Quoted 1 line
+MODULE_ALIAS("platform:twl4030_codec:audio");
Is that second colon right given...
sound/soc/codecs/twl4030.c static int twl4030_init(struct snd_soc_device *socdev) · line 2312
Quoted 3 lines
sound/soc/codecs/twl4030.c +3
-0+ .driver = { + .name = "twl4030_codec_audio", + .owner = THIS_MODULE,
this.
Re: [PATCH 4/4] ASoC: TWL4030: Driver registration via twl4030_codec MFD
Quoted 5 lines · On Tuesday 20 October 2009 13:25:40 ext Mark Brown wrote:
Quoted 2 lines · Peter Ujfalusi
TWL4030 codec is now using the device registration via
tlw4030_codecMFD device.This looks pretty good but obviously depends on the MFD changes.
Thanks, yes it all depends on the MFD changes.
Quoted 3 lines
The major thing that jumps out at me is the removal of the register definitions from the ASoC headers - it might be nice to have that done as part of the MFD patch, or as a separate patch.
The reason why I have done it like this is that with one patch I only touch one subsystem at the time:
1. MFD changes only
2. OMAP related changes
3. soc codec driver change
In patch 1, the register definitions had to be added, so that the twl4030_codec driver knows the registers (and there could be the vibra driver placed separately from the soc codec driver).
In patch 3, where I modify the soc codec driver to use the new method, than I remove the definitions and use the existing header file, introduced by the first patch.
All in all, after each patch the kernel can be builds, boots and works as before.
Quoted 5 lines
You've also got the bias being brought up when the ASoC system comes up rather than when the driver comes up. To be honest it doesn't really make any difference either way, it's just slightly different to other drivers.
I was thinking that if you built the kernel with SND_SOC_ALL_CODECS on OMAP platform for some reason and you don't actually use the twl4030 as audio device -> no machine driver, which would use it, than the codec part would be off. But yes, probably I can move the povering up to the probe function.
Quoted 4 lines
What is useful with things like twl4030 which take a little while to come up is if you can do the bias bringup out of line from device probe, avoiding blocking system startup on CODEC bringup. That's definitely a separate patch, I'm just mentioning it for interest here.
I'm sure there will be another round for this series, so I can make this change at the same time within the patch, since this anyway changes the way how the driver is loaded/probed.
Quoted 2 lines
There's also a couple of debug prints (like in the remove function) and
I'll get rid of them.
But at least this time I did not had those unneeded casts, which I usually have ;)
Quoted 4 lines
Quoted 2 lines
+MODULE_ALIAS("platform:twl4030_codec:audio");
Is that second colon right given...
I'm not sure about it at all either. I did not found any other 'nested MFD' drivers around, so this is just a guess
Should it be:
+MODULE_ALIAS("platform:twl4030_codec_audio");
Quoted 7 lines
sound/soc/codecs/twl4030.c static int twl4030_init(struct snd_soc_device *socdev) · line 2312
Quoted 4 lines
sound/soc/codecs/twl4030.c +3
-0+ .driver = { + .name = "twl4030_codec_audio", + .owner = THIS_MODULE,this.
Signature · 1 line
Péter
Re: [PATCH 4/4] ASoC: TWL4030: Driver registration via twl4030_codec MFD
Quoted 8 lines · Peter Ujfalusi
In patch 1, the register definitions had to be added, so that the
twl4030_codecdriver knows the registers (and there could be the vibra driver placed separately from the soc codec driver).
In patch 3, where I modify the soc codec driver to use the new method, than I remove the definitions and use the existing header file, introduced by the first patch.
All in all, after each patch the kernel can be builds, boots and works as before.
Sure, though I suspect patch 3 could just be split in two happily with an include. I don't really mind either way. If you are going to keep them as one patch it'd be good to call out the move in the changelog.
Quoted 9 lines
Quoted 4 lines
You've also got the bias being brought up when the ASoC system comes up rather than when the driver comes up. To be honest it doesn't really make any difference either way, it's just slightly different to other drivers.
I was thinking that if you built the kernel with
SND_SOC_ALL_CODECSon OMAP platform for some reason and you don't actually use the twl4030 as audio device -> no machine driver, which would use it, than the codec part would be off. But yes, probably I can move the povering up to the probe function.
That's a good enough reason to leave things as they are, though really if you're building SND_SOC_ALL_CODECs in a production system you're being a bit strange.
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
+MODULE_ALIAS("platform:twl4030_codec:audio");
Is that second colon right given...
I'm not sure about it at all either. I did not found any other 'nested MFD' drivers around, so this is just a guess
Should it be:+MODULE_ALIAS("platform:twl4030_codec_audio");
Yes. The aliasing makes no reference to the parents of the device, it only cares about the device name - for the purposes of module loading and driver matching it's identical to any other platform device.
Re: [PATCH 4/4] ASoC: TWL4030: Driver registration via twl4030_codec MFD
Quoted 3 lines · On Tuesday 20 October 2009 14:51:06 ext Mark Brown wrote:
Sure, though I suspect patch 3 could just be split in two happily with an include. I don't really mind either way. If you are going to keep them as one patch it'd be good to call out the move in the changelog.
I'll split the soc codec patch to two, one is changing the header the other is for the change in the codec driver.
Quoted 3 lines
That's a good enough reason to leave things as they are, though really if you're building
SND_SOC_ALL_CODECsin a production system you're being a bit strange.
Fair enough.
Quoted 6 lines
Quoted 2 lines
+MODULE_ALIAS("platform:twl4030_codec_audio");
Yes. The aliasing makes no reference to the parents of the device, it only cares about the device name - for the purposes of module loading and driver matching it's identical to any other platform device.
Good to know, I'll change this as well.
Thanks,
Péter
Re: [PATCH 3/4] ASoC: TWL4030: Only update the needed bits in *set_dai_sysclk
In reply to Peter Ujfalusisound/soc/codecs/twl4030.c static int twl4030_set_dai_sysclk(struct snd_soc_dai *codec_dai, · line 1792
Quoted 3 lines · Peter Ujfalusi
sound/soc/codecs/twl4030.c +2
-0+ apll_ctrl =twl4030_read_reg_cache (codec,TWL4030_REG_APLL_CTL ); + apll_ctrl &= ~TWL4030_APLL_INFREQ ;switch (freq) {
I'll apply this - it's idiomatic for the current driver - but you might want to look at snd_soc_update_bits() which does a read/modify/write cycle for you.
Re: [PATCH 3/4] ASoC: TWL4030: Only update the needed bits in *set_dai_sysclk
Quoted 9 lines · On Monday 19 October 2009 15:55:08 ext Mark Brown wrote:
sound/soc/codecs/twl4030.c static int twl4030_set_dai_sysclk(struct snd_soc_dai *codec_dai, · line 1792
Quoted 3 lines · Peter Ujfalusi
sound/soc/codecs/twl4030.c +2
-0+ apll_ctrl =twl4030_read_reg_cache (codec,TWL4030_REG_APLL_CTL ); + apll_ctrl &= ~TWL4030_APLL_INFREQ ;switch (freq) {I'll apply this - it's idiomatic for the current driver - but you might want to look at
snd_soc_update_bits()which does a read/modify/write cycle for you.
Yeah, it is a good idea.
I'll address this when I go through the soc codec driver in my planned revisit and cleanup round quite soon.
Thanks,
Péter
Re: [PATCH 2/4] OMAP: Platform support for twl4030_codec MFD
In reply to Peter UjfalusiQuoted 4 lines · Peter Ujfalusi
Add needed platform data for the
twl4030_codecMFD on boards, where the audio part of the twl4030 codec is used.Signed-off-by Peter Ujfalusi <[email protected]>
This looks safe to merge with the twl/audio patches to keep them together. So not adding to my queue.
Quoted 172 lines
--- arch/arm/mach-omap2/board-3430sdp.c | 9 +++++++++ arch/arm/mach-omap2/board-omap3beagle.c | 9 +++++++++ arch/arm/mach-omap2/board-omap3evm.c | 9 +++++++++ arch/arm/mach-omap2/board-omap3pandora.c | 9 +++++++++ arch/arm/mach-omap2/board-overo.c | 9 +++++++++ arch/arm/mach-omap2/board-zoom2.c | 9 +++++++++ 6 files changed, 54 insertions(+), 0 deletions(-)arch/arm/mach-omap2/board-3430sdp.c +9
-0@@ -410,6 +410,14 @@ static struct regulator_init_data sdp3430_vpll2 = { .consumer_supplies = &sdp3430_vdvi_supply, }; +static struct twl4030_codec_audio_data sdp3430_audio = { + .audio_mclk =26000000 , +}; + +static struct twl4030_codec_data sdp3430_codec = { + .audio = &sdp3430_audio, +}; +static struct twl4030_platform_data sdp3430_twldata = { .irq_base =TWL4030_IRQ_BASE , .irq_end =TWL4030_IRQ_END ,@@ -420,6 +428,7 @@ static struct twl4030_platform_data sdp3430_twldata = { .madc = &sdp3430_madc_data, .keypad = &sdp3430_kp_data, .usb = &sdp3430_usb_data, + .codec = &sdp3430_codec, .vaux1 = &sdp3430_vaux1, .vaux2 = &sdp3430_vaux2,arch/arm/mach-omap2/board-omap3beagle.c +9
-0@@ -254,6 +254,14 @@ static struct twl4030_usb_data beagle_usb_data = { .usb_mode = T2_USB_MODE_ULPI, }; +static struct twl4030_codec_audio_data beagle_audio_data = { + .audio_mclk =26000000 , +}; + +static struct twl4030_codec_data beagle_codec_data = { + .audio = &beagle_audio_data, +}; +static struct twl4030_platform_data beagle_twldata = { .irq_base =TWL4030_IRQ_BASE , .irq_end =TWL4030_IRQ_END ,@@ -261,6 +269,7 @@ static struct twl4030_platform_data beagle_twldata = {/* platform_data for children goes here */ .usb = &beagle_usb_data, .gpio = &beagle_gpio_data, + .codec = &beagle_codec_data, .vmmc1 = &beagle_vmmc1, .vsim = &beagle_vsim, .vdac = &beagle_vdac,arch/arm/mach-omap2/board-omap3evm.c +9
-0@@ -194,6 +194,14 @@ static struct twl4030_madc_platform_data omap3evm_madc_data = { .irq_line = 1, }; +static struct twl4030_codec_audio_data omap3evm_audio_data = { + .audio_mclk =26000000 , +}; + +static struct twl4030_codec_data omap3evm_codec_data = { + .audio = &omap3evm_audio_data, +}; +static struct twl4030_platform_data omap3evm_twldata = { .irq_base =TWL4030_IRQ_BASE , .irq_end =TWL4030_IRQ_END ,@@ -203,6 +211,7 @@ static struct twl4030_platform_data omap3evm_twldata = { .madc = &omap3evm_madc_data, .usb = &omap3evm_usb_data, .gpio = &omap3evm_gpio_data, + .codec = &omap3evm_codec_data, };static struct i2c_board_info __initdata omap3evm_i2c_boardinfo[] = {arch/arm/mach-omap2/board-omap3pandora.c +9
-0@@ -281,11 +281,20 @@ static struct twl4030_usb_data omap3pandora_usb_data = { .usb_mode = T2_USB_MODE_ULPI, }; +static struct twl4030_codec_audio_data omap3pandora_audio_data = { + .audio_mclk =26000000 , +}; + +static struct twl4030_codec_data omap3pandora_codec_data = { + .audio = &omap3pandora_audio_data, +}; +static struct twl4030_platform_data omap3pandora_twldata = { .irq_base =TWL4030_IRQ_BASE , .irq_end =TWL4030_IRQ_END , .gpio = &omap3pandora_gpio_data, .usb = &omap3pandora_usb_data, + .codec = &omap3pandora_codec_data, .vmmc1 = &pandora_vmmc1, .vmmc2 = &pandora_vmmc2, .keypad = &pandora_kp_data,arch/arm/mach-omap2/board-overo.c +9
-0@@ -329,6 +329,14 @@ static struct regulator_init_data overo_vmmc1 = { .consumer_supplies = &overo_vmmc1_supply, }; +static struct twl4030_codec_audio_data overo_audio_data = { + .audio_mclk =26000000 , +}; + +static struct twl4030_codec_data overo_codec_data = { + .audio = &overo_audio_data, +}; +/* mmc2 (WLAN) and Bluetooth don't use twl4030 regulators */ static struct twl4030_platform_data overo_twldata = {@@ -336,6 +344,7 @@ static struct twl4030_platform_data overo_twldata = { .irq_end = TWL4030_IRQ_END, .gpio = &overo_gpio_data, .usb = &overo_usb_data, + .codec = &overo_codec_data, .vmmc1 = &overo_vmmc1, };arch/arm/mach-omap2/board-zoom2.c +9
-0@@ -229,6 +229,14 @@ static struct twl4030_madc_platform_data zoom2_madc_data = { .irq_line = 1, }; +static struct twl4030_codec_audio_data zoom2_audio_data = { + .audio_mclk =26000000 , +}; + +static struct twl4030_codec_data zoom2_codec_data = { + .audio = &zoom2_audio_data, +}; +static struct twl4030_platform_data zoom2_twldata = { .irq_base =TWL4030_IRQ_BASE , .irq_end =TWL4030_IRQ_END ,@@ -239,6 +247,7 @@ static struct twl4030_platform_data zoom2_twldata = { .usb = &zoom2_usb_data, .gpio = &zoom2_gpio_data, .keypad = &zoom2_kp_twl4030_data, + .codec = &zoom2_codec_data, .vmmc1 = &zoom2_vmmc1, .vmmc2 = &zoom2_vmmc2, .vsim = &zoom2_vsim,Signature · 1 line
1.6.5.1
Re: [PATCH 1/4] MFD: twl4030: add twl4030_codec MFD as a new child to the core
In reply to Peter Ujfalusidrivers/mfd/Kconfig config TWL4030_POWER · line 125
Quoted 11 lines · Peter Ujfalusi
New MFD child to twl4030 MFD device.
This MFD device will be used by the drivers, which needs resources from the twl4030 codec like audio and vibra.The platform specific configuration data is passed along to the child drivers (audio, vibra).
Signed-off-by Peter Ujfalusi <[email protected]>drivers/mfd/Kconfig +2
-0+config TWL4030_CODEC + bool "Support codec part of the TWL4030 family chips"
This seems like something that users shouldn't really have to worry about selecting explicitly - might it be better to have it selected by the drivers that use it instead? It feels like it's an implementation detail of the driver.
Re: [alsa-devel] [PATCH 1/4] MFD: twl4030: add twl4030_codec MFD as a new child to the core
Quoted 10 lines · On Tuesday 20 October 2009 13:03:34 ext Mark Brown wrote:
Quoted 9 lines · Peter Ujfalusi
New MFD child to twl4030 MFD device.
This MFD device will be used by the drivers, which needs resources from the twl4030 codec like audio and vibra.The platform specific configuration data is passed along to the child drivers (audio, vibra).
Signed-off-by Peter Ujfalusi <[email protected]>
Quoted 7 lines
drivers/mfd/Kconfig config TWL4030_POWER · line 125
Quoted 2 lines
drivers/mfd/Kconfig +2
-0+config TWL4030_CODEC + bool "Support codec part of the TWL4030 family chips"This seems like something that users shouldn't really have to worry about selecting explicitly - might it be better to have it selected by the drivers that use it instead? It feels like it's an implementation detail of the driver.
Yes, first I had the TWL4030_CODEC selected in the sound/soc/codecs/Kconfig, but for some reason I have decided to add user selectable config option instead and use the depends on in the codecs Makefile.
I'll make the change as you suggested.
Signature · 1 line
Péter
Re: [PATCH 1/4] MFD: twl4030: add twl4030_codec MFD as a new child to the core
In reply to Peter UjfalusiHi Peter,
Quoted 6 lines · Peter Ujfalusi
New MFD child to twl4030 MFD device.
This MFD device will be used by the drivers, which needs resources from the twl4030 codec like audio and vibra.The platform specific configuration data is passed along to the child drivers (audio, vibra).
Some comments on your code:
drivers/mfd/Kconfig config TWL4030_POWER · line 136
Quoted 13 lines
drivers/mfd/Kconfig +13
-0+config TWL4030_CODEC + bool "Support codec part of the TWL4030 family chips" + depends on TWL4030_CORE + help + Say yes here if you want to use the codec resources on the + TWL4030 family chips. The codec in TWL4030 provides the audio + functionality and also has the vibrator controls. + + This driver provides MFD device to be used for drivers, which needs + access to the codec part, the board-specific data is passed from this + driver to the childs as platform data with the board specific + configuration. +
As Mark noticed already, you dont really want users to explicitely select this obscure mfd driver to get their audio and vibre driver selectable. It should be the other way around, and I think you already agreed with that.
Quoted 23 lines
drivers/mfd/twl4030-codec.c new file +23
-0+static struct device * +twl4030_codec_new_child (const char *name,void *pdata,unsigned pdata_len) +{ +struct platform_device *pdev; +int status =0 ; + + pdev =platform_device_alloc (name,-1 ); +if (!pdev) { +dev_dbg (&twl4030_codec_dev->dev,"can't alloc dev (%s)\n" , + name); +return ERR_PTR (-ENOMEM ); + } + pdev->dev.parent = &twl4030_codec_dev->dev; + +if (pdata) { + status =platform_device_add_data (pdev, pdata, pdata_len); +if (status <0 ) { +dev_dbg (&pdev->dev,"can't add platform_data\n" ); + goto err; + } + } + status =platform_device_add (pdev); +if (status <0 ) {
drivers/mfd/twl4030-codec.c line 176
Quoted 10 lines
drivers/mfd/twl4030-codec.c new file +10
-0+dev_dbg (&pdev->dev,"Adding platform device failed\n" ); + goto err; + } + +return &pdev->dev; +err: +platform_device_put (pdev); +dev_err (&twl4030_codec_dev->dev,"can't add %s dev\n" , name); +return ERR_PTR (status); +}
This could really use the mfd-core API, and avoid duplicating code. You just would have to define a couple cells, and call mfd_add_devices on them.
drivers/mfd/twl4030-codec.c line 218
Quoted 10 lines
drivers/mfd/twl4030-codec.c new file +10
-0+static int __devexit twl4030_codec_remove(struct platform_device *pdev) +{ +struct twl4030_codec *codec =platform_get_drvdata (pdev); + +platform_set_drvdata (pdev,NULL ); +kfree (codec); + twl4030_codec_dev =NULL ; + +return 0 ; +}
I think you're missing a platform_device_unregister() here (or an mfd_remove_devices() if you're going to switch to the mfd-core API)
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/
Re: [PATCH 1/4] MFD: twl4030: add twl4030_codec MFD as a new child to the core
Quoted 3 lines · On Thursday 22 October 2009 02:13:11 ext Samuel Ortiz wrote:
As Mark noticed already, you dont really want users to explicitely select
this obscure mfd driver to get their audio and vibre driver selectable. It should be the other way around, and I think you already agreed with that.
Yes, I have already made the modification.
Quoted 4 lines
Quoted 4 lines
(quoted diff) +2
-0+static struct device * +twl4030_codec_new_child(const char *name, void *pdata, unsigned
pdata_len) +{
...
Quoted 3 lines
This could really use the mfd-core API, and avoid duplicating code. You just would have to define a couple cells, and call
mfd_add_deviceson them.
Good point. When I wrote this driver I have been looking at the twl4030-core driver, which is not using the mfd-core API. I'll make the change.
Quoted 14 lines
drivers/mfd/twl4030-codec.c line 218
Quoted 11 lines
drivers/mfd/twl4030-codec.c new file +10
-0+static int __devexit twl4030_codec_remove(struct platform_device *pdev) +{ +struct twl4030_codec *codec =platform_get_drvdata (pdev); + +platform_set_drvdata (pdev,NULL ); +kfree (codec); + twl4030_codec_dev =NULL ; + +return 0 ; +}I think you're missing a
platform_device_unregister()here (or anmfd_remove_devices()if you're going to switch to the mfd-core API)
You are right, although I have used the bool in the Kconfig for the twl4030- codec in a same way as the twl4030-core (and the core did not unregister the devices either), but yes, this is not correct so I'll fix it.
I have now question about the practicalities on how this series would be taken, and via which tree.
The final patch for the soc codec driver depends on the change in MFD and in the OMAP board files.
The change in the OMAP board files depends on the MFD changes, obviously.
So in order to have the soc codec changes the MFD and OMAP part has to be applied before, otherwise the audio will be broken.
the mfd-2.6:for-next branch has some patches against the twl4030-core in addition to the ones in l-o and in sound-2.6:topic/asoc.
I'll check, if the MFD patch applies to mfd-2.6:for-next also, but to have the soc codec changes the MFD patch should go to the sound-2.6 tree as well to make sure it is not braking things.
All-in-all, how these things can be handled?
Thanks,
Péter
Re: [PATCH 1/4] MFD: twl4030: add twl4030_codec MFD as a new child to the core
Quoted 5 lines · Peter Ujfalusi
I'll check, if the MFD patch applies to mfd-2.6:for-next also, but to have the soc codec changes the MFD patch should go to the sound-2.6 tree as well to make sure it is not braking things.
All-in-all, how these things can be handled?
The OMAP patch has been acked by Tony. Then we I'm fine with the mfd one and Mark is also ok with the remaining asoc one, all 3 patches have to go through one single tree.
It seems to me that this patchset is mostly an asoc one, even though all of those patches depend on the MFD one. So I'd perfectly fine if they'd all go through Mark's tree, and then I'd have to make sure I'm sending my 2.6.33 merge window pull request _after_ Mark's code is in Linus tree. Once it's there, I can work on merging conflicts with the few twl4030-core pending patches from my tree. Mark, what do you think ?
Cheers,
Samuel.
Quoted 2 lines
Thanks,
Péter
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/
Re: [PATCH 1/4] MFD: twl4030: add twl4030_codec MFD as a new child to the core
Quoted 6 lines · Samuel Ortiz
It seems to me that this patchset is mostly an asoc one, even though all of those patches depend on the MFD one. So I'd perfectly fine if they'd all go through Mark's tree, and then I'd have to make sure I'm sending my 2.6.33 merge window pull request _after_ Mark's code is in Linus tree. Once it's there, I can work on merging conflicts with the few twl4030-core pending patches from my tree. Mark, what do you think ?
Seems reasonable. I'll apply them on a separate branch and merge them into my 2.6.33 branch so that you can merge them into your tree too and avoid any cross-tree issues without needing to think about how things get merged with Linus (though since Takashi generally merges early it'll probably happen naturally anyway). Note that if you do pull this branch you won't be able to rebase your tree, you'd have to merge up Linus' tree instead (but that'd be handy anyway :) ).
Re: [PATCH 1/4] MFD: twl4030: add twl4030_codec MFD as a new child to the core
Quoted 8 lines · On Thursday 22 October 2009 13:55:17 ext Mark Brown wrote:
Quoted 6 lines · Samuel Ortiz
It seems to me that this patchset is mostly an asoc one, even though all of those patches depend on the MFD one. So I'd perfectly fine if they'd all go through Mark's tree, and then I'd have to make sure I'm sending my 2.6.33 merge window pull request _after_ Mark's code is in Linus tree. Once it's there, I can work on merging conflicts with the few twl4030-core pending patches from my tree. Mark, what do you think ?
Quoted 7 lines
Seems reasonable. I'll apply them on a separate branch and merge them into my 2.6.33 branch so that you can merge them into your tree too and avoid any cross-tree issues without needing to think about how things get merged with Linus (though since Takashi generally merges early it'll probably happen naturally anyway). Note that if you do pull this branch you won't be able to rebase your tree, you'd have to merge up Linus' tree instead (but that'd be handy anyway :) ).
I just sent the second series, I'll hope the I have not missed anything. I was scratching my head on which tree it should be going, but it is really nice to see that it can be done like this.
Thank you Samuel, Mark and Tony!
Signature · 1 line
Péter
Hello Samuel,
Quoted 6 lines · On Monday 19 October 2009 15:42:16 Ujfalusi Peter (Nokia-D/Tampere) wrote:
Hello,
The following series adds new MFD device on top of the twl4030 MFD device
for the codec part of the chip, and also converts the soc audio driver to use the correct probing (device model).
Quoted 6 lines
Reason for the
twl4030_codecMFD: the vibra control is actually in the
codec part of the twl4030. If both the vibra and the audio functionality is needed from the twl4030 at the same time, than they need to control the codec power and APLL at the same time without breaking the other driver.
Also these two has to be able to work without the need for the other
driver.
Have you had time to look at the series?
I have made all the modification suggested by Mark Brown, and I'm holding back the second series (to have the comments from you for the initial series), so I can address those in the same round.
Thank you,
Péter