blob: 50f887dda56550bde11bc85101000ca224a4e75a [file] [log] [blame]
Paul Mundt36ddf312006-01-16 22:14:17 -08001/*
2 * arch/sh/kernel/cpu/clock.c - SuperH clock framework
3 *
Paul Mundtb1f6cfe2009-05-12 04:27:43 +09004 * Copyright (C) 2005 - 2009 Paul Mundt
Paul Mundt36ddf312006-01-16 22:14:17 -08005 *
6 * This clock framework is derived from the OMAP version by:
7 *
Paul Mundtb1f6cfe2009-05-12 04:27:43 +09008 * Copyright (C) 2004 - 2008 Nokia Corporation
Paul Mundt36ddf312006-01-16 22:14:17 -08009 * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
10 *
Paul Mundt1d118562006-12-01 13:15:14 +090011 * Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com>
12 *
Paul Mundt36ddf312006-01-16 22:14:17 -080013 * This file is subject to the terms and conditions of the GNU General Public
14 * License. See the file "COPYING" in the main directory of this archive
15 * for more details.
16 */
17#include <linux/kernel.h>
18#include <linux/init.h>
Paul Mundt51a50062010-03-08 21:45:19 +090019#include <linux/clk.h>
Paul Mundt36ddf312006-01-16 22:14:17 -080020#include <asm/clock.h>
Paul Mundt253b0882009-05-13 17:38:11 +090021#include <asm/machvec.h>
Paul Mundt36ddf312006-01-16 22:14:17 -080022
Paul Mundt36ddf312006-01-16 22:14:17 -080023int __init clk_init(void)
24{
Paul Mundt253b0882009-05-13 17:38:11 +090025 int ret;
Paul Mundt36ddf312006-01-16 22:14:17 -080026
Paul Mundt253b0882009-05-13 17:38:11 +090027 ret = arch_clk_init();
28 if (unlikely(ret)) {
29 pr_err("%s: CPU clock registration failed.\n", __func__);
30 return ret;
Paul Mundt36ddf312006-01-16 22:14:17 -080031 }
32
Paul Mundt253b0882009-05-13 17:38:11 +090033 if (sh_mv.mv_clk_init) {
34 ret = sh_mv.mv_clk_init();
35 if (unlikely(ret)) {
36 pr_err("%s: machvec clock initialization failed.\n",
37 __func__);
38 return ret;
39 }
40 }
dmitry pervushindfbbbe92007-05-15 08:42:22 +090041
Paul Mundt36ddf312006-01-16 22:14:17 -080042 /* Kick the child clocks.. */
Paul Mundtb1f6cfe2009-05-12 04:27:43 +090043 recalculate_root_clocks();
Paul Mundt36ddf312006-01-16 22:14:17 -080044
Paul Mundt4ff29ff2009-05-12 05:14:53 +090045 /* Enable the necessary init clocks */
46 clk_enable_init_clocks();
47
Paul Mundt36ddf312006-01-16 22:14:17 -080048 return ret;
49}
50
Paul Mundtcedcf332009-05-13 21:51:28 +090051/*
Magnus Damm8b5ee112010-05-11 13:29:25 +000052 * Returns a clock. Note that we first try to use device id on the bus
53 * and clock name. If this fails, we try to use clock name only.
Paul Mundtcedcf332009-05-13 21:51:28 +090054 */
Magnus Damm8b5ee112010-05-11 13:29:25 +000055struct clk *clk_get(struct device *dev, const char *con_id)
Paul Mundtcedcf332009-05-13 21:51:28 +090056{
Magnus Damm8b5ee112010-05-11 13:29:25 +000057 const char *dev_id = dev ? dev_name(dev) : NULL;
Paul Mundtcedcf332009-05-13 21:51:28 +090058
Magnus Damm8b5ee112010-05-11 13:29:25 +000059 return clk_get_sys(dev_id, con_id);
Paul Mundtcedcf332009-05-13 21:51:28 +090060}
Magnus Damm8b5ee112010-05-11 13:29:25 +000061EXPORT_SYMBOL_GPL(clk_get);
Paul Mundtcedcf332009-05-13 21:51:28 +090062
Magnus Damm8b5ee112010-05-11 13:29:25 +000063void clk_put(struct clk *clk)
Paul Mundtcedcf332009-05-13 21:51:28 +090064{
Paul Mundt36ddf312006-01-16 22:14:17 -080065}
Magnus Damm8b5ee112010-05-11 13:29:25 +000066EXPORT_SYMBOL_GPL(clk_put);
Paul Mundtcedcf332009-05-13 21:51:28 +090067