blob: 5399bb81f0bbed6988be3b00d101ea128ad60500 [file] [log] [blame]
Chandan Nath4ba33452011-10-14 02:58:23 +00001/*
2 * clock.h
3 *
4 * clock header
5 *
Matt Porter57da6662013-03-15 10:07:04 +00006 * Copyright (C) 2011, Texas Instruments Incorporated - http://www.ti.com/
Chandan Nath4ba33452011-10-14 02:58:23 +00007 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
Chandan Nath4ba33452011-10-14 02:58:23 +00009 */
10
11#ifndef _CLOCKS_H_
12#define _CLOCKS_H_
13
14#include <asm/arch/clocks_am33xx.h>
Lokesh Vutla6302e532017-05-05 12:59:10 +053015#include <asm/arch/hardware.h>
Chandan Nath4ba33452011-10-14 02:58:23 +000016
Tom Rini2a84b012017-05-16 14:46:40 -040017#if defined(CONFIG_TI816X) || defined(CONFIG_TI814X)
TENART Antoine35c7e522013-07-02 12:05:59 +020018#include <asm/arch/clock_ti81xx.h>
19#endif
20
Lokesh Vutla89a83bf2013-07-30 10:48:52 +053021#define LDELAY 1000000
22
Lokesh Vutlab1b6fba2013-07-30 10:48:53 +053023/*CM_<clock_domain>__CLKCTRL */
24#define CD_CLKCTRL_CLKTRCTRL_SHIFT 0
25#define CD_CLKCTRL_CLKTRCTRL_MASK 3
26
27#define CD_CLKCTRL_CLKTRCTRL_NO_SLEEP 0
28#define CD_CLKCTRL_CLKTRCTRL_SW_SLEEP 1
29#define CD_CLKCTRL_CLKTRCTRL_SW_WKUP 2
30
31/* CM_<clock_domain>_<module>_CLKCTRL */
32#define MODULE_CLKCTRL_MODULEMODE_SHIFT 0
33#define MODULE_CLKCTRL_MODULEMODE_MASK 3
34#define MODULE_CLKCTRL_IDLEST_SHIFT 16
35#define MODULE_CLKCTRL_IDLEST_MASK (3 << 16)
36
37#define MODULE_CLKCTRL_MODULEMODE_SW_DISABLE 0
38#define MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN 2
39
40#define MODULE_CLKCTRL_IDLEST_FULLY_FUNCTIONAL 0
41#define MODULE_CLKCTRL_IDLEST_TRANSITIONING 1
42#define MODULE_CLKCTRL_IDLEST_IDLE 2
43#define MODULE_CLKCTRL_IDLEST_DISABLED 3
44
Lokesh Vutla89a83bf2013-07-30 10:48:52 +053045/* CM_CLKMODE_DPLL */
Yegor Yefremovcacea6c2014-04-19 22:12:18 +020046#define CM_CLKMODE_DPLL_SSC_EN_SHIFT 12
47#define CM_CLKMODE_DPLL_SSC_EN_MASK (1 << 12)
Heiko Schocher7cc40dd2016-06-07 08:31:18 +020048#define CM_CLKMODE_DPLL_SSC_ACK_MASK (1 << 13)
49#define CM_CLKMODE_DPLL_SSC_DOWNSPREAD_MASK (1 << 14)
50#define CM_CLKMODE_DPLL_SSC_TYPE_MASK (1 << 15)
Lokesh Vutla89a83bf2013-07-30 10:48:52 +053051#define CM_CLKMODE_DPLL_REGM4XEN_SHIFT 11
52#define CM_CLKMODE_DPLL_REGM4XEN_MASK (1 << 11)
53#define CM_CLKMODE_DPLL_LPMODE_EN_SHIFT 10
54#define CM_CLKMODE_DPLL_LPMODE_EN_MASK (1 << 10)
55#define CM_CLKMODE_DPLL_RELOCK_RAMP_EN_SHIFT 9
56#define CM_CLKMODE_DPLL_RELOCK_RAMP_EN_MASK (1 << 9)
57#define CM_CLKMODE_DPLL_DRIFTGUARD_EN_SHIFT 8
58#define CM_CLKMODE_DPLL_DRIFTGUARD_EN_MASK (1 << 8)
59#define CM_CLKMODE_DPLL_RAMP_RATE_SHIFT 5
60#define CM_CLKMODE_DPLL_RAMP_RATE_MASK (0x7 << 5)
61#define CM_CLKMODE_DPLL_EN_SHIFT 0
62#define CM_CLKMODE_DPLL_EN_MASK (0x7 << 0)
63
64#define CM_CLKMODE_DPLL_DPLL_EN_SHIFT 0
65#define CM_CLKMODE_DPLL_DPLL_EN_MASK 7
66
67#define DPLL_EN_STOP 1
68#define DPLL_EN_MN_BYPASS 4
69#define DPLL_EN_LOW_POWER_BYPASS 5
70#define DPLL_EN_LOCK 7
71
72/* CM_IDLEST_DPLL fields */
73#define ST_DPLL_CLK_MASK 1
74
75/* CM_CLKSEL_DPLL */
76#define CM_CLKSEL_DPLL_M_SHIFT 8
77#define CM_CLKSEL_DPLL_M_MASK (0x7FF << 8)
78#define CM_CLKSEL_DPLL_N_SHIFT 0
79#define CM_CLKSEL_DPLL_N_MASK 0x7F
80
81struct dpll_params {
82 u32 m;
83 u32 n;
84 s8 m2;
85 s8 m3;
86 s8 m4;
87 s8 m5;
88 s8 m6;
89};
90
91struct dpll_regs {
92 u32 cm_clkmode_dpll;
93 u32 cm_idlest_dpll;
94 u32 cm_autoidle_dpll;
95 u32 cm_clksel_dpll;
96 u32 cm_div_m2_dpll;
97 u32 cm_div_m3_dpll;
98 u32 cm_div_m4_dpll;
99 u32 cm_div_m5_dpll;
100 u32 cm_div_m6_dpll;
101};
102
103extern const struct dpll_regs dpll_mpu_regs;
104extern const struct dpll_regs dpll_core_regs;
105extern const struct dpll_regs dpll_per_regs;
106extern const struct dpll_regs dpll_ddr_regs;
Lokesh Vutla6302e532017-05-05 12:59:10 +0530107extern const struct dpll_params dpll_mpu_opp[NUM_CRYSTAL_FREQ][NUM_OPPS];
108extern const struct dpll_params dpll_core_1000MHz[NUM_CRYSTAL_FREQ];
109extern const struct dpll_params dpll_per_192MHz[NUM_CRYSTAL_FREQ];
110extern const struct dpll_params dpll_ddr2_266MHz[NUM_CRYSTAL_FREQ];
111extern const struct dpll_params dpll_ddr3_303MHz[NUM_CRYSTAL_FREQ];
112extern const struct dpll_params dpll_ddr3_400MHz[NUM_CRYSTAL_FREQ];
Lokesh Vutla89a83bf2013-07-30 10:48:52 +0530113
Lokesh Vutlab1b6fba2013-07-30 10:48:53 +0530114extern struct cm_wkuppll *const cmwkup;
Lokesh Vutla89a83bf2013-07-30 10:48:52 +0530115
Lokesh Vutla42c213a2013-12-10 15:02:20 +0530116const struct dpll_params *get_dpll_mpu_params(void);
117const struct dpll_params *get_dpll_core_params(void);
118const struct dpll_params *get_dpll_per_params(void);
Lokesh Vutla89a83bf2013-07-30 10:48:52 +0530119const struct dpll_params *get_dpll_ddr_params(void);
Tom Rini7c37e5c2014-06-05 11:15:28 -0400120void scale_vcores(void);
Lokesh Vutla89a83bf2013-07-30 10:48:52 +0530121void do_setup_dpll(const struct dpll_regs *, const struct dpll_params *);
Lokesh Vutlab1b6fba2013-07-30 10:48:53 +0530122void prcm_init(void);
123void enable_basic_clocks(void);
124void do_enable_clocks(u32 *const *, u32 *const *, u8);
Kishon Vijay Abraham Iefc65c82015-08-17 13:29:50 +0530125void do_disable_clocks(u32 *const *, u32 *const *, u8);
Lokesh Vutla89a83bf2013-07-30 10:48:52 +0530126
Heiko Schocher85754732016-06-07 08:31:19 +0200127void set_mpu_spreadspectrum(int permille);
Chandan Nath4ba33452011-10-14 02:58:23 +0000128#endif