blob: 0b02b4161d71f9806fd10acea364d3dbfe005505 [file] [log] [blame]
Paul Walmsley657ebfa2010-02-22 22:09:20 -07001/*
2 * OMAP3-specific clock framework functions
3 *
4 * Copyright (C) 2007-2008 Texas Instruments, Inc.
5 * Copyright (C) 2007-2010 Nokia Corporation
6 *
7 * Paul Walmsley
8 * Jouni Högander
9 *
10 * Parts of this code are based on code written by
11 * Richard Woodruff, Tony Lindgren, Tuukka Tikkanen, Karthik Dasu
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16 */
17#undef DEBUG
18
19#include <linux/kernel.h>
20#include <linux/errno.h>
Paul Walmsley657ebfa2010-02-22 22:09:20 -070021#include <linux/clk.h>
22#include <linux/io.h>
Paul Walmsley657ebfa2010-02-22 22:09:20 -070023
Tony Lindgrendbc04162012-08-31 10:59:07 -070024#include "soc.h"
Paul Walmsley657ebfa2010-02-22 22:09:20 -070025#include "clock.h"
26#include "clock3xxx.h"
Paul Walmsley59fb6592010-12-21 15:30:55 -070027#include "prm2xxx_3xxx.h"
Paul Walmsley657ebfa2010-02-22 22:09:20 -070028#include "prm-regbits-34xx.h"
Paul Walmsley59fb6592010-12-21 15:30:55 -070029#include "cm2xxx_3xxx.h"
Paul Walmsley657ebfa2010-02-22 22:09:20 -070030#include "cm-regbits-34xx.h"
31
32/*
33 * DPLL5_FREQ_FOR_USBHOST: USBHOST and USBTLL are the only clocks
34 * that are sourced by DPLL5, and both of these require this clock
35 * to be at 120 MHz for proper operation.
36 */
37#define DPLL5_FREQ_FOR_USBHOST 120000000
38
39/* needed by omap3_core_dpll_m2_set_rate() */
40struct clk *sdrc_ick_p, *arm_fck_p;
Rajendra Nayakb4777a22012-04-27 15:53:48 +053041int omap3_dpll4_set_rate(struct clk_hw *hw, unsigned long rate,
42 unsigned long parent_rate)
Paul Walmsley657ebfa2010-02-22 22:09:20 -070043{
44 /*
45 * According to the 12-5 CDP code from TI, "Limitation 2.5"
46 * on 3430ES1 prevents us from changing DPLL multipliers or dividers
47 * on DPLL4.
48 */
49 if (omap_rev() == OMAP3430_REV_ES1_0) {
Paul Walmsley7852ec02012-07-26 00:54:26 -060050 pr_err("clock: DPLL4 cannot change rate due to silicon 'Limitation 2.5' on 3430ES1.\n");
Paul Walmsley657ebfa2010-02-22 22:09:20 -070051 return -EINVAL;
52 }
53
Rajendra Nayakb4777a22012-04-27 15:53:48 +053054 return omap3_noncore_dpll_set_rate(hw, rate, parent_rate);
Paul Walmsley657ebfa2010-02-22 22:09:20 -070055}
56
57void __init omap3_clk_lock_dpll5(void)
58{
59 struct clk *dpll5_clk;
60 struct clk *dpll5_m2_clk;
61
62 dpll5_clk = clk_get(NULL, "dpll5_ck");
63 clk_set_rate(dpll5_clk, DPLL5_FREQ_FOR_USBHOST);
Rajendra Nayak4d7cb452012-09-22 02:24:16 -060064 clk_prepare_enable(dpll5_clk);
Paul Walmsley657ebfa2010-02-22 22:09:20 -070065
Paul Walmsley657ebfa2010-02-22 22:09:20 -070066 /* Program dpll5_m2_clk divider for no division */
67 dpll5_m2_clk = clk_get(NULL, "dpll5_m2_ck");
Rajendra Nayak4d7cb452012-09-22 02:24:16 -060068 clk_prepare_enable(dpll5_m2_clk);
Paul Walmsley657ebfa2010-02-22 22:09:20 -070069 clk_set_rate(dpll5_m2_clk, DPLL5_FREQ_FOR_USBHOST);
70
Rajendra Nayak4d7cb452012-09-22 02:24:16 -060071 clk_disable_unprepare(dpll5_m2_clk);
72 clk_disable_unprepare(dpll5_clk);
Paul Walmsley657ebfa2010-02-22 22:09:20 -070073 return;
74}
75
76/* Common clock code */
77
Paul Walmsley657ebfa2010-02-22 22:09:20 -070078/*
Paul Walmsley4d30e822010-02-22 22:09:36 -070079 * Switch the MPU rate if specified on cmdline. We cannot do this
80 * early until cmdline is parsed. XXX This should be removed from the
81 * clock code and handled by the OPP layer code in the near future.
Paul Walmsley657ebfa2010-02-22 22:09:20 -070082 */
83static int __init omap3xxx_clk_arch_init(void)
84{
Paul Walmsley4d30e822010-02-22 22:09:36 -070085 int ret;
Paul Walmsley657ebfa2010-02-22 22:09:20 -070086
87 if (!cpu_is_omap34xx())
88 return 0;
89
Paul Walmsley4d30e822010-02-22 22:09:36 -070090 ret = omap2_clk_switch_mpurate_at_boot("dpll1_ck");
91 if (!ret)
Paul Walmsleyf1f4b772010-12-21 21:08:14 -070092 omap2_clk_print_new_rates("osc_sys_ck", "core_ck", "arm_fck");
Paul Walmsley657ebfa2010-02-22 22:09:20 -070093
Paul Walmsley4d30e822010-02-22 22:09:36 -070094 return ret;
Paul Walmsley657ebfa2010-02-22 22:09:20 -070095}
Paul Walmsley4d30e822010-02-22 22:09:36 -070096
Tony Lindgrenb76c8b192013-01-11 11:24:18 -080097omap_arch_initcall(omap3xxx_clk_arch_init);
Paul Walmsley657ebfa2010-02-22 22:09:20 -070098
99