[ELDK] Getting your clock on qong / arm

Wolf, Rene, HRO-GP rene.wolf at mbda-systems.de
Wed Aug 12 13:40:32 CEST 2009


Good day everyone!

First of all, I hope this is the right place for such a topic.

Here are the specs:
QONG EVB-Lite
ELDK 4.2
Kernel 2.6.31-rc5, build based on qong default config
booting: uboot -> tftp (kernel) -> nfs-root (from host)
Working great so far :-)


Ok this is about clocks on arm platforms, so I will break down this procedure, as far as I understood it (please correct me if I'm wrong):

Let's say, we're in a kernel module and want to enable the 2nd uart (UART1), then we would call

uart1_clk = clk_get_sys( "imx-uart.1", NULL);
/* clk_get() would do the same, dyn. creating the dev_id "imx-uart.1" */

Afaik this will go to arch/arm/common/clkdev.c, and clk_get_sys will search in
"lookups" (defined around line 520 in arch/arm/mach-mx3/clock.c) for dev_id == "imx-uart.1".
On hit at
_REGISTER_CLOCK("imx-uart.1", NULL, uart2_clk) 
returning uart2_clk, we will call

clk_enable(uart1_clk);

and we're rolling!


Fine so far, but I'm trying to get a clock for CSPI3, and in "lookups" there is only 
_REGISTER_CLOCK(NULL, "cspi", cspi1_clk)
_REGISTER_CLOCK(NULL, "cspi", cspi2_clk)
_REGISTER_CLOCK(NULL, "cspi", cspi3_clk)

So if I call 
cspi3_clk = clk_get_sys( NULL , "cspi");

It returns the first hit: cspi1_clk.
Some further reading into the sources (arch/arm/plat-mxc/clock.c) showed me another (,older?) version of clk_get():

/*
 * All the code inside #ifndef CONFIG_COMMON_CLKDEV can be removed once all
 * MXC architectures have switched to using clkdev.
 */
#ifndef CONFIG_COMMON_CLKDEV
/*...*/
struct clk *clk_get(struct device *dev, const char *id){
/*...*/
if (p->id == idno && strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
/*...*/
#endif

This version seams be looking at the con_id ("cspi") and the id (CSPI3 => id=2) supplied by *dev, which would make an exact hit possible.


Am I right so far?


Now the older/other implementation of this search is no longer in use, and I don't see how to get to the CSPI3 clock. For testing purpose, I patched arch/arm/mach-mx3/clock.c and added the following around line 520:
_REGISTER_CLOCK("cspi.0", NULL, cspi1_clk)
_REGISTER_CLOCK("cspi.1", NULL, cspi2_clk)
_REGISTER_CLOCK("cspi.2", NULL, cspi3_clk)

Now calling 
cspi3_clk = clk_get_sys( "cspi.2" , NULL);
returns the correct clock.

Is this the right way to go? Or am I doing wrong here, and overlooked a better way of getting / enabling the clock? (Using this facility is very nice, because it enables all clocks needed, with just one call)

If I'm right, the same problem will arise with:
_REGISTER_CLOCK(NULL, "epit", epit1_clk)
_REGISTER_CLOCK(NULL, "epit", epit2_clk)
_REGISTER_CLOCK(NULL, "ssi", ssi1_clk)
_REGISTER_CLOCK(NULL, "ssi", ssi2_clk)
_REGISTER_CLOCK(NULL, "mstick", mstick1_clk)
_REGISTER_CLOCK(NULL, "mstick", mstick2_clk)



Any suggestions / corrections appreciated :-)

Thanks so far!


Rene Wolf

LFK-Lenkflugkörpersysteme GmbH
Human Resources Operations & Policy, HRO
Landshuter Straße 26, 85716 Unterschleißheim, GERMANY
Phone: +49 89 3179 8337
Fax: +49 8252 99 8964
E-Mail: rene.wolf at mbda-systems.de

http://www.mbda.net

Chairman of the Supervisory Board: Antoine Bouvier
Managing Director: Werner Kaltenegger
Registered Office: Schrobenhausen
Commercial Register: Amtsgericht Ingolstadt, HRB 4365


More information about the eldk mailing list