Merge tag 'usb-5.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
[linux/fpc-iii.git] / arch / mips / ralink / clk.c
blob2f9d5acb38eaa497fa20a44b146ee5c1f30b168b
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
4 * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2013 John Crispin <john@phrozen.org>
6 */
8 #include <linux/kernel.h>
9 #include <linux/init.h>
10 #include <linux/export.h>
11 #include <linux/clkdev.h>
12 #include <linux/clk.h>
14 #include <asm/time.h>
16 #include "common.h"
18 struct clk {
19 struct clk_lookup cl;
20 unsigned long rate;
23 void ralink_clk_add(const char *dev, unsigned long rate)
25 struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
27 if (!clk)
28 panic("failed to add clock");
30 clk->cl.dev_id = dev;
31 clk->cl.clk = clk;
33 clk->rate = rate;
35 clkdev_add(&clk->cl);
39 * Linux clock API
41 int clk_enable(struct clk *clk)
43 return 0;
45 EXPORT_SYMBOL_GPL(clk_enable);
47 void clk_disable(struct clk *clk)
50 EXPORT_SYMBOL_GPL(clk_disable);
52 unsigned long clk_get_rate(struct clk *clk)
54 if (!clk)
55 return 0;
57 return clk->rate;
59 EXPORT_SYMBOL_GPL(clk_get_rate);
61 int clk_set_rate(struct clk *clk, unsigned long rate)
63 return -1;
65 EXPORT_SYMBOL_GPL(clk_set_rate);
67 long clk_round_rate(struct clk *clk, unsigned long rate)
69 return -1;
71 EXPORT_SYMBOL_GPL(clk_round_rate);
73 void __init plat_time_init(void)
75 struct clk *clk;
77 ralink_of_remap();
79 ralink_clk_init();
80 clk = clk_get_sys("cpu", NULL);
81 if (IS_ERR(clk))
82 panic("unable to get CPU clock, err=%ld", PTR_ERR(clk));
83 pr_info("CPU Clock: %ldMHz\n", clk_get_rate(clk) / 1000000);
84 mips_hpt_frequency = clk_get_rate(clk) / 2;
85 clk_put(clk);
86 timer_probe();