[Tinyx-devel] [PATCH] ARM: CLOCK: Fixing extern declarations and improve clock struct.
Status: Planning
Brought to you by:
davidcohen
|
From: David C. <da...@gm...> - 2008-01-11 02:50:13
|
Changing from extern to static some clock functions.
Fixing the clock's child list vector.
Adding rate_list.
Small fixes on generic clock functions.
Signed-off-by: David Cohen <da...@gm...>
---
arch/arm7/mach-lpc21xx/clock.c | 28 +++++++---------------------
arch/arm7/mach-lpc21xx/clock.h | 28 +++++++++++++++++++++++++---
arch/common/clock.c | 26 +++++++++++++++++++++-----
include/asm-generic/clock.h | 15 ++++++++++-----
4 files changed, 63 insertions(+), 34 deletions(-)
diff --git a/arch/arm7/mach-lpc21xx/clock.c b/arch/arm7/mach-lpc21xx/clock.c
index 61b00e3..19b2abb 100644
--- a/arch/arm7/mach-lpc21xx/clock.c
+++ b/arch/arm7/mach-lpc21xx/clock.c
@@ -21,35 +21,21 @@
#include "clock.h"
-unsigned int cclk_set_rate(struct clock *clk, unsigned int rate)
+static unsigned int cclk_set_rate(struct clock *clk, unsigned int rate)
{
return 0;
}
-unsigned int pclk_set_rate(struct clock *clk, unsigned int rate)
+static void cclk_init(struct clock *clk)
{
- return 0;
}
-void pclk_propagate(struct clock *clk, struct clock *parent)
+static unsigned int pclk_set_rate(struct clock *clk, unsigned int rate)
{
+ return 0;
}
-static struct clock pclk = {
- .id = PCLK,
- .num_child = 0,
- .child = NULL,
- .set_rate = pclk_set_rate,
- .propagate = pclk_propagate,
-};
-
-static struct clock cclk = {
- .id = CCLK,
- .num_child = 1,
- .child = &pclk,
- .set_rate = cclk_set_rate,
- .propagate = NULL,
-};
-
-struct clock *lpc2xxx_clk_list[] = { &cclk, &pclk };
+static void pclk_propagate(struct clock *clk, struct clock *parent)
+{
+}
diff --git a/arch/arm7/mach-lpc21xx/clock.h b/arch/arm7/mach-lpc21xx/clock.h
index 214fd62..420ac16 100644
--- a/arch/arm7/mach-lpc21xx/clock.h
+++ b/arch/arm7/mach-lpc21xx/clock.h
@@ -25,8 +25,30 @@
#include <asm/arch-lpc2xxx/clock.h>
#include <tinyx/kernel.h>
-extern unsigned int cclk_set_rate(struct clock *clk, unsigned int rate);
-extern unsigned int pclk_set_rate(struct clock *clk, unsigned int rate);
-extern void pclk_propagate(struct clock *clk, struct clock *parent);
+static unsigned int cclk_set_rate(struct clock *clk, unsigned int rate);
+static void cclk_init(struct clock *clk);
+static unsigned int pclk_set_rate(struct clock *clk, unsigned int rate);
+static void pclk_propagate(struct clock *clk, struct clock *parent);
+
+static struct clock pclk = {
+ .id = PCLK,
+ .num_child = 0,
+ .child_list = NULL,
+ .set_rate = pclk_set_rate,
+ .propagate = pclk_propagate,
+};
+
+static struct clock cclk = {
+ .id = CCLK,
+ .num_child = 1,
+ .child_list = &pclk,
+ .set_rate = cclk_set_rate,
+ .propagate = NULL,
+ .init = cclk_init,
+ .init_rate = 15000000,
+ .rate_list = { 15000000, 30000000, 45000000, 60000000, 0 },
+};
+
+struct clock *lpc2xxx_clk_list[] = { &cclk, &pclk };
#endif /* __ARCH_MACH_LPC2XXX_CLOCK_H */
diff --git a/arch/common/clock.c b/arch/common/clock.c
index d92f09e..a7cc66f 100644
--- a/arch/common/clock.c
+++ b/arch/common/clock.c
@@ -29,6 +29,12 @@ void clk_set_list(struct clock *list, unsigned int num)
{
clk_list = list;
num_clk = num;
+
+ while (num--) {
+ if (list->init)
+ (*list->init)(list);
+ list++;
+ }
}
void clk_propagate(struct clock *clk, struct clock *parent)
@@ -43,7 +49,7 @@ void clk_propagate(struct clock *clk, struct clock *parent)
(*clk->propagate)(clk, parent);
c = clk->num_child;
- child = clk->child;
+ child = clk->child_list;
/* Revisit: fix recursive while */
while (c--) {
@@ -52,20 +58,30 @@ void clk_propagate(struct clock *clk, struct clock *parent)
}
}
-unsigned int clk_set_rate(struct clock *clk, unsigned int rate)
+unsigned int clk_set_rate(struct clock *clk, unsigned int clk_rate)
{
- unsigned int clk_rate = rate;
unsigned int c;
+ unsigned int *rate_list;
struct clock *child;
if (clk == NULL)
return 0;
+ rate_list = clk->rate_list;
+ while (*rate_list) {
+ if (clk_rate >= (*rate_list)++) {
+ clk_rate = *rate_list;
+ break;
+ }
+ }
+ if (!(*rate_list))
+ clk_rate = 0;
+
if (clk->set_rate)
- clk_rate = (*clk->set_rate)(clk, rate);
+ clk_rate = (*clk->set_rate)(clk, clk_rate);
c = clk->num_child;
- child = clk->child;
+ child = clk->child_list;
while (c--) {
clk_propagate(child, clk);
child++;
diff --git a/include/asm-generic/clock.h b/include/asm-generic/clock.h
index 4ac8e7c..43f33f4 100644
--- a/include/asm-generic/clock.h
+++ b/include/asm-generic/clock.h
@@ -25,17 +25,22 @@
struct clock {
unsigned int id;
unsigned int rate;
- struct clock *parent;
- struct clock *child;
+ unsigned int flags;
unsigned int num_child;
+ struct clock *child_list;
+
unsigned int (*set_rate) (struct clock *clk, unsigned int rate);
void (*propagate) (struct clock *clk, struct clock *parent);
+ void (*init) (struct clock *clk);
+
+ unsigned int init_rate;
+ unsigned int rate_list[];
};
#define clk_get_rate(clk) (clk)->rate
-extern void clk_set_list(struct clock *list, unsigned int num);
-extern void clk_propagate(struct clock *clk, struct clock *parent);
-extern unsigned int clk_set_rate(struct clock *clk, unsigned int rate);
+void clk_set_list(struct clock *list, unsigned int num);
+void clk_propagate(struct clock *clk, struct clock *parent);
+unsigned int clk_set_rate(struct clock *clk, unsigned int rate);
#endif /* __ASM_GENERIC_CLOCK_H */
--
1.5.3.7
|