[ELDK] Getting your clock on qong / arm

Detlev Zundel dzu at denx.de
Wed Aug 12 17:42:49 CEST 2009


Hi Wolf,

> Good day everyone!

Good day to you too!

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

Not really - the ELDK list is to support the ELDK as a toolchain
together with its target components.

You clearly want to post your question on the linux-arm mailinglist:

http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel

> 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?

Although I'm an outsider, this makes sense.

> 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)

For me this looks like good - so actually I'd propose rolling this into
a git formatted patch and post it to the arm mailinglist and see what
happens.

Cheers
  Detlev

-- 
Choosing which tool to use is a problem for most users. Therefore
when one tool came along that did everything Perl (Ugly) it took over.
                                    -- Rob Pike
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de


More information about the eldk mailing list