Index: linux-2.6.18-htc/include/asm-arm/arch-pxa/clock.h =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.6.18-htc/include/asm-arm/arch-pxa/clock.h 2006-10-22 13:57:31.000000000 +0200 @@ -0,0 +1,25 @@ +/* + * linux/include/asm-arm/arch-pxa/clock.h + * + * Copyright (C) 2006 Erik Hovland + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +struct clk { + struct list_head node; + unsigned long rate; + struct module *owner; + struct clk *parent; + const char *name; + unsigned int enabled; + unsigned long priv; + void (*enable)(struct clk *); + void (*disable)(struct clk *); +}; + + +extern int clk_register(struct clk *clk); +extern void clk_unregister(struct clk *clk); Index: linux-2.6.18-htc/arch/arm/mach-pxa/clock.c =================================================================== --- linux-2.6.18-htc.orig/arch/arm/mach-pxa/clock.c 2006-10-22 13:57:02.000000000 +0200 +++ linux-2.6.18-htc/arch/arm/mach-pxa/clock.c 2006-10-22 13:58:00.000000000 +0200 @@ -14,15 +14,7 @@ #include #include -struct clk { - struct list_head node; - unsigned long rate; - struct module *owner; - const char *name; - unsigned int enabled; - void (*enable)(void); - void (*disable)(void); -}; +#include static LIST_HEAD(clocks); static DECLARE_MUTEX(clocks_sem); @@ -57,7 +49,7 @@ spin_lock_irqsave(&clocks_lock, flags); if (clk->enabled++ == 0) - clk->enable(); + clk->enable(clk); spin_unlock_irqrestore(&clocks_lock, flags); return 0; } @@ -71,24 +63,46 @@ spin_lock_irqsave(&clocks_lock, flags); if (--clk->enabled == 0) - clk->disable(); + clk->disable(clk); spin_unlock_irqrestore(&clocks_lock, flags); } EXPORT_SYMBOL(clk_disable); unsigned long clk_get_rate(struct clk *clk) { + if (clk->rate != 0) + return clk->rate; + + while (clk->parent != NULL && clk->rate == 0) + clk = clk->parent; + return clk->rate; } EXPORT_SYMBOL(clk_get_rate); +struct clk *clk_get_parent(struct clk *clk) +{ + return clk->parent; +} +EXPORT_SYMBOL(clk_get_parent); + +int clk_set_parent(struct clk *clk, struct clk *parent) +{ + down(&clocks_sem); + clk->parent = parent; + up(&clocks_sem); + + return 0; +} +EXPORT_SYMBOL(clk_set_parent); + -static void clk_gpio27_enable(void) +static void clk_gpio27_enable(struct clk *clk) { pxa_gpio_mode(GPIO11_3_6MHz_MD); } -static void clk_gpio27_disable(void) +static void clk_gpio27_disable(struct clk *clk) { }