Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Chandan Nath | 4ba3345 | 2011-10-14 02:58:23 +0000 | [diff] [blame] | 2 | /* |
| 3 | * clock.h |
| 4 | * |
| 5 | * clock header |
| 6 | * |
Nishanth Menon | eaa39c6 | 2023-11-01 15:56:03 -0500 | [diff] [blame] | 7 | * Copyright (C) 2011, Texas Instruments Incorporated - https://www.ti.com/ |
Chandan Nath | 4ba3345 | 2011-10-14 02:58:23 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef _CLOCKS_H_ |
| 11 | #define _CLOCKS_H_ |
| 12 | |
| 13 | #include <asm/arch/clocks_am33xx.h> |
Lokesh Vutla | 6302e53 | 2017-05-05 12:59:10 +0530 | [diff] [blame] | 14 | #include <asm/arch/hardware.h> |
Chandan Nath | 4ba3345 | 2011-10-14 02:58:23 +0000 | [diff] [blame] | 15 | |
Lokesh Vutla | 89a83bf | 2013-07-30 10:48:52 +0530 | [diff] [blame] | 16 | #define LDELAY 1000000 |
| 17 | |
Lokesh Vutla | b1b6fba | 2013-07-30 10:48:53 +0530 | [diff] [blame] | 18 | /*CM_<clock_domain>__CLKCTRL */ |
| 19 | #define CD_CLKCTRL_CLKTRCTRL_SHIFT 0 |
| 20 | #define CD_CLKCTRL_CLKTRCTRL_MASK 3 |
| 21 | |
| 22 | #define CD_CLKCTRL_CLKTRCTRL_NO_SLEEP 0 |
| 23 | #define CD_CLKCTRL_CLKTRCTRL_SW_SLEEP 1 |
| 24 | #define CD_CLKCTRL_CLKTRCTRL_SW_WKUP 2 |
| 25 | |
| 26 | /* CM_<clock_domain>_<module>_CLKCTRL */ |
| 27 | #define MODULE_CLKCTRL_MODULEMODE_SHIFT 0 |
| 28 | #define MODULE_CLKCTRL_MODULEMODE_MASK 3 |
| 29 | #define MODULE_CLKCTRL_IDLEST_SHIFT 16 |
| 30 | #define MODULE_CLKCTRL_IDLEST_MASK (3 << 16) |
| 31 | |
| 32 | #define MODULE_CLKCTRL_MODULEMODE_SW_DISABLE 0 |
| 33 | #define MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN 2 |
| 34 | |
| 35 | #define MODULE_CLKCTRL_IDLEST_FULLY_FUNCTIONAL 0 |
| 36 | #define MODULE_CLKCTRL_IDLEST_TRANSITIONING 1 |
| 37 | #define MODULE_CLKCTRL_IDLEST_IDLE 2 |
| 38 | #define MODULE_CLKCTRL_IDLEST_DISABLED 3 |
| 39 | |
Lokesh Vutla | 89a83bf | 2013-07-30 10:48:52 +0530 | [diff] [blame] | 40 | /* CM_CLKMODE_DPLL */ |
Yegor Yefremov | cacea6c | 2014-04-19 22:12:18 +0200 | [diff] [blame] | 41 | #define CM_CLKMODE_DPLL_SSC_EN_SHIFT 12 |
| 42 | #define CM_CLKMODE_DPLL_SSC_EN_MASK (1 << 12) |
Heiko Schocher | 7cc40dd | 2016-06-07 08:31:18 +0200 | [diff] [blame] | 43 | #define CM_CLKMODE_DPLL_SSC_ACK_MASK (1 << 13) |
| 44 | #define CM_CLKMODE_DPLL_SSC_DOWNSPREAD_MASK (1 << 14) |
| 45 | #define CM_CLKMODE_DPLL_SSC_TYPE_MASK (1 << 15) |
Lokesh Vutla | 89a83bf | 2013-07-30 10:48:52 +0530 | [diff] [blame] | 46 | #define CM_CLKMODE_DPLL_REGM4XEN_SHIFT 11 |
| 47 | #define CM_CLKMODE_DPLL_REGM4XEN_MASK (1 << 11) |
| 48 | #define CM_CLKMODE_DPLL_LPMODE_EN_SHIFT 10 |
| 49 | #define CM_CLKMODE_DPLL_LPMODE_EN_MASK (1 << 10) |
| 50 | #define CM_CLKMODE_DPLL_RELOCK_RAMP_EN_SHIFT 9 |
| 51 | #define CM_CLKMODE_DPLL_RELOCK_RAMP_EN_MASK (1 << 9) |
| 52 | #define CM_CLKMODE_DPLL_DRIFTGUARD_EN_SHIFT 8 |
| 53 | #define CM_CLKMODE_DPLL_DRIFTGUARD_EN_MASK (1 << 8) |
| 54 | #define CM_CLKMODE_DPLL_RAMP_RATE_SHIFT 5 |
| 55 | #define CM_CLKMODE_DPLL_RAMP_RATE_MASK (0x7 << 5) |
| 56 | #define CM_CLKMODE_DPLL_EN_SHIFT 0 |
| 57 | #define CM_CLKMODE_DPLL_EN_MASK (0x7 << 0) |
| 58 | |
| 59 | #define CM_CLKMODE_DPLL_DPLL_EN_SHIFT 0 |
| 60 | #define CM_CLKMODE_DPLL_DPLL_EN_MASK 7 |
| 61 | |
| 62 | #define DPLL_EN_STOP 1 |
| 63 | #define DPLL_EN_MN_BYPASS 4 |
| 64 | #define DPLL_EN_LOW_POWER_BYPASS 5 |
Dario Binacchi | 5931e5a | 2020-12-30 00:06:33 +0100 | [diff] [blame] | 65 | #define DPLL_EN_FAST_RELOCK_BYPASS 6 |
Lokesh Vutla | 89a83bf | 2013-07-30 10:48:52 +0530 | [diff] [blame] | 66 | #define DPLL_EN_LOCK 7 |
| 67 | |
| 68 | /* CM_IDLEST_DPLL fields */ |
| 69 | #define ST_DPLL_CLK_MASK 1 |
| 70 | |
| 71 | /* CM_CLKSEL_DPLL */ |
| 72 | #define CM_CLKSEL_DPLL_M_SHIFT 8 |
| 73 | #define CM_CLKSEL_DPLL_M_MASK (0x7FF << 8) |
| 74 | #define CM_CLKSEL_DPLL_N_SHIFT 0 |
| 75 | #define CM_CLKSEL_DPLL_N_MASK 0x7F |
| 76 | |
Dario Binacchi | d441175 | 2021-09-26 11:58:58 +0200 | [diff] [blame] | 77 | /* CM_SSC_DELTAM_DPLL */ |
| 78 | #define CM_SSC_DELTAM_DPLL_FRAC_SHIFT 0 |
| 79 | #define CM_SSC_DELTAM_DPLL_FRAC_MASK GENMASK(17, 0) |
| 80 | #define CM_SSC_DELTAM_DPLL_INT_SHIFT 18 |
| 81 | #define CM_SSC_DELTAM_DPLL_INT_MASK GENMASK(19, 18) |
| 82 | |
| 83 | /* CM_SSC_MODFREQ_DPLL */ |
| 84 | #define CM_SSC_MODFREQ_DPLL_MANT_SHIFT 0 |
| 85 | #define CM_SSC_MODFREQ_DPLL_MANT_MASK GENMASK(6, 0) |
| 86 | #define CM_SSC_MODFREQ_DPLL_EXP_SHIFT 7 |
| 87 | #define CM_SSC_MODFREQ_DPLL_EXP_MASK GENMASK(10, 8) |
| 88 | |
Lokesh Vutla | 89a83bf | 2013-07-30 10:48:52 +0530 | [diff] [blame] | 89 | struct dpll_params { |
| 90 | u32 m; |
| 91 | u32 n; |
| 92 | s8 m2; |
| 93 | s8 m3; |
| 94 | s8 m4; |
| 95 | s8 m5; |
| 96 | s8 m6; |
| 97 | }; |
| 98 | |
| 99 | struct dpll_regs { |
| 100 | u32 cm_clkmode_dpll; |
| 101 | u32 cm_idlest_dpll; |
| 102 | u32 cm_autoidle_dpll; |
| 103 | u32 cm_clksel_dpll; |
| 104 | u32 cm_div_m2_dpll; |
| 105 | u32 cm_div_m3_dpll; |
| 106 | u32 cm_div_m4_dpll; |
| 107 | u32 cm_div_m5_dpll; |
| 108 | u32 cm_div_m6_dpll; |
| 109 | }; |
| 110 | |
| 111 | extern const struct dpll_regs dpll_mpu_regs; |
| 112 | extern const struct dpll_regs dpll_core_regs; |
| 113 | extern const struct dpll_regs dpll_per_regs; |
| 114 | extern const struct dpll_regs dpll_ddr_regs; |
Hannes Schmelzer | f29f8f4 | 2018-01-09 19:01:31 +0100 | [diff] [blame] | 115 | extern const struct dpll_regs dpll_disp_regs; |
Lokesh Vutla | 6302e53 | 2017-05-05 12:59:10 +0530 | [diff] [blame] | 116 | extern const struct dpll_params dpll_mpu_opp[NUM_CRYSTAL_FREQ][NUM_OPPS]; |
| 117 | extern const struct dpll_params dpll_core_1000MHz[NUM_CRYSTAL_FREQ]; |
| 118 | extern const struct dpll_params dpll_per_192MHz[NUM_CRYSTAL_FREQ]; |
| 119 | extern const struct dpll_params dpll_ddr2_266MHz[NUM_CRYSTAL_FREQ]; |
| 120 | extern const struct dpll_params dpll_ddr3_303MHz[NUM_CRYSTAL_FREQ]; |
| 121 | extern const struct dpll_params dpll_ddr3_400MHz[NUM_CRYSTAL_FREQ]; |
Lokesh Vutla | 89a83bf | 2013-07-30 10:48:52 +0530 | [diff] [blame] | 122 | |
Lokesh Vutla | b1b6fba | 2013-07-30 10:48:53 +0530 | [diff] [blame] | 123 | extern struct cm_wkuppll *const cmwkup; |
Lokesh Vutla | 89a83bf | 2013-07-30 10:48:52 +0530 | [diff] [blame] | 124 | |
Lokesh Vutla | 42c213a | 2013-12-10 15:02:20 +0530 | [diff] [blame] | 125 | const struct dpll_params *get_dpll_mpu_params(void); |
| 126 | const struct dpll_params *get_dpll_core_params(void); |
| 127 | const struct dpll_params *get_dpll_per_params(void); |
Lokesh Vutla | 89a83bf | 2013-07-30 10:48:52 +0530 | [diff] [blame] | 128 | const struct dpll_params *get_dpll_ddr_params(void); |
Tom Rini | 7c37e5c | 2014-06-05 11:15:28 -0400 | [diff] [blame] | 129 | void scale_vcores(void); |
Lokesh Vutla | 89a83bf | 2013-07-30 10:48:52 +0530 | [diff] [blame] | 130 | void do_setup_dpll(const struct dpll_regs *, const struct dpll_params *); |
Lokesh Vutla | b1b6fba | 2013-07-30 10:48:53 +0530 | [diff] [blame] | 131 | void prcm_init(void); |
| 132 | void enable_basic_clocks(void); |
Tero Kristo | 5d6acae | 2018-03-17 13:32:52 +0530 | [diff] [blame] | 133 | |
| 134 | void rtc_only_update_board_type(u32 btype); |
| 135 | u32 rtc_only_get_board_type(void); |
| 136 | void rtc_only_prcm_init(void); |
| 137 | void rtc_only_enable_basic_clocks(void); |
| 138 | |
Lokesh Vutla | b1b6fba | 2013-07-30 10:48:53 +0530 | [diff] [blame] | 139 | void do_enable_clocks(u32 *const *, u32 *const *, u8); |
Kishon Vijay Abraham I | efc65c8 | 2015-08-17 13:29:50 +0530 | [diff] [blame] | 140 | void do_disable_clocks(u32 *const *, u32 *const *, u8); |
Lokesh Vutla | 89a83bf | 2013-07-30 10:48:52 +0530 | [diff] [blame] | 141 | |
Heiko Schocher | 8575473 | 2016-06-07 08:31:19 +0200 | [diff] [blame] | 142 | void set_mpu_spreadspectrum(int permille); |
Chandan Nath | 4ba3345 | 2011-10-14 02:58:23 +0000 | [diff] [blame] | 143 | #endif |