blob: 7a2f5ad07bab5b566ae7e307fc0fea64383dc3a0 [file] [log] [blame]
Paul Walmsleyd8a94452009-12-08 16:21:29 -07001/*
Paul Walmsleyda4d2902010-01-26 20:13:10 -07002 * clock2xxx.c - OMAP2xxx-specific clock integration code
Paul Walmsleyd8a94452009-12-08 16:21:29 -07003 *
Paul Walmsleyda4d2902010-01-26 20:13:10 -07004 * Copyright (C) 2005-2008 Texas Instruments, Inc.
5 * Copyright (C) 2004-2010 Nokia Corporation
Paul Walmsleyd8a94452009-12-08 16:21:29 -07006 *
Paul Walmsleyda4d2902010-01-26 20:13:10 -07007 * Contacts:
8 * Richard Woodruff <r-woodruff2@ti.com>
9 * Paul Walmsley
Paul Walmsleyd8a94452009-12-08 16:21:29 -070010 *
Paul Walmsleyda4d2902010-01-26 20:13:10 -070011 * Based on earlier work by Tuukka Tikkanen, Tony Lindgren,
12 * Gordon McNutt and RidgeRun, Inc.
Paul Walmsleyd8a94452009-12-08 16:21:29 -070013 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
17 */
18#undef DEBUG
19
Paul Walmsleyd8a94452009-12-08 16:21:29 -070020#include <linux/kernel.h>
Paul Walmsleyd8a94452009-12-08 16:21:29 -070021#include <linux/errno.h>
Paul Walmsleyd8a94452009-12-08 16:21:29 -070022#include <linux/clk.h>
23#include <linux/io.h>
Paul Walmsleyd8a94452009-12-08 16:21:29 -070024
25#include <plat/clock.h>
Paul Walmsleyd8a94452009-12-08 16:21:29 -070026
Paul Walmsleyd8a94452009-12-08 16:21:29 -070027#include "clock.h"
28#include "clock2xxx.h"
Paul Walmsleyd8a94452009-12-08 16:21:29 -070029#include "cm.h"
30#include "cm-regbits-24xx.h"
31
Paul Walmsleyd8a94452009-12-08 16:21:29 -070032struct clk *vclk, *sclk, *dclk;
33
Paul Walmsleyda4d2902010-01-26 20:13:10 -070034/*
Paul Walmsleyd8a94452009-12-08 16:21:29 -070035 * Omap24xx specific clock functions
Paul Walmsleyda4d2902010-01-26 20:13:10 -070036 */
Paul Walmsleyd8a94452009-12-08 16:21:29 -070037
Paul Walmsleyd8a94452009-12-08 16:21:29 -070038/*
39 * Set clocks for bypass mode for reboot to work.
40 */
Paul Walmsleyfeec1272010-01-26 20:13:11 -070041void omap2xxx_clk_prepare_for_reboot(void)
Paul Walmsleyd8a94452009-12-08 16:21:29 -070042{
43 u32 rate;
44
45 if (vclk == NULL || sclk == NULL)
46 return;
47
48 rate = clk_get_rate(sclk);
49 clk_set_rate(vclk, rate);
50}
51
52/*
53 * Switch the MPU rate if specified on cmdline.
54 * We cannot do this early until cmdline is parsed.
55 */
Paul Walmsley4680c292010-01-26 20:13:09 -070056static int __init omap2xxx_clk_arch_init(void)
Paul Walmsleyd8a94452009-12-08 16:21:29 -070057{
58 struct clk *virt_prcm_set, *sys_ck, *dpll_ck, *mpu_ck;
59 unsigned long sys_ck_rate;
60
Paul Walmsley4680c292010-01-26 20:13:09 -070061 if (!cpu_is_omap24xx())
62 return 0;
63
Paul Walmsleyd8a94452009-12-08 16:21:29 -070064 if (!mpurate)
65 return -EINVAL;
66
67 virt_prcm_set = clk_get(NULL, "virt_prcm_set");
68 sys_ck = clk_get(NULL, "sys_ck");
69 dpll_ck = clk_get(NULL, "dpll_ck");
70 mpu_ck = clk_get(NULL, "mpu_ck");
71
72 if (clk_set_rate(virt_prcm_set, mpurate))
Paul Walmsley81b34fb2010-02-22 22:09:22 -070073 pr_err("Could not find matching MPU rate\n");
Paul Walmsleyd8a94452009-12-08 16:21:29 -070074
75 recalculate_root_clocks();
76
77 sys_ck_rate = clk_get_rate(sys_ck);
78
79 pr_info("Switched to new clocking rate (Crystal/DPLL/MPU): "
80 "%ld.%01ld/%ld/%ld MHz\n",
81 (sys_ck_rate / 1000000), (sys_ck_rate / 100000) % 10,
82 (clk_get_rate(dpll_ck) / 1000000),
83 (clk_get_rate(mpu_ck) / 1000000));
84
85 return 0;
86}
Paul Walmsley4680c292010-01-26 20:13:09 -070087arch_initcall(omap2xxx_clk_arch_init);
Paul Walmsleyd8a94452009-12-08 16:21:29 -070088
89