[ramips] add patches for v3.8
[openwrt/svn-archive/archive.git] / target / linux / ramips / patches-3.8 / 0005-MIPS-ralink-adds-clkdev-code.patch
1 From 3f0a06b0368d25608841843e9d65a7289ad9f14a Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sun, 20 Jan 2013 22:01:29 +0100
4 Subject: [PATCH 05/14] MIPS: ralink: adds clkdev code
5
6 These SoCs have a limited number of fixed rate clocks. Add support for the
7 clk and clkdev api.
8
9 Signed-off-by: John Crispin <blogic@openwrt.org>
10 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
11 Patchwork: http://patchwork.linux-mips.org/patch/4894/
12 ---
13 arch/mips/ralink/clk.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
14 1 file changed, 72 insertions(+)
15 create mode 100644 arch/mips/ralink/clk.c
16
17 diff --git a/arch/mips/ralink/clk.c b/arch/mips/ralink/clk.c
18 new file mode 100644
19 index 0000000..8dfa22f
20 --- /dev/null
21 +++ b/arch/mips/ralink/clk.c
22 @@ -0,0 +1,72 @@
23 +/*
24 + * This program is free software; you can redistribute it and/or modify it
25 + * under the terms of the GNU General Public License version 2 as published
26 + * by the Free Software Foundation.
27 + *
28 + * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
29 + * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
30 + */
31 +
32 +#include <linux/kernel.h>
33 +#include <linux/module.h>
34 +#include <linux/clkdev.h>
35 +#include <linux/clk.h>
36 +
37 +#include <asm/time.h>
38 +
39 +#include "common.h"
40 +
41 +struct clk {
42 + struct clk_lookup cl;
43 + unsigned long rate;
44 +};
45 +
46 +void ralink_clk_add(const char *dev, unsigned long rate)
47 +{
48 + struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
49 +
50 + if (!clk)
51 + panic("failed to add clock\n");
52 +
53 + clk->cl.dev_id = dev;
54 + clk->cl.clk = clk;
55 +
56 + clk->rate = rate;
57 +
58 + clkdev_add(&clk->cl);
59 +}
60 +
61 +/*
62 + * Linux clock API
63 + */
64 +int clk_enable(struct clk *clk)
65 +{
66 + return 0;
67 +}
68 +EXPORT_SYMBOL_GPL(clk_enable);
69 +
70 +void clk_disable(struct clk *clk)
71 +{
72 +}
73 +EXPORT_SYMBOL_GPL(clk_disable);
74 +
75 +unsigned long clk_get_rate(struct clk *clk)
76 +{
77 + return clk->rate;
78 +}
79 +EXPORT_SYMBOL_GPL(clk_get_rate);
80 +
81 +void __init plat_time_init(void)
82 +{
83 + struct clk *clk;
84 +
85 + ralink_of_remap();
86 +
87 + ralink_clk_init();
88 + clk = clk_get_sys("cpu", NULL);
89 + if (IS_ERR(clk))
90 + panic("unable to get CPU clock, err=%ld", PTR_ERR(clk));
91 + pr_info("CPU Clock: %ldMHz\n", clk_get_rate(clk) / 1000000);
92 + mips_hpt_frequency = clk_get_rate(clk) / 2;
93 + clk_put(clk);
94 +}
95 --
96 1.7.10.4
97