Hi Mark,
On 05/09/2012 04:35 PM, Mark Brown wrote:
That's true but what can I do with that in the ASoC machine driver? The chip driver is _not_ the codec driver.
This really doesn't seem like it should be at all hard to resolve...
By not using any phandle for the codec in the dts file. The phandle for the chip (MFD driver) is as useful as any other phandle for me to parse things in the ASoC machine driver.
I can craft the pdata for the MFD child devices out from the DT information but then the child devices will have no dev.of_node since they were not probed via OF. So I would have not phandle for the codec to be used to define the dai-link connection within the sound dts section.
Am I missing something here?
Clearly. This is all very circular. Obviously if you're intent on using a phandle specific to the MFD child then you need to have that in the device tree but this is because you're making the child devices externally visible... Clearly if we're not going to use the MFD subdevices in the DT then the links ought to reference the chip.
This boils down to this after all: how to handle an MFD device in DT? Clearly this is not really defined.
I suppose I can go with something like this in the dts for twl6040:
twl6040: twl6040@4b { compatible = "ti,twl6040"; reg = <0x4b>; interrupts = <0 119 4>; /* IRQ_SYS_2N cascaded to gic */ interrupt-parent = <&gic>; twl6040,audpwron_gpio = <&gpio4 31 0>; /* gpio 127 */ enable-active-high;
interrupt-controller; #interrupt-cells = <1>;
vio-supply = <&v1v8>; v2v1-supply = <&v2v1>;
vibra { vddvibl-supply = <&vbat>; vddvibr-supply = <&vbat>; vibldrv_res = <8>; vibrdrv_res = <3>; viblmotor_res = <10>; vibrmotor_res = <10>; }; };
So we probe the MFD driver via DT. We construct the mfd children struct for ASoC codec (always, since the main function of twl6040 is to provide audio), or I can have a property like twl6040,audio_enabled to explicitly enable the audio functionality. We created the vibra device only if the vibra section exist. We register use mfd_add_devices() in DT probed mode as well.
The vibra driver can get it's configuration via pdev->dev.parent->of_node (from the MFD OF node).
As for the machine driver:
sound { compatible = "ti,abe-twl6040"; abe-twl6040,model = "SDP4430";
abe-twl6040,jack_detection = <1>; abe-twl6040,mclk_freq = <38400000>;
codec,dmic = <&dmic_codec>;
dai,mcpdm = <&mcpdm>; dai,dmic = <&dmic>;
/* Audio routing */ abe-twl6040,audio-routing = "Headset Stereophone", "HSOL", "Headset Stereophone", "HSOR", "Earphone Spk", "EP", "Ext Spk", "HFL", "Ext Spk", "HFR", "Line Out", "AUXL", "Line Out", "AUXR", "Vibrator", "VIBRAL", "Vibrator", "VIBRAR", "HSMIC", "Headset Mic", "Headset Mic", "Headset Mic Bias", "MAINMIC", "Main Handset Mic", "Main Handset Mic", "Main Mic Bias", "SUBMIC", "Sub Handset Mic", "Sub Handset Mic", "Main Mic Bias", "AFML", "Line In", "AFMR", "Line In", "DMic", "Digital Mic", "Digital Mic", "Digital Mic1 Bias"; };
In the driver I remove the mcpdm dai names and and the phandle for it instead. Same for the dmic dai and for the dmic codec. Since the twl6040 ASoC codec does not have phandle (not loaded via DT) I do not need to touch it, I can leave the codec_name as it was. The number of DAI links can be checked if we have for example the codec,dmic property set. If it is set we have 2 links, if it is not set we have one (twl6040 <-> mcpdm).
Mark: is this what you were suggesting?