summaryrefslogtreecommitdiff
path: root/target/linux/adm8668/files/arch/mips
diff options
context:
space:
mode:
authorflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-12-06 22:39:52 +0000
committerflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-12-06 22:39:52 +0000
commita2565ae2b41d5f8cc90a037bce52501101a1773a (patch)
tree4dae5be6f74ed4f4a5688596773d97ea4d91a7ca /target/linux/adm8668/files/arch/mips
parent0fb7b81e9ef0e7bf1dcf54d43c82ddfc13b02ef5 (diff)
[adm8668] provide a system clock to be used by the MIPS timer
Signed-off-by: Florian Fainelli <florian@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34550 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/adm8668/files/arch/mips')
-rw-r--r--target/linux/adm8668/files/arch/mips/adm8668/Makefile2
-rw-r--r--target/linux/adm8668/files/arch/mips/adm8668/clock.c24
-rw-r--r--target/linux/adm8668/files/arch/mips/adm8668/time.c13
-rw-r--r--target/linux/adm8668/files/arch/mips/include/asm/mach-adm8668/adm8668.h2
4 files changed, 33 insertions, 8 deletions
diff --git a/target/linux/adm8668/files/arch/mips/adm8668/Makefile b/target/linux/adm8668/files/arch/mips/adm8668/Makefile
index ed45666194..aff789c7d2 100644
--- a/target/linux/adm8668/files/arch/mips/adm8668/Makefile
+++ b/target/linux/adm8668/files/arch/mips/adm8668/Makefile
@@ -3,5 +3,5 @@
#
obj-y := irq.o pci.o prom.o platform.o proc.o \
- setup.o time.o early_printk.o clock.o \
+ setup.o clock.o time.o early_printk.o \
net_core.o net_intr.o
diff --git a/target/linux/adm8668/files/arch/mips/adm8668/clock.c b/target/linux/adm8668/files/arch/mips/adm8668/clock.c
index 96d139e177..6c839a2474 100644
--- a/target/linux/adm8668/files/arch/mips/adm8668/clock.c
+++ b/target/linux/adm8668/files/arch/mips/adm8668/clock.c
@@ -22,12 +22,19 @@ static struct clk uart_clk = {
.rate = ADM8668_UARTCLK_FREQ,
};
+static struct clk sys_clk;
+
struct clk *clk_get(struct device *dev, const char *id)
{
- const char *name = dev_name(dev);
+ const char *lookup = id;
+
+ if (dev)
+ lookup = dev_name(dev);
- if (!strcmp(name, "apb:uart0"))
+ if (!strcmp(lookup, "apb:uart0"))
return &uart_clk;
+ if (!strcmp(lookup, "sys"))
+ return &sys_clk;
return ERR_PTR(-ENOENT);
}
@@ -54,3 +61,16 @@ void clk_put(struct clk *clk)
{
}
EXPORT_SYMBOL(clk_put);
+
+void __init adm8668_init_clocks(void)
+{
+ u32 adj;
+
+ /* adjustable clock selection
+ * CR3 bit 14~11, 0000 -> 175MHz, 0001 -> 180MHz, etc...
+ */
+ adj = (ADM8668_CONFIG_REG(ADM8668_CR3) >> 11) & 0xf;
+ sys_clk.rate = SYS_CLOCK + adj * 5000000;
+
+ pr_info("ADM8668 CPU clock: %lu MHz\n", sys_clk.rate / 1000000);
+}
diff --git a/target/linux/adm8668/files/arch/mips/adm8668/time.c b/target/linux/adm8668/files/arch/mips/adm8668/time.c
index 047bccdedd..87bdd66965 100644
--- a/target/linux/adm8668/files/arch/mips/adm8668/time.c
+++ b/target/linux/adm8668/files/arch/mips/adm8668/time.c
@@ -1,17 +1,20 @@
#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/clk.h>
#include <asm/time.h>
#include <adm8668.h>
void __init plat_time_init(void)
{
- int adj = (ADM8668_CONFIG_REG(ADM8668_CR3) >> 11) & 0xf;
+ struct clk *sys_clk;
- /* adjustable clock selection
- CR3 bit 14~11, 0000 -> 175MHz, 0001 -> 180MHz, etc... */
+ adm8668_init_clocks();
- mips_hpt_frequency = (SYS_CLOCK + adj * 5000000) / 2;
- printk("ADM8668 CPU clock: %d MHz\n", 2*mips_hpt_frequency / 1000000);
+ sys_clk = clk_get(NULL, "sys");
+ if (IS_ERR(sys_clk))
+ panic("unable to get system clock\n");
+
+ mips_hpt_frequency = clk_get_rate(sys_clk) / 2;
}
diff --git a/target/linux/adm8668/files/arch/mips/include/asm/mach-adm8668/adm8668.h b/target/linux/adm8668/files/arch/mips/include/asm/mach-adm8668/adm8668.h
index 1f7ab72cad..bb4466c522 100644
--- a/target/linux/adm8668/files/arch/mips/include/asm/mach-adm8668/adm8668.h
+++ b/target/linux/adm8668/files/arch/mips/include/asm/mach-adm8668/adm8668.h
@@ -109,4 +109,6 @@
#define CRGPIO_TOGGLE(num) \
ADM8668_CONFIG_REG(CRGPIO_REG) ^= (1 << (6 + num))
+void adm8668_init_clocks(void);
+
#endif /* __ADM8668_H__ */