[RFC 1/3] S3C244X: armclk set_rate/round_rate using FCLK or HCLK
Rask Ingemann Lambertsen
rask at sygehus.dk
Wed Apr 1 02:43:09 CEST 2009
This patch just makes use of the two easily available clock sources.
arch/arm/plat-s3c24xx/s3c244x-clock.c | 33 +++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/arch/arm/plat-s3c24xx/s3c244x-clock.c b/arch/arm/plat-s3c24xx/s3c244x-clock.c
index dde41f1..65437c4 100644
--- a/arch/arm/plat-s3c24xx/s3c244x-clock.c
+++ b/arch/arm/plat-s3c24xx/s3c244x-clock.c
@@ -65,9 +65,42 @@ static int s3c2440_setparent_armclk(struct clk *clk, struct clk *parent)
return 0;
}
+static int s3c2440_setrate_armclk(struct clk *clk, unsigned long rate)
+{
+ struct clk *new_parent;
+
+ if (rate == clk_get_rate(&clk_h))
+ new_parent = &clk_h;
+ else if (rate == clk_get_rate(&clk_f))
+ new_parent = &clk_f;
+ else
+ return -EINVAL;
+
+ if (new_parent != clk->parent)
+ /* Lock already held, don't use clk_set_parent(). */
+ return s3c2440_setparent_armclk(clk, new_parent);
+
+ return 0;
+}
+
+static unsigned long s3c2440_round_rate(struct clk *clk, unsigned long rate)
+{
+ unsigned long f_rate = clk_get_rate(&clk_f);
+ unsigned long h_rate = clk_get_rate(&clk_h);
+
+ pr_debug("s3c440_round_rate(%lu): %lu and %lu available.\n",
+ rate, h_rate, f_rate);
+ if (rate < (h_rate + f_rate) / 2)
+ return h_rate;
+ else
+ return f_rate;
+}
+
static struct clk clk_arm = {
.name = "armclk",
.id = -1,
+ .set_rate = s3c2440_setrate_armclk,
+ .round_rate = s3c2440_round_rate,
.set_parent = s3c2440_setparent_armclk,
};
--
Rask Ingemann Lambertsen
Danish law requires addresses in e-mail to be logged and stored for a year
More information about the openmoko-kernel
mailing list