Clock output on PCK0 with LINUX 3.10

Discussion around products based on ARM Cortex-A5 core.

Moderator: nferre

mschulz
Posts: 7
Joined: Wed Oct 28, 2009 9:40 am

Clock output on PCK0 with LINUX 3.10

Mon Aug 08, 2016 3:26 pm

Hi all,

I want to drive an external device with a clock out of PCK0.

When I set up the according PMC and peripheral multiplexing in U-Boot all works fine.

But when I start LINUX, there is no clock output at PCK0 anymore.

What do I have to do to re-establish the clock output again?

Do I have to use some LINUX driver facility within a device-driver or can I simply configure some device tree bindings?
Is ther any documentation for the preferable way to do it?

Many thanks and best regards,

M.Schulz.
mschulz
Posts: 7
Joined: Wed Oct 28, 2009 9:40 am

Re: Clock output on PCK0 with LINUX 3.10

Mon Aug 08, 2016 3:34 pm

...sorry, the device is a SAMA5D36...
blue_z
Location: USA
Posts: 2131
Joined: Thu Apr 19, 2007 10:15 pm

Re: Clock output on PCK0 with LINUX 3.10

Tue Aug 09, 2016 1:11 am

mschulz wrote:But when I start LINUX, there is no clock output at PCK0 anymore.

What do I have to do to re-establish the clock output again?
You haven't provided any context.
The pin for PCK0 conflicts with an ADC pin.
So how does the Device Tree for your board configure these two peripherals and this pin?

Regards
mschulz
Posts: 7
Joined: Wed Oct 28, 2009 9:40 am

Re: Clock output on PCK0 with LINUX 3.10

Tue Aug 09, 2016 7:26 am

Hello blue_z,

thank u for ur fast reply.

I did already find the conflicting setting in the device tree and i have changed it so, that the ADC should only use the pins which I am using on my own baseboard.

I use this "base"-settings for the ADC:

Code: Select all

			adc0: adc@f8018000 {
				compatible = "atmel,at91sam9x5-adc";
				reg = <0xf8018000 0x100>;
				interrupts = <29 IRQ_TYPE_LEVEL_HIGH 5>;
				pinctrl-names = "default";
				pinctrl-0 = <
					&pinctrl_adc0_adtrg
/*					&pinctrl_adc0_ad0*/
/*					&pinctrl_adc0_ad1*/
/*					&pinctrl_adc0_ad2*/
/*					&pinctrl_adc0_ad3*/
/*					&pinctrl_adc0_ad4*/
					&pinctrl_adc0_ad5
					&pinctrl_adc0_ad6
					&pinctrl_adc0_ad7
					&pinctrl_adc0_ad8
					&pinctrl_adc0_ad9
/*					&pinctrl_adc0_ad10*/
/*					&pinctrl_adc0_ad11*/
					>;
				atmel,adc-channels-used = <0xfff>;
				atmel,adc-startup-time = <40>;
				atmel,adc-use-external;
				atmel,adc-vref = <3000>;
				atmel,adc-res = <10 12>;
				atmel,adc-sample-hold-time = <11>;
				atmel,adc-res-names = "lowres", "highres";
				status = "disabled";
And I also did comment out the initialisation of the ADC (status = ok).

There was also a setting in the original ATMEL DT which did use PCK0 as PLL output for the soundcard.
These settings I did also remove.

Nevertheless, PCK0 still keeps quite aster LINUX has startet.

What do I have to configure for th clock output in the device tree for LINUX 3.10? Is ther any documentation for this?

Thanks in advance and best regards,

MSchulz.
mschulz
Posts: 7
Joined: Wed Oct 28, 2009 9:40 am

Re: Clock output on PCK0 with LINUX 3.10

Tue Aug 09, 2016 2:19 pm

Hi blue_z,

I've done it - but in a very dirty way I think ;-)

I put the following code into the init-function of the driver of the device for which i need the clock:

Code: Select all

#include <mach/at91_pmc.h>

...

	printk("\n...setting peripheral B on PD30...\n");
	at91_set_B_periph(AT91_PIN_PD30, 1);

	printk("...setting MCK as clock source for PCK0...\n");
	at91_pmc_write(AT91_PMC_PCKR(0), 4);
	
	printk("...reading PMC_SCSR (0x");
	pmc_scsr = at91_pmc_read(AT91_PMC_SCSR);
	printk("%08X)...\n", pmc_scsr);
	printk("...enabling PCK0 in PMC_SCER (0x%08X)\n", pmc_scsr | AT91_PMC_PCK0);
	at91_pmc_write(AT91_PMC_SCER, pmc_scsr | AT91_PMC_PCK0); 

...

Therefore I use the AT91 pmc driver wih direct register access.

Its dirty, but it works.

Is there a more elegant way I can go?

Best regards,

MSchulz.
blue_z
Location: USA
Posts: 2131
Joined: Thu Apr 19, 2007 10:15 pm

Re: Clock output on PCK0 with LINUX 3.10

Wed Aug 10, 2016 12:42 am

mschulz wrote:Is there a more elegant way I can go?
In your board's dts file, do you at least have this PD30 pin declared as owned by this device (or the PMC)?

Regards
Last edited by blue_z on Thu Aug 11, 2016 12:24 am, edited 1 time in total.
mschulz
Posts: 7
Joined: Wed Oct 28, 2009 9:40 am

Re: Clock output on PCK0 with LINUX 3.10

Wed Aug 10, 2016 8:00 am

...no I didnt, because I am missing a bit of documentation how to do it.

Do u know some resources I can got through or can u give me some examples how to do it in the device tree?

Regards
blue_z
Location: USA
Posts: 2131
Joined: Thu Apr 19, 2007 10:15 pm

Re: Clock output on PCK0 with LINUX 3.10

Thu Aug 11, 2016 12:52 am

You could try something like this in the board-level dts file:

Code: Select all

	ahb {
		apb {

			adc0: adc@f8018000 {
				pinctrl-0 = <
					&pinctrl_adc0_adtrg
					&pinctrl_adc0_ad5
					&pinctrl_adc0_ad6
					&pinctrl_adc0_ad7
					&pinctrl_adc0_ad8
					&pinctrl_adc0_ad9
					>;
			};


			pmc: pmc@fffffc00 {
				pinctrl-names = "default";
				pinctrl-0 = <&pinctrl_pmc_pck0>;
			};


			pinctrl@fffff200 {
				pmc {

					pinctrl_pmc_pck0: pmc_pck0 {
						atmel,pins =
							<AT91_PIOD 30 AT91_PERIPH_B AT91_PINCTRL_NONE>;
					};
				};
			};
		};
	};
Redefine the pinctrl list for the ADC (and undo your hack to the SoC-level dtsi), and define a pinctrl list for the PMC (or assign it to your device).

Regards
mschulz
Posts: 7
Joined: Wed Oct 28, 2009 9:40 am

Re: Clock output on PCK0 with LINUX 3.10

Thu Aug 11, 2016 1:49 pm

thank u blue_z.

is there a direct implementation of the clock selection and output stuff in the device tree of later LINUX kernels?

Regards, MSchulz.

Return to “SAMA5D Cortex-A5 MPU”

Who is online

Users browsing this forum: No registered users and 2 guests