Solved: pck0 codec frequency support by device tree is missing v4.14.11 ?

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

PowerPenguin
Posts: 16
Joined: Mon Feb 19, 2018 12:41 pm

Solved: pck0 codec frequency support by device tree is missing v4.14.11 ?

Mon Feb 19, 2018 1:02 pm

Hi community, does any expert know how to set up pck0 by device tree.
I am using a AT91SAM9G20 and I want to program pck0 to 12MHz.
But the pck0 is also on all other AT91SAM SoCs

If I choose PLLB and divider is set to 4; the MCLK (pck0) for my audio codec is set to 12MHz
devmem 0xFFffFC40 8 0xb

But I want to configure pck0 frequency by device tree. I couldn´t find any example and in
https://elixir.bootlin.com/linux/v4.14. ... rammable.c
no node is checked for frequency ..
I think if implemented it must be a kind of dynamic support. The wish frequency has to be re calculated by clock source selection and divider.
If no clocksource with divider itteration will match prn_err ("frequency %xnot supported", frequency_device_node)

Or is it possible on a different way ? This discription for programmable clocks is not so easy to understand
https://elixir.bootlin.com/linux/v4.14. ... -clock.txt

Is there a linux4sam *dts example link ?

Thanks for any response,
PowerPenguin
Last edited by PowerPenguin on Thu Feb 22, 2018 7:34 pm, edited 3 times in total.
blue_z
Location: USA
Posts: 1745
Joined: Thu Apr 19, 2007 10:15 pm

Re: pck0 frequency support by device tree is missing ?

Tue Feb 20, 2018 4:04 am

PowerPenguin wrote: I couldn´t find any example and in
https://elixir.bootlin.com/linux/v4.14. ... rammable.c
no node is checked for frequency ..
Probably because you're looking in the wrong place.

PowerPenguin wrote:I think if implemented it must be a kind of dynamic support. The wish frequency has to be re calculated by clock source selection and divider.
If no clocksource with divider itteration will match prn_err ("frequency %xnot supported", frequency_device_node)
Or is it possible on a different way ?
Instead of writing about your guesses, why haven't you looked at what has already been done?

PowerPenguin wrote:This discription for programmable clocks is not so easy to understand
https://elixir.bootlin.com/linux/v4.14. ... -clock.txt
Again you're probably looking in the wrong place.

PowerPenguin wrote:Is there a linux4sam *dts example link ?
Well, the Device Tree for the SAM9G20 reference board is at91sam9g20ek.dts, which includes at91sam9g20ek_common.dtsi.
The salient node in that file is

Code: Select all

/ {
        ...
	sound {
		compatible = "atmel,at91sam9g20ek-wm8731-audio";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_pck0_as_mck>;

		atmel,model = "wm8731 @ AT91SAMG20EK";

		atmel,audio-routing =
			"Ext Spk", "LHPOUT",
			"Int Mic", "MICIN";

		atmel,ssc-controller = <&ssc0>;
		atmel,audio-codec = <&wm8731>;
	};
};
This node is used by the sound/soc/atmel/sam9g20_wm8731.c driver.
This is the driver that acquires the programmable clock pck0, and then configures it.
The clock (and most sound codec) attributes are hardcoded in the module rather than obtained from the DT.

Code: Select all

#define MCLK_RATE 12000000
        ...
	mclk = clk_get(NULL, "pck0");
        ...
	clk_set_rate(mclk, MCLK_RATE);

If you want to "set up pck0 by device tree", then you first have to know where and how this setup would occur.
The above audio codec driver does not have its clock specification by DT, whereas some other drivers (or subsystems) do (e.g. see Documentation/devicetree/bindings/media/i2c/ov7670.txt) using of_clk_set_defaults().


Regards
PowerPenguin
Posts: 16
Joined: Mon Feb 19, 2018 12:41 pm

Re: pck0 frequency support by device tree is missing ?

Tue Feb 20, 2018 12:40 pm

Thanks a lot. Sound works fine in v4.14.11 :D :D

The pck0 is set up by https://elixir.bootlin.com/linux/v4.14. ... ndings.txt
So its done by dts of linux and that pass the info to atmel.
I thought pck0 clk dts has to be done by atmel SoC clk driver, but that was wrong.
Very well supported clock system by Atmel :-)

So it is possible to run any codec by simple sound card driver and device tree :D

You need to add a Kconfig part to select your board option and that will select simple sound card and your codec and the atmel sound stuff.
Thats works without any new C-file for your sound card !
Add this new sound config to your defconfig thats all :D

This works for G20 with SSC_PDC

/sound/soc/atmel/Kconfig

Code: Select all


config SND_TAURUS_TLV320AIC33
 	tristate "SoC Audio support for TLV320AIC based Taurus reference board"
	depends on ARCH_AT91 || COMPILE_TEST
	depends on ATMEL_SSC && SND_SOC_I2C_AND_SPI
	select SND_ATMEL_SOC_SSC_PDC
	select SND_SOC_TLV320AIC3X
	select SND_SIMPLE_CARD
	help
	  Say Y if you want to add support for SoC audio on TLV320AIC33 based Taurus reference board.

Code: Select all

ssc0: ssc@fffbc000 {
				status = "okay";
				pinctrl-0 = <&pinctrl_ssc0_tx &pinctrl_ssc0_rx>;
				#sound-dai-cells= <0>;
			};

Code: Select all

pinctrl@fffff400 {
				ssc_c0 {
					/* PB30 periph A MCLK */
					pinctrl_pck0_as_audio_mck: pck0_as_audio_mck {
						atmel,pins =
							<AT91_PIOB 30 AT91_PERIPH_A AT91_PINCTRL_NONE>;
							/*AT91_PIOB 19 AT91_PERIPH_A AT91_PINCTRL_NONE>;  PB19 periph A Data IN */
					};
				};

Code: Select all

i2c-gpio-0 {
				status = "okay";
				eeprom@50 {
					compatible = "24c512";
					reg = <0x50>;
				};

				/* Audio codec */
				tlv320aic3x: codec@1b {
					compatible = "ti,tlv320aic33";
					reg = <0x1b>;

					/* set up pck0 as codec mclk */
					clocks = <&pck0>;
					#clock-cells = <1>;
					clock-names = "mclk";
					assigned-clocks = <&pck0>,  <&pllb>;
					assigned-clock-parents = <&pllb>;
					assigned-clock-rates = <12000000>;

					#sound-dai-cells= <0>;
					status = "okay";


					/* Regulators */
					AVDD-supply  = <&vcc_3v3_reg>;
					IOVDD-supply = <&vcc_3v3_reg>;
					DRVDD-supply = <&vcc_3v3_reg>;
					DVDD-supply  = <&vcc_1v8_reg>;
				};
	};

sound {
		compatible = "simple-audio-card";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_pck0_as_audio_mck>;
		simple-audio-card,name = "simple-audio-card-tlv320aic33";

		simple-audio-card,widgets =
			"Line", "Line Out",
			"Headphone", "Headphone Jack",
			"Line", "Line In";
		simple-audio-card,routing =
			"Line Out",	"LLOUT",
			"Line Out",	"RLOUT",
			"Headphone Jack" , "HPLOUT",
			"Headphone Jack" , "HPLCOM",
			"Headphone Jack" , "HPROUT",
			"Headphone Jack" , "HPRCOM",
			"LINE1L", "Line In",
			"LINE1R", "Line In";

		simple-audio-card,format = "i2s";
		simple-audio-card,bitclock-master = <&sound_master>;
		simple-audio-card,frame-master = <&sound_master>;
       	simple-audio-card,mclk-fs = <256>;

		simple-audio-card,cpu {
			sound-dai = <&ssc0>;
			/* clocks =<&ssc0_clk>; */
			/*bitclock-master;*/
			/*frame-master;*/
		};

		sound_master: simple-audio-card,codec {
			sound-dai = <&tlv320aic3x>;
			clocks =<&pck0>;
			/*bitclock-master; */
			/*frame-master; */
			system-clock-frequency = <12000000>;
		};
	};

	vcc_3v3_reg: fixedregulator_3v3 {
		compatible = "regulator-fixed";
		regulator-name = "VCC 3V3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-boot-on;
		regulator-always-on;
	};

	vcc_1v8_reg: fixedregulator_1v8 {
		compatible = "regulator-fixed";
		regulator-name = "VCC 1V8";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		regulator-boot-on;
		regulator-always-on;
	};
};

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 1 guest