[PATCH 3/5] Use clocklib for ARM pxa sub-arch.
Signed-off-by: Dmitry Baryshkov <[EMAIL PROTECTED]> --- arch/arm/Kconfig |1 + arch/arm/mach-pxa/clock.c | 108 -- arch/arm/mach-pxa/clock.h | 58 +++--- arch/arm/mach-pxa/pxa25x.c | 187 +-- arch/arm/mach-pxa/pxa27x.c | 61 --- arch/arm/mach-pxa/pxa3xx.c | 91 - 6 files changed, 292 insertions(+), 214 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 4b1a8e3..45c1790 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -362,6 +362,7 @@ config ARCH_PXA select GENERIC_TIME select GENERIC_CLOCKEVENTS select TICK_ONESHOT + select HAVE_CLOCK_LIB help Support for Intel/Marvell's PXA2xx/PXA3xx processor line. diff --git a/arch/arm/mach-pxa/clock.c b/arch/arm/mach-pxa/clock.c index 83ef5ec..3296b02 100644 --- a/arch/arm/mach-pxa/clock.c +++ b/arch/arm/mach-pxa/clock.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -19,123 +20,42 @@ #include "generic.h" #include "clock.h" -static LIST_HEAD(clocks); -static DEFINE_MUTEX(clocks_mutex); -static DEFINE_SPINLOCK(clocks_lock); - -struct clk *clk_get(struct device *dev, const char *id) -{ - struct clk *p, *clk = ERR_PTR(-ENOENT); - - mutex_lock(_mutex); - list_for_each_entry(p, , node) { - if (strcmp(id, p->name) == 0 && - (p->dev == NULL || p->dev == dev)) { - clk = p; - break; - } - } - mutex_unlock(_mutex); - - return clk; -} -EXPORT_SYMBOL(clk_get); - -void clk_put(struct clk *clk) +static int clk_gpio27_enable(struct clk *clk) { -} -EXPORT_SYMBOL(clk_put); - -int clk_enable(struct clk *clk) -{ - unsigned long flags; - - spin_lock_irqsave(_lock, flags); - if (clk->enabled++ == 0) - clk->ops->enable(clk); - spin_unlock_irqrestore(_lock, flags); - - if (clk->delay) - udelay(clk->delay); + pxa_gpio_mode(GPIO11_3_6MHz_MD); return 0; } -EXPORT_SYMBOL(clk_enable); - -void clk_disable(struct clk *clk) -{ - unsigned long flags; - - WARN_ON(clk->enabled == 0); - - spin_lock_irqsave(_lock, flags); - if (--clk->enabled == 0) - clk->ops->disable(clk); - spin_unlock_irqrestore(_lock, flags); -} -EXPORT_SYMBOL(clk_disable); - -unsigned long clk_get_rate(struct clk *clk) -{ - unsigned long rate; - - rate = clk->rate; - if (clk->ops->getrate) - rate = clk->ops->getrate(clk); - - return rate; -} -EXPORT_SYMBOL(clk_get_rate); - - -static void clk_gpio27_enable(struct clk *clk) -{ - pxa_gpio_mode(GPIO11_3_6MHz_MD); -} static void clk_gpio27_disable(struct clk *clk) { + /* FIXME: disable clock */ } -static const struct clkops clk_gpio27_ops = { - .enable = clk_gpio27_enable, - .disable= clk_gpio27_disable, -}; - - -void clk_cken_enable(struct clk *clk) +int clk_cken_enable(struct clk *clk) { - CKEN |= 1 << clk->cken; + int cken = ((struct clk_cken_priv *)clk->priv)->cken; + CKEN |= 1 << cken; + + return 0; } void clk_cken_disable(struct clk *clk) { - CKEN &= ~(1 << clk->cken); + int cken = ((struct clk_cken_priv *)clk->priv)->cken; + CKEN &= ~(1 << cken); } -const struct clkops clk_cken_ops = { - .enable = clk_cken_enable, - .disable= clk_cken_disable, -}; - static struct clk common_clks[] = { { .name = "GPIO27_CLK", - .ops= _gpio27_ops, .rate = 3686400, + .owner = THIS_MODULE, + .enable = clk_gpio27_enable, + .disable= clk_gpio27_disable, }, }; -void clks_register(struct clk *clks, size_t num) -{ - int i; - - mutex_lock(_mutex); - for (i = 0; i < num; i++) - list_add([i].node, ); - mutex_unlock(_mutex); -} - static int __init clk_init(void) { clks_register(common_clks, ARRAY_SIZE(common_clks)); diff --git a/arch/arm/mach-pxa/clock.h b/arch/arm/mach-pxa/clock.h index bc6b77e..5d0d067 100644 --- a/arch/arm/mach-pxa/clock.h +++ b/arch/arm/mach-pxa/clock.h @@ -1,43 +1,47 @@ -struct clk; +#include +#include -struct clkops { - void(*enable)(struct clk *); - void(*disable)(struct clk *); - unsigned long (*getrate)(struct clk *); +struct clk_cken_priv { + unsigned intcken; }; -struct clk { - struct list_headnode; - const char *name; - struct device *dev; - const struct clkops *ops; - unsigned long rate; - unsigned intcken; - unsigned int
[PATCH 3/5] Use clocklib for ARM pxa sub-arch.
Signed-off-by: Dmitry Baryshkov [EMAIL PROTECTED] --- arch/arm/Kconfig |1 + arch/arm/mach-pxa/clock.c | 108 -- arch/arm/mach-pxa/clock.h | 58 +++--- arch/arm/mach-pxa/pxa25x.c | 187 +-- arch/arm/mach-pxa/pxa27x.c | 61 --- arch/arm/mach-pxa/pxa3xx.c | 91 - 6 files changed, 292 insertions(+), 214 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 4b1a8e3..45c1790 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -362,6 +362,7 @@ config ARCH_PXA select GENERIC_TIME select GENERIC_CLOCKEVENTS select TICK_ONESHOT + select HAVE_CLOCK_LIB help Support for Intel/Marvell's PXA2xx/PXA3xx processor line. diff --git a/arch/arm/mach-pxa/clock.c b/arch/arm/mach-pxa/clock.c index 83ef5ec..3296b02 100644 --- a/arch/arm/mach-pxa/clock.c +++ b/arch/arm/mach-pxa/clock.c @@ -8,6 +8,7 @@ #include linux/err.h #include linux/string.h #include linux/clk.h +#include linux/clklib.h #include linux/spinlock.h #include linux/platform_device.h #include linux/delay.h @@ -19,123 +20,42 @@ #include generic.h #include clock.h -static LIST_HEAD(clocks); -static DEFINE_MUTEX(clocks_mutex); -static DEFINE_SPINLOCK(clocks_lock); - -struct clk *clk_get(struct device *dev, const char *id) -{ - struct clk *p, *clk = ERR_PTR(-ENOENT); - - mutex_lock(clocks_mutex); - list_for_each_entry(p, clocks, node) { - if (strcmp(id, p-name) == 0 - (p-dev == NULL || p-dev == dev)) { - clk = p; - break; - } - } - mutex_unlock(clocks_mutex); - - return clk; -} -EXPORT_SYMBOL(clk_get); - -void clk_put(struct clk *clk) +static int clk_gpio27_enable(struct clk *clk) { -} -EXPORT_SYMBOL(clk_put); - -int clk_enable(struct clk *clk) -{ - unsigned long flags; - - spin_lock_irqsave(clocks_lock, flags); - if (clk-enabled++ == 0) - clk-ops-enable(clk); - spin_unlock_irqrestore(clocks_lock, flags); - - if (clk-delay) - udelay(clk-delay); + pxa_gpio_mode(GPIO11_3_6MHz_MD); return 0; } -EXPORT_SYMBOL(clk_enable); - -void clk_disable(struct clk *clk) -{ - unsigned long flags; - - WARN_ON(clk-enabled == 0); - - spin_lock_irqsave(clocks_lock, flags); - if (--clk-enabled == 0) - clk-ops-disable(clk); - spin_unlock_irqrestore(clocks_lock, flags); -} -EXPORT_SYMBOL(clk_disable); - -unsigned long clk_get_rate(struct clk *clk) -{ - unsigned long rate; - - rate = clk-rate; - if (clk-ops-getrate) - rate = clk-ops-getrate(clk); - - return rate; -} -EXPORT_SYMBOL(clk_get_rate); - - -static void clk_gpio27_enable(struct clk *clk) -{ - pxa_gpio_mode(GPIO11_3_6MHz_MD); -} static void clk_gpio27_disable(struct clk *clk) { + /* FIXME: disable clock */ } -static const struct clkops clk_gpio27_ops = { - .enable = clk_gpio27_enable, - .disable= clk_gpio27_disable, -}; - - -void clk_cken_enable(struct clk *clk) +int clk_cken_enable(struct clk *clk) { - CKEN |= 1 clk-cken; + int cken = ((struct clk_cken_priv *)clk-priv)-cken; + CKEN |= 1 cken; + + return 0; } void clk_cken_disable(struct clk *clk) { - CKEN = ~(1 clk-cken); + int cken = ((struct clk_cken_priv *)clk-priv)-cken; + CKEN = ~(1 cken); } -const struct clkops clk_cken_ops = { - .enable = clk_cken_enable, - .disable= clk_cken_disable, -}; - static struct clk common_clks[] = { { .name = GPIO27_CLK, - .ops= clk_gpio27_ops, .rate = 3686400, + .owner = THIS_MODULE, + .enable = clk_gpio27_enable, + .disable= clk_gpio27_disable, }, }; -void clks_register(struct clk *clks, size_t num) -{ - int i; - - mutex_lock(clocks_mutex); - for (i = 0; i num; i++) - list_add(clks[i].node, clocks); - mutex_unlock(clocks_mutex); -} - static int __init clk_init(void) { clks_register(common_clks, ARRAY_SIZE(common_clks)); diff --git a/arch/arm/mach-pxa/clock.h b/arch/arm/mach-pxa/clock.h index bc6b77e..5d0d067 100644 --- a/arch/arm/mach-pxa/clock.h +++ b/arch/arm/mach-pxa/clock.h @@ -1,43 +1,47 @@ -struct clk; +#include linux/clklib.h +#include linux/seq_file.h -struct clkops { - void(*enable)(struct clk *); - void(*disable)(struct clk *); - unsigned long (*getrate)(struct clk *); +struct clk_cken_priv { + unsigned intcken; }; -struct clk { - struct list_headnode; - const char *name; - struct device