blob: 79e3b8c7d9f97501eb28f3d1f6cf9c6114b3db49 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Chandan Nath4ba33452011-10-14 02:58:23 +00002/*
3 * clock.h
4 *
5 * clock header
6 *
Matt Porter57da6662013-03-15 10:07:04 +00007 * Copyright (C) 2011, Texas Instruments Incorporated - http://www.ti.com/
Chandan Nath4ba33452011-10-14 02:58:23 +00008 */
9
10#ifndef _CLOCKS_H_
11#define _CLOCKS_H_
12
13#include <asm/arch/clocks_am33xx.h>
Lokesh Vutla6302e532017-05-05 12:59:10 +053014#include <asm/arch/hardware.h>
Chandan Nath4ba33452011-10-14 02:58:23 +000015
Tom Rini2a84b012017-05-16 14:46:40 -040016#if defined(CONFIG_TI816X) || defined(CONFIG_TI814X)
TENART Antoine35c7e522013-07-02 12:05:59 +020017#include <asm/arch/clock_ti81xx.h>
18#endif
19
Lokesh Vutla89a83bf2013-07-30 10:48:52 +053020#define LDELAY 1000000
21
Lokesh Vutlab1b6fba2013-07-30 10:48:53 +053022/*CM_<clock_domain>__CLKCTRL */
23#define CD_CLKCTRL_CLKTRCTRL_SHIFT 0
24#define CD_CLKCTRL_CLKTRCTRL_MASK 3
25
26#define CD_CLKCTRL_CLKTRCTRL_NO_SLEEP 0
27#define CD_CLKCTRL_CLKTRCTRL_SW_SLEEP 1
28#define CD_CLKCTRL_CLKTRCTRL_SW_WKUP 2
29
30/* CM_<clock_domain>_<module>_CLKCTRL */
31#define MODULE_CLKCTRL_MODULEMODE_SHIFT 0
32#define MODULE_CLKCTRL_MODULEMODE_MASK 3
33#define MODULE_CLKCTRL_IDLEST_SHIFT 16
34#define MODULE_CLKCTRL_IDLEST_MASK (3 << 16)
35
36#define MODULE_CLKCTRL_MODULEMODE_SW_DISABLE 0
37#define MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN 2
38
39#define MODULE_CLKCTRL_IDLEST_FULLY_FUNCTIONAL 0
40#define MODULE_CLKCTRL_IDLEST_TRANSITIONING 1
41#define MODULE_CLKCTRL_IDLEST_IDLE 2
42#define MODULE_CLKCTRL_IDLEST_DISABLED 3
43
Lokesh Vutla89a83bf2013-07-30 10:48:52 +053044/* CM_CLKMODE_DPLL */
Yegor Yefremovcacea6c2014-04-19 22:12:18 +020045#define CM_CLKMODE_DPLL_SSC_EN_SHIFT 12
46#define CM_CLKMODE_DPLL_SSC_EN_MASK (1 << 12)
Heiko Schocher7cc40dd2016-06-07 08:31:18 +020047#define CM_CLKMODE_DPLL_SSC_ACK_MASK (1 << 13)
48#define CM_CLKMODE_DPLL_SSC_DOWNSPREAD_MASK (1 << 14)
49#define CM_CLKMODE_DPLL_SSC_TYPE_MASK (1 << 15)
Lokesh Vutla89a83bf2013-07-30 10:48:52 +053050#define CM_CLKMODE_DPLL_REGM4XEN_SHIFT 11
51#define CM_CLKMODE_DPLL_REGM4XEN_MASK (1 << 11)
52#define CM_CLKMODE_DPLL_LPMODE_EN_SHIFT 10
53#define CM_CLKMODE_DPLL_LPMODE_EN_MASK (1 << 10)
54#define CM_CLKMODE_DPLL_RELOCK_RAMP_EN_SHIFT 9
55#define CM_CLKMODE_DPLL_RELOCK_RAMP_EN_MASK (1 << 9)
56#define CM_CLKMODE_DPLL_DRIFTGUARD_EN_SHIFT 8
57#define CM_CLKMODE_DPLL_DRIFTGUARD_EN_MASK (1 << 8)
58#define CM_CLKMODE_DPLL_RAMP_RATE_SHIFT 5
59#define CM_CLKMODE_DPLL_RAMP_RATE_MASK (0x7 << 5)
60#define CM_CLKMODE_DPLL_EN_SHIFT 0
61#define CM_CLKMODE_DPLL_EN_MASK (0x7 << 0)
62
63#define CM_CLKMODE_DPLL_DPLL_EN_SHIFT 0
64#define CM_CLKMODE_DPLL_DPLL_EN_MASK 7
65
66#define DPLL_EN_STOP 1
67#define DPLL_EN_MN_BYPASS 4
68#define DPLL_EN_LOW_POWER_BYPASS 5
Dario Binacchi5931e5a2020-12-30 00:06:33 +010069#define DPLL_EN_FAST_RELOCK_BYPASS 6
Lokesh Vutla89a83bf2013-07-30 10:48:52 +053070#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
Dario Binacchid4411752021-09-26 11:58:58 +020081/* CM_SSC_DELTAM_DPLL */
82#define CM_SSC_DELTAM_DPLL_FRAC_SHIFT 0
83#define CM_SSC_DELTAM_DPLL_FRAC_MASK GENMASK(17, 0)
84#define CM_SSC_DELTAM_DPLL_INT_SHIFT 18
85#define CM_SSC_DELTAM_DPLL_INT_MASK GENMASK(19, 18)
86
87/* CM_SSC_MODFREQ_DPLL */
88#define CM_SSC_MODFREQ_DPLL_MANT_SHIFT 0
89#define CM_SSC_MODFREQ_DPLL_MANT_MASK GENMASK(6, 0)
90#define CM_SSC_MODFREQ_DPLL_EXP_SHIFT 7
91#define CM_SSC_MODFREQ_DPLL_EXP_MASK GENMASK(10, 8)
92
Lokesh Vutla89a83bf2013-07-30 10:48:52 +053093struct dpll_params {
94 u32 m;
95 u32 n;
96 s8 m2;
97 s8 m3;
98 s8 m4;
99 s8 m5;
100 s8 m6;
101};
102
103struct dpll_regs {
104 u32 cm_clkmode_dpll;
105 u32 cm_idlest_dpll;
106 u32 cm_autoidle_dpll;
107 u32 cm_clksel_dpll;
108 u32 cm_div_m2_dpll;
109 u32 cm_div_m3_dpll;
110 u32 cm_div_m4_dpll;
111 u32 cm_div_m5_dpll;
112 u32 cm_div_m6_dpll;
113};
114
115extern const struct dpll_regs dpll_mpu_regs;
116extern const struct dpll_regs dpll_core_regs;
117extern const struct dpll_regs dpll_per_regs;
118extern const struct dpll_regs dpll_ddr_regs;
Hannes Schmelzerf29f8f42018-01-09 19:01:31 +0100119extern const struct dpll_regs dpll_disp_regs;
Lokesh Vutla6302e532017-05-05 12:59:10 +0530120extern const struct dpll_params dpll_mpu_opp[NUM_CRYSTAL_FREQ][NUM_OPPS];
121extern const struct dpll_params dpll_core_1000MHz[NUM_CRYSTAL_FREQ];
122extern const struct dpll_params dpll_per_192MHz[NUM_CRYSTAL_FREQ];
123extern const struct dpll_params dpll_ddr2_266MHz[NUM_CRYSTAL_FREQ];
124extern const struct dpll_params dpll_ddr3_303MHz[NUM_CRYSTAL_FREQ];
125extern const struct dpll_params dpll_ddr3_400MHz[NUM_CRYSTAL_FREQ];
Lokesh Vutla89a83bf2013-07-30 10:48:52 +0530126
Lokesh Vutlab1b6fba2013-07-30 10:48:53 +0530127extern struct cm_wkuppll *const cmwkup;
Lokesh Vutla89a83bf2013-07-30 10:48:52 +0530128
Lokesh Vutla42c213a2013-12-10 15:02:20 +0530129const struct dpll_params *get_dpll_mpu_params(void);
130const struct dpll_params *get_dpll_core_params(void);
131const struct dpll_params *get_dpll_per_params(void);
Lokesh Vutla89a83bf2013-07-30 10:48:52 +0530132const struct dpll_params *get_dpll_ddr_params(void);
Tom Rini7c37e5c2014-06-05 11:15:28 -0400133void scale_vcores(void);
Lokesh Vutla89a83bf2013-07-30 10:48:52 +0530134void do_setup_dpll(const struct dpll_regs *, const struct dpll_params *);
Lokesh Vutlab1b6fba2013-07-30 10:48:53 +0530135void prcm_init(void);
136void enable_basic_clocks(void);
Tero Kristo5d6acae2018-03-17 13:32:52 +0530137
138void rtc_only_update_board_type(u32 btype);
139u32 rtc_only_get_board_type(void);
140void rtc_only_prcm_init(void);
141void rtc_only_enable_basic_clocks(void);
142
Lokesh Vutlab1b6fba2013-07-30 10:48:53 +0530143void do_enable_clocks(u32 *const *, u32 *const *, u8);
Kishon Vijay Abraham Iefc65c82015-08-17 13:29:50 +0530144void do_disable_clocks(u32 *const *, u32 *const *, u8);
Lokesh Vutla89a83bf2013-07-30 10:48:52 +0530145
Heiko Schocher85754732016-06-07 08:31:19 +0200146void set_mpu_spreadspectrum(int permille);
Chandan Nath4ba33452011-10-14 02:58:23 +0000147#endif