merge of '178eac00dc5aa8338d42e8e203633bec7817bbf6'
[vuplus_openembedded] / packages / linux / linux-rp-2.6.24 / tosa / 0043-Use-clocklib-for-sa1100-sub-arch.patch
1 From 3932e0f5c4c05200c030b60606ed2eb83550f4bb Mon Sep 17 00:00:00 2001
2 From: Dmitry Baryshkov <dbaryshkov@gmail.com>
3 Date: Mon, 4 Feb 2008 03:01:04 +0300
4 Subject: [PATCH 43/64] Use clocklib for sa1100 sub-arch.
5
6 Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
7 ---
8  arch/arm/Kconfig             |    1 +
9  arch/arm/mach-sa1100/clock.c |   95 ++---------------------------------------
10  2 files changed, 6 insertions(+), 90 deletions(-)
11
12 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
13 index 47f3c73..fa47201 100644
14 --- a/arch/arm/Kconfig
15 +++ b/arch/arm/Kconfig
16 @@ -370,6 +370,7 @@ config ARCH_SA1100
17         select ARCH_MTD_XIP
18         select GENERIC_GPIO
19         select GENERIC_TIME
20 +       select HAVE_CLOCK_LIB
21         help
22           Support for StrongARM 11x0 based boards.
23  
24 diff --git a/arch/arm/mach-sa1100/clock.c b/arch/arm/mach-sa1100/clock.c
25 index fc97fe5..6b3cc51 100644
26 --- a/arch/arm/mach-sa1100/clock.c
27 +++ b/arch/arm/mach-sa1100/clock.c
28 @@ -8,83 +8,13 @@
29  #include <linux/err.h>
30  #include <linux/string.h>
31  #include <linux/clk.h>
32 +#include <linux/clklib.h>
33  #include <linux/spinlock.h>
34  #include <linux/mutex.h>
35  
36  #include <asm/hardware.h>
37  
38 -/*
39 - * Very simple clock implementation - we only have one clock to
40 - * deal with at the moment, so we only match using the "name".
41 - */
42 -struct clk {
43 -       struct list_head        node;
44 -       unsigned long           rate;
45 -       const char              *name;
46 -       unsigned int            enabled;
47 -       void                    (*enable)(void);
48 -       void                    (*disable)(void);
49 -};
50 -
51 -static LIST_HEAD(clocks);
52 -static DEFINE_MUTEX(clocks_mutex);
53 -static DEFINE_SPINLOCK(clocks_lock);
54 -
55 -struct clk *clk_get(struct device *dev, const char *id)
56 -{
57 -       struct clk *p, *clk = ERR_PTR(-ENOENT);
58 -
59 -       mutex_lock(&clocks_mutex);
60 -       list_for_each_entry(p, &clocks, node) {
61 -               if (strcmp(id, p->name) == 0) {
62 -                       clk = p;
63 -                       break;
64 -               }
65 -       }
66 -       mutex_unlock(&clocks_mutex);
67 -
68 -       return clk;
69 -}
70 -EXPORT_SYMBOL(clk_get);
71 -
72 -void clk_put(struct clk *clk)
73 -{
74 -}
75 -EXPORT_SYMBOL(clk_put);
76 -
77 -int clk_enable(struct clk *clk)
78 -{
79 -       unsigned long flags;
80 -
81 -       spin_lock_irqsave(&clocks_lock, flags);
82 -       if (clk->enabled++ == 0)
83 -               clk->enable();
84 -       spin_unlock_irqrestore(&clocks_lock, flags);
85 -       return 0;
86 -}
87 -EXPORT_SYMBOL(clk_enable);
88 -
89 -void clk_disable(struct clk *clk)
90 -{
91 -       unsigned long flags;
92 -
93 -       WARN_ON(clk->enabled == 0);
94 -
95 -       spin_lock_irqsave(&clocks_lock, flags);
96 -       if (--clk->enabled == 0)
97 -               clk->disable();
98 -       spin_unlock_irqrestore(&clocks_lock, flags);
99 -}
100 -EXPORT_SYMBOL(clk_disable);
101 -
102 -unsigned long clk_get_rate(struct clk *clk)
103 -{
104 -       return clk->rate;
105 -}
106 -EXPORT_SYMBOL(clk_get_rate);
107 -
108 -
109 -static void clk_gpio27_enable(void)
110 +static int clk_gpio27_enable(struct clk *clk)
111  {
112         /*
113          * First, set up the 3.6864MHz clock on GPIO 27 for the SA-1111:
114 @@ -93,9 +23,11 @@ static void clk_gpio27_enable(void)
115         GAFR |= GPIO_32_768kHz;
116         GPDR |= GPIO_32_768kHz;
117         TUCR = TUCR_3_6864MHz;
118 +
119 +       return 0;
120  }
121  
122 -static void clk_gpio27_disable(void)
123 +static void clk_gpio27_disable(struct clk *clk)
124  {
125         TUCR = 0;
126         GPDR &= ~GPIO_32_768kHz;
127 @@ -109,23 +41,6 @@ static struct clk clk_gpio27 = {
128         .disable        = clk_gpio27_disable,
129  };
130  
131 -int clk_register(struct clk *clk)
132 -{
133 -       mutex_lock(&clocks_mutex);
134 -       list_add(&clk->node, &clocks);
135 -       mutex_unlock(&clocks_mutex);
136 -       return 0;
137 -}
138 -EXPORT_SYMBOL(clk_register);
139 -
140 -void clk_unregister(struct clk *clk)
141 -{
142 -       mutex_lock(&clocks_mutex);
143 -       list_del(&clk->node);
144 -       mutex_unlock(&clocks_mutex);
145 -}
146 -EXPORT_SYMBOL(clk_unregister);
147 -
148  static int __init clk_init(void)
149  {
150         clk_register(&clk_gpio27);
151 -- 
152 1.5.3.8
153