Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/err.h> |
| 17 | #include <linux/ctype.h> |
| 18 | #include <linux/bitops.h> |
| 19 | #include <linux/io.h> |
| 20 | #include <linux/spinlock.h> |
| 21 | #include <linux/delay.h> |
| 22 | #include <linux/clk.h> |
| 23 | #include <linux/clkdev.h> |
| 24 | |
| 25 | #include <mach/msm_iomap.h> |
| 26 | #include <mach/clk.h> |
| 27 | #include <mach/msm_xo.h> |
| 28 | #include <mach/scm-io.h> |
| 29 | #include <mach/rpm.h> |
| 30 | #include <mach/rpm-regulator.h> |
| 31 | |
| 32 | #include "clock-local.h" |
| 33 | #include "clock-rpm.h" |
| 34 | #include "clock-voter.h" |
| 35 | |
| 36 | #ifdef CONFIG_MSM_SECURE_IO |
| 37 | #undef readl_relaxed |
| 38 | #undef writel_relaxed |
| 39 | #define readl_relaxed secure_readl |
| 40 | #define writel_relaxed secure_writel |
| 41 | #endif |
| 42 | |
| 43 | #define REG(off) (MSM_CLK_CTL_BASE + (off)) |
| 44 | #define REG_MM(off) (MSM_MMSS_CLK_CTL_BASE + (off)) |
| 45 | #define REG_LPA(off) (MSM_LPASS_CLK_CTL_BASE + (off)) |
| 46 | |
| 47 | /* Peripheral clock registers. */ |
| 48 | #define CE2_HCLK_CTL_REG REG(0x2740) |
| 49 | #define CLK_HALT_CFPB_STATEA_REG REG(0x2FCC) |
| 50 | #define CLK_HALT_CFPB_STATEB_REG REG(0x2FD0) |
| 51 | #define CLK_HALT_CFPB_STATEC_REG REG(0x2FD4) |
| 52 | #define CLK_HALT_DFAB_STATE_REG REG(0x2FC8) |
| 53 | #define CLK_HALT_MSS_SMPSS_MISC_STATE_REG REG(0x2FDC) |
| 54 | #define CLK_HALT_SFPB_MISC_STATE_REG REG(0x2FD8) |
| 55 | #define CLK_TEST_REG REG(0x2FA0) |
| 56 | #define GSBIn_HCLK_CTL_REG(n) REG(0x29C0+(0x20*((n)-1))) |
| 57 | #define GSBIn_QUP_APPS_MD_REG(n) REG(0x29C8+(0x20*((n)-1))) |
| 58 | #define GSBIn_QUP_APPS_NS_REG(n) REG(0x29CC+(0x20*((n)-1))) |
| 59 | #define GSBIn_RESET_REG(n) REG(0x29DC+(0x20*((n)-1))) |
| 60 | #define GSBIn_UART_APPS_MD_REG(n) REG(0x29D0+(0x20*((n)-1))) |
| 61 | #define GSBIn_UART_APPS_NS_REG(n) REG(0x29D4+(0x20*((n)-1))) |
| 62 | #define PDM_CLK_NS_REG REG(0x2CC0) |
| 63 | #define BB_PLL_ENA_SC0_REG REG(0x34C0) |
| 64 | #define BB_PLL0_STATUS_REG REG(0x30D8) |
| 65 | #define BB_PLL6_STATUS_REG REG(0x3118) |
| 66 | #define BB_PLL8_L_VAL_REG REG(0x3144) |
| 67 | #define BB_PLL8_M_VAL_REG REG(0x3148) |
| 68 | #define BB_PLL8_MODE_REG REG(0x3140) |
| 69 | #define BB_PLL8_N_VAL_REG REG(0x314C) |
| 70 | #define BB_PLL8_STATUS_REG REG(0x3158) |
| 71 | #define PLLTEST_PAD_CFG_REG REG(0x2FA4) |
| 72 | #define PMEM_ACLK_CTL_REG REG(0x25A0) |
| 73 | #define PPSS_HCLK_CTL_REG REG(0x2580) |
| 74 | #define RINGOSC_NS_REG REG(0x2DC0) |
| 75 | #define RINGOSC_STATUS_REG REG(0x2DCC) |
| 76 | #define RINGOSC_TCXO_CTL_REG REG(0x2DC4) |
| 77 | #define SC0_U_CLK_BRANCH_ENA_VOTE_REG REG(0x3080) |
| 78 | #define SC1_U_CLK_BRANCH_ENA_VOTE_REG REG(0x30A0) |
| 79 | #define SC0_U_CLK_SLEEP_ENA_VOTE_REG REG(0x3084) |
| 80 | #define SC1_U_CLK_SLEEP_ENA_VOTE_REG REG(0x30A4) |
| 81 | #define SDCn_APPS_CLK_MD_REG(n) REG(0x2828+(0x20*((n)-1))) |
| 82 | #define SDCn_APPS_CLK_NS_REG(n) REG(0x282C+(0x20*((n)-1))) |
| 83 | #define SDCn_HCLK_CTL_REG(n) REG(0x2820+(0x20*((n)-1))) |
| 84 | #define SDCn_RESET_REG(n) REG(0x2830+(0x20*((n)-1))) |
| 85 | #define TSIF_HCLK_CTL_REG REG(0x2700) |
| 86 | #define TSIF_REF_CLK_MD_REG REG(0x270C) |
| 87 | #define TSIF_REF_CLK_NS_REG REG(0x2710) |
| 88 | #define TSSC_CLK_CTL_REG REG(0x2CA0) |
| 89 | #define USB_FSn_HCLK_CTL_REG(n) REG(0x2960+(0x20*((n)-1))) |
| 90 | #define USB_FSn_RESET_REG(n) REG(0x2974+(0x20*((n)-1))) |
| 91 | #define USB_FSn_SYSTEM_CLK_CTL_REG(n) REG(0x296C+(0x20*((n)-1))) |
| 92 | #define USB_FSn_XCVR_FS_CLK_MD_REG(n) REG(0x2964+(0x20*((n)-1))) |
| 93 | #define USB_FSn_XCVR_FS_CLK_NS_REG(n) REG(0x2968+(0x20*((n)-1))) |
| 94 | #define USB_HS1_HCLK_CTL_REG REG(0x2900) |
| 95 | #define USB_HS1_RESET_REG REG(0x2910) |
| 96 | #define USB_HS1_XCVR_FS_CLK_MD_REG REG(0x2908) |
| 97 | #define USB_HS1_XCVR_FS_CLK_NS_REG REG(0x290C) |
| 98 | #define USB_PHY0_RESET_REG REG(0x2E20) |
| 99 | |
| 100 | /* Multimedia clock registers. */ |
| 101 | #define AHB_EN_REG REG_MM(0x0008) |
| 102 | #define AHB_EN2_REG REG_MM(0x0038) |
| 103 | #define AHB_NS_REG REG_MM(0x0004) |
| 104 | #define AXI_NS_REG REG_MM(0x0014) |
| 105 | #define CAMCLK_CC_REG REG_MM(0x0140) |
| 106 | #define CAMCLK_MD_REG REG_MM(0x0144) |
| 107 | #define CAMCLK_NS_REG REG_MM(0x0148) |
| 108 | #define CSI_CC_REG REG_MM(0x0040) |
| 109 | #define CSI_NS_REG REG_MM(0x0048) |
| 110 | #define DBG_BUS_VEC_A_REG REG_MM(0x01C8) |
| 111 | #define DBG_BUS_VEC_B_REG REG_MM(0x01CC) |
| 112 | #define DBG_BUS_VEC_C_REG REG_MM(0x01D0) |
| 113 | #define DBG_BUS_VEC_D_REG REG_MM(0x01D4) |
| 114 | #define DBG_BUS_VEC_E_REG REG_MM(0x01D8) |
| 115 | #define DBG_BUS_VEC_F_REG REG_MM(0x01DC) |
| 116 | #define DBG_BUS_VEC_H_REG REG_MM(0x01E4) |
| 117 | #define DBG_CFG_REG_HS_REG REG_MM(0x01B4) |
| 118 | #define DBG_CFG_REG_LS_REG REG_MM(0x01B8) |
| 119 | #define GFX2D0_CC_REG REG_MM(0x0060) |
| 120 | #define GFX2D0_MD0_REG REG_MM(0x0064) |
| 121 | #define GFX2D0_MD1_REG REG_MM(0x0068) |
| 122 | #define GFX2D0_NS_REG REG_MM(0x0070) |
| 123 | #define GFX2D1_CC_REG REG_MM(0x0074) |
| 124 | #define GFX2D1_MD0_REG REG_MM(0x0078) |
| 125 | #define GFX2D1_MD1_REG REG_MM(0x006C) |
| 126 | #define GFX2D1_NS_REG REG_MM(0x007C) |
| 127 | #define GFX3D_CC_REG REG_MM(0x0080) |
| 128 | #define GFX3D_MD0_REG REG_MM(0x0084) |
| 129 | #define GFX3D_MD1_REG REG_MM(0x0088) |
| 130 | #define GFX3D_NS_REG REG_MM(0x008C) |
| 131 | #define IJPEG_CC_REG REG_MM(0x0098) |
| 132 | #define IJPEG_MD_REG REG_MM(0x009C) |
| 133 | #define IJPEG_NS_REG REG_MM(0x00A0) |
| 134 | #define JPEGD_CC_REG REG_MM(0x00A4) |
| 135 | #define JPEGD_NS_REG REG_MM(0x00AC) |
| 136 | #define MAXI_EN_REG REG_MM(0x0018) |
Matt Wagantall | f63a889 | 2011-06-15 16:44:46 -0700 | [diff] [blame] | 137 | #define MAXI_EN2_REG REG_MM(0x0020) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 138 | #define MAXI_EN3_REG REG_MM(0x002C) |
| 139 | #define MDP_CC_REG REG_MM(0x00C0) |
| 140 | #define MDP_MD0_REG REG_MM(0x00C4) |
| 141 | #define MDP_MD1_REG REG_MM(0x00C8) |
| 142 | #define MDP_NS_REG REG_MM(0x00D0) |
| 143 | #define MISC_CC_REG REG_MM(0x0058) |
| 144 | #define MISC_CC2_REG REG_MM(0x005C) |
| 145 | #define PIXEL_CC_REG REG_MM(0x00D4) |
| 146 | #define PIXEL_CC2_REG REG_MM(0x0120) |
| 147 | #define PIXEL_MD_REG REG_MM(0x00D8) |
| 148 | #define PIXEL_NS_REG REG_MM(0x00DC) |
| 149 | #define MM_PLL0_MODE_REG REG_MM(0x0300) |
| 150 | #define MM_PLL1_MODE_REG REG_MM(0x031C) |
| 151 | #define MM_PLL2_CONFIG_REG REG_MM(0x0348) |
| 152 | #define MM_PLL2_L_VAL_REG REG_MM(0x033C) |
| 153 | #define MM_PLL2_M_VAL_REG REG_MM(0x0340) |
| 154 | #define MM_PLL2_MODE_REG REG_MM(0x0338) |
| 155 | #define MM_PLL2_N_VAL_REG REG_MM(0x0344) |
| 156 | #define ROT_CC_REG REG_MM(0x00E0) |
| 157 | #define ROT_NS_REG REG_MM(0x00E8) |
| 158 | #define SAXI_EN_REG REG_MM(0x0030) |
| 159 | #define SW_RESET_AHB_REG REG_MM(0x020C) |
| 160 | #define SW_RESET_ALL_REG REG_MM(0x0204) |
| 161 | #define SW_RESET_AXI_REG REG_MM(0x0208) |
| 162 | #define SW_RESET_CORE_REG REG_MM(0x0210) |
| 163 | #define TV_CC_REG REG_MM(0x00EC) |
| 164 | #define TV_CC2_REG REG_MM(0x0124) |
| 165 | #define TV_MD_REG REG_MM(0x00F0) |
| 166 | #define TV_NS_REG REG_MM(0x00F4) |
| 167 | #define VCODEC_CC_REG REG_MM(0x00F8) |
| 168 | #define VCODEC_MD0_REG REG_MM(0x00FC) |
| 169 | #define VCODEC_MD1_REG REG_MM(0x0128) |
| 170 | #define VCODEC_NS_REG REG_MM(0x0100) |
| 171 | #define VFE_CC_REG REG_MM(0x0104) |
| 172 | #define VFE_MD_REG REG_MM(0x0108) |
| 173 | #define VFE_NS_REG REG_MM(0x010C) |
| 174 | #define VPE_CC_REG REG_MM(0x0110) |
| 175 | #define VPE_NS_REG REG_MM(0x0118) |
| 176 | |
| 177 | /* Low-power Audio clock registers. */ |
| 178 | #define LCC_CLK_LS_DEBUG_CFG_REG REG_LPA(0x00A8) |
| 179 | #define LCC_CODEC_I2S_MIC_MD_REG REG_LPA(0x0064) |
| 180 | #define LCC_CODEC_I2S_MIC_NS_REG REG_LPA(0x0060) |
| 181 | #define LCC_CODEC_I2S_MIC_STATUS_REG REG_LPA(0x0068) |
| 182 | #define LCC_CODEC_I2S_SPKR_MD_REG REG_LPA(0x0070) |
| 183 | #define LCC_CODEC_I2S_SPKR_NS_REG REG_LPA(0x006C) |
| 184 | #define LCC_CODEC_I2S_SPKR_STATUS_REG REG_LPA(0x0074) |
| 185 | #define LCC_MI2S_MD_REG REG_LPA(0x004C) |
| 186 | #define LCC_MI2S_NS_REG REG_LPA(0x0048) |
| 187 | #define LCC_MI2S_STATUS_REG REG_LPA(0x0050) |
| 188 | #define LCC_PCM_MD_REG REG_LPA(0x0058) |
| 189 | #define LCC_PCM_NS_REG REG_LPA(0x0054) |
| 190 | #define LCC_PCM_STATUS_REG REG_LPA(0x005C) |
| 191 | #define LCC_PLL0_CONFIG_REG REG_LPA(0x0014) |
| 192 | #define LCC_PLL0_L_VAL_REG REG_LPA(0x0004) |
| 193 | #define LCC_PLL0_M_VAL_REG REG_LPA(0x0008) |
| 194 | #define LCC_PLL0_MODE_REG REG_LPA(0x0000) |
| 195 | #define LCC_PLL0_N_VAL_REG REG_LPA(0x000C) |
| 196 | #define LCC_PRI_PLL_CLK_CTL_REG REG_LPA(0x00C4) |
| 197 | #define LCC_SPARE_I2S_MIC_MD_REG REG_LPA(0x007C) |
| 198 | #define LCC_SPARE_I2S_MIC_NS_REG REG_LPA(0x0078) |
| 199 | #define LCC_SPARE_I2S_MIC_STATUS_REG REG_LPA(0x0080) |
| 200 | #define LCC_SPARE_I2S_SPKR_MD_REG REG_LPA(0x0088) |
| 201 | #define LCC_SPARE_I2S_SPKR_NS_REG REG_LPA(0x0084) |
| 202 | #define LCC_SPARE_I2S_SPKR_STATUS_REG REG_LPA(0x008C) |
| 203 | |
| 204 | /* MUX source input identifiers. */ |
| 205 | #define pxo_to_bb_mux 0 |
| 206 | #define mxo_to_bb_mux 1 |
| 207 | #define cxo_to_bb_mux pxo_to_bb_mux |
| 208 | #define pll0_to_bb_mux 2 |
| 209 | #define pll8_to_bb_mux 3 |
| 210 | #define pll6_to_bb_mux 4 |
| 211 | #define gnd_to_bb_mux 6 |
| 212 | #define pxo_to_mm_mux 0 |
| 213 | #define pll1_to_mm_mux 1 /* or MMSS_PLL0 */ |
| 214 | #define pll2_to_mm_mux 1 /* or MMSS_PLL1 */ |
| 215 | #define pll3_to_mm_mux 3 /* or MMSS_PLL2 */ |
| 216 | #define pll8_to_mm_mux 2 /* or MMSS_GPERF */ |
| 217 | #define pll0_to_mm_mux 3 /* or MMSS_GPLL0 */ |
| 218 | #define mxo_to_mm_mux 4 |
| 219 | #define gnd_to_mm_mux 6 |
| 220 | #define cxo_to_xo_mux 0 |
| 221 | #define pxo_to_xo_mux 1 |
| 222 | #define mxo_to_xo_mux 2 |
| 223 | #define gnd_to_xo_mux 3 |
| 224 | #define pxo_to_lpa_mux 0 |
| 225 | #define cxo_to_lpa_mux 1 |
| 226 | #define pll4_to_lpa_mux 2 /* or LPA_PLL0 */ |
| 227 | #define gnd_to_lpa_mux 6 |
| 228 | |
| 229 | /* Test Vector Macros */ |
| 230 | #define TEST_TYPE_PER_LS 1 |
| 231 | #define TEST_TYPE_PER_HS 2 |
| 232 | #define TEST_TYPE_MM_LS 3 |
| 233 | #define TEST_TYPE_MM_HS 4 |
| 234 | #define TEST_TYPE_LPA 5 |
| 235 | #define TEST_TYPE_SC 6 |
| 236 | #define TEST_TYPE_MM_HS2X 7 |
| 237 | #define TEST_TYPE_SHIFT 24 |
| 238 | #define TEST_CLK_SEL_MASK BM(23, 0) |
| 239 | #define TEST_VECTOR(s, t) (((t) << TEST_TYPE_SHIFT) | BVAL(23, 0, (s))) |
| 240 | #define TEST_PER_LS(s) TEST_VECTOR((s), TEST_TYPE_PER_LS) |
| 241 | #define TEST_PER_HS(s) TEST_VECTOR((s), TEST_TYPE_PER_HS) |
| 242 | #define TEST_MM_LS(s) TEST_VECTOR((s), TEST_TYPE_MM_LS) |
| 243 | #define TEST_MM_HS(s) TEST_VECTOR((s), TEST_TYPE_MM_HS) |
| 244 | #define TEST_LPA(s) TEST_VECTOR((s), TEST_TYPE_LPA) |
| 245 | #define TEST_SC(s) TEST_VECTOR((s), TEST_TYPE_SC) |
| 246 | #define TEST_MM_HS2X(s) TEST_VECTOR((s), TEST_TYPE_MM_HS2X) |
| 247 | |
| 248 | struct pll_rate { |
| 249 | const uint32_t l_val; |
| 250 | const uint32_t m_val; |
| 251 | const uint32_t n_val; |
| 252 | const uint32_t vco; |
| 253 | const uint32_t post_div; |
| 254 | const uint32_t i_bits; |
| 255 | }; |
| 256 | #define PLL_RATE(l, m, n, v, d, i) { l, m, n, v, (d>>1), i } |
| 257 | /* |
| 258 | * Clock frequency definitions and macros |
| 259 | */ |
| 260 | #define MN_MODE_DUAL_EDGE 0x2 |
| 261 | |
| 262 | /* MD Registers */ |
| 263 | #define MD4(m_lsb, m, n_lsb, n) \ |
| 264 | (BVAL((m_lsb+3), m_lsb, m) | BVAL((n_lsb+3), n_lsb, ~(n))) |
| 265 | #define MD8(m_lsb, m, n_lsb, n) \ |
| 266 | (BVAL((m_lsb+7), m_lsb, m) | BVAL((n_lsb+7), n_lsb, ~(n))) |
| 267 | #define MD16(m, n) (BVAL(31, 16, m) | BVAL(15, 0, ~(n))) |
| 268 | |
| 269 | /* NS Registers */ |
| 270 | #define NS(n_msb, n_lsb, n, m, mde_lsb, d_msb, d_lsb, d, s_msb, s_lsb, s) \ |
| 271 | (BVAL(n_msb, n_lsb, ~(n-m)) \ |
| 272 | | (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n)) \ |
| 273 | | BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s)) |
| 274 | |
| 275 | #define NS_MM(n_msb, n_lsb, n, m, d_msb, d_lsb, d, s_msb, s_lsb, s) \ |
| 276 | (BVAL(n_msb, n_lsb, ~(n-m)) | BVAL(d_msb, d_lsb, (d-1)) \ |
| 277 | | BVAL(s_msb, s_lsb, s)) |
| 278 | |
| 279 | #define NS_DIVSRC(d_msb , d_lsb, d, s_msb, s_lsb, s) \ |
| 280 | (BVAL(d_msb, d_lsb, (d-1)) | BVAL(s_msb, s_lsb, s)) |
| 281 | |
| 282 | #define NS_DIV(d_msb , d_lsb, d) \ |
| 283 | BVAL(d_msb, d_lsb, (d-1)) |
| 284 | |
| 285 | #define NS_SRC_SEL(s_msb, s_lsb, s) \ |
| 286 | BVAL(s_msb, s_lsb, s) |
| 287 | |
| 288 | #define NS_MND_BANKED4(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \ |
| 289 | (BVAL((n0_lsb+3), n0_lsb, ~(n-m)) \ |
| 290 | | BVAL((n1_lsb+3), n1_lsb, ~(n-m)) \ |
| 291 | | BVAL((s0_lsb+2), s0_lsb, s) \ |
| 292 | | BVAL((s1_lsb+2), s1_lsb, s)) |
| 293 | |
| 294 | #define NS_MND_BANKED8(n0_lsb, n1_lsb, n, m, s0_lsb, s1_lsb, s) \ |
| 295 | (BVAL((n0_lsb+7), n0_lsb, ~(n-m)) \ |
| 296 | | BVAL((n1_lsb+7), n1_lsb, ~(n-m)) \ |
| 297 | | BVAL((s0_lsb+2), s0_lsb, s) \ |
| 298 | | BVAL((s1_lsb+2), s1_lsb, s)) |
| 299 | |
| 300 | #define NS_DIVSRC_BANKED(d0_msb, d0_lsb, d1_msb, d1_lsb, d, \ |
| 301 | s0_msb, s0_lsb, s1_msb, s1_lsb, s) \ |
| 302 | (BVAL(d0_msb, d0_lsb, (d-1)) | BVAL(d1_msb, d1_lsb, (d-1)) \ |
| 303 | | BVAL(s0_msb, s0_lsb, s) \ |
| 304 | | BVAL(s1_msb, s1_lsb, s)) |
| 305 | |
| 306 | /* CC Registers */ |
| 307 | #define CC(mde_lsb, n) (BVAL((mde_lsb+1), mde_lsb, MN_MODE_DUAL_EDGE) * !!(n)) |
| 308 | #define CC_BANKED(mde0_lsb, mde1_lsb, n) \ |
| 309 | ((BVAL((mde0_lsb+1), mde0_lsb, MN_MODE_DUAL_EDGE) \ |
| 310 | | BVAL((mde1_lsb+1), mde1_lsb, MN_MODE_DUAL_EDGE)) \ |
| 311 | * !!(n)) |
| 312 | |
| 313 | static struct msm_xo_voter *xo_pxo, *xo_cxo; |
| 314 | |
| 315 | static bool xo_clk_is_local(struct clk *clk) |
| 316 | { |
| 317 | return false; |
| 318 | } |
| 319 | |
| 320 | static int pxo_clk_enable(struct clk *clk) |
| 321 | { |
| 322 | return msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_ON); |
| 323 | } |
| 324 | |
| 325 | static void pxo_clk_disable(struct clk *clk) |
| 326 | { |
| 327 | msm_xo_mode_vote(xo_pxo, MSM_XO_MODE_OFF); |
| 328 | } |
| 329 | |
| 330 | static struct clk_ops clk_ops_pxo = { |
| 331 | .enable = pxo_clk_enable, |
| 332 | .disable = pxo_clk_disable, |
| 333 | .get_rate = fixed_clk_get_rate, |
| 334 | .is_local = xo_clk_is_local, |
| 335 | }; |
| 336 | |
| 337 | static struct fixed_clk pxo_clk = { |
| 338 | .rate = 27000000, |
| 339 | .c = { |
| 340 | .dbg_name = "pxo_clk", |
| 341 | .ops = &clk_ops_pxo, |
| 342 | CLK_INIT(pxo_clk.c), |
| 343 | }, |
| 344 | }; |
| 345 | |
| 346 | static int cxo_clk_enable(struct clk *clk) |
| 347 | { |
| 348 | return msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_ON); |
| 349 | } |
| 350 | |
| 351 | static void cxo_clk_disable(struct clk *clk) |
| 352 | { |
| 353 | msm_xo_mode_vote(xo_cxo, MSM_XO_MODE_OFF); |
| 354 | } |
| 355 | |
| 356 | static struct clk_ops clk_ops_cxo = { |
| 357 | .enable = cxo_clk_enable, |
| 358 | .disable = cxo_clk_disable, |
| 359 | .get_rate = fixed_clk_get_rate, |
| 360 | .is_local = xo_clk_is_local, |
| 361 | }; |
| 362 | |
| 363 | static struct fixed_clk cxo_clk = { |
| 364 | .rate = 19200000, |
| 365 | .c = { |
| 366 | .dbg_name = "cxo_clk", |
| 367 | .ops = &clk_ops_cxo, |
| 368 | CLK_INIT(cxo_clk.c), |
| 369 | }, |
| 370 | }; |
| 371 | |
| 372 | static struct pll_vote_clk pll8_clk = { |
| 373 | .rate = 384000000, |
| 374 | .en_reg = BB_PLL_ENA_SC0_REG, |
| 375 | .en_mask = BIT(8), |
| 376 | .status_reg = BB_PLL8_STATUS_REG, |
| 377 | .parent = &pxo_clk.c, |
| 378 | .c = { |
| 379 | .dbg_name = "pll8_clk", |
| 380 | .ops = &clk_ops_pll_vote, |
| 381 | CLK_INIT(pll8_clk.c), |
| 382 | }, |
| 383 | }; |
| 384 | |
| 385 | static struct pll_clk pll2_clk = { |
| 386 | .rate = 800000000, |
| 387 | .mode_reg = MM_PLL1_MODE_REG, |
| 388 | .parent = &pxo_clk.c, |
| 389 | .c = { |
| 390 | .dbg_name = "pll2_clk", |
| 391 | .ops = &clk_ops_pll, |
| 392 | CLK_INIT(pll2_clk.c), |
| 393 | }, |
| 394 | }; |
| 395 | |
| 396 | static struct pll_clk pll3_clk = { |
| 397 | .rate = 0, /* TODO: Detect rate dynamically */ |
| 398 | .mode_reg = MM_PLL2_MODE_REG, |
| 399 | .parent = &pxo_clk.c, |
| 400 | .c = { |
| 401 | .dbg_name = "pll3_clk", |
| 402 | .ops = &clk_ops_pll, |
| 403 | CLK_INIT(pll3_clk.c), |
| 404 | }, |
| 405 | }; |
| 406 | |
| 407 | static int pll4_clk_enable(struct clk *clk) |
| 408 | { |
| 409 | struct msm_rpm_iv_pair iv = { MSM_RPM_ID_PLL_4, 1 }; |
| 410 | return msm_rpm_set_noirq(MSM_RPM_CTX_SET_0, &iv, 1); |
| 411 | } |
| 412 | |
| 413 | static void pll4_clk_disable(struct clk *clk) |
| 414 | { |
| 415 | struct msm_rpm_iv_pair iv = { MSM_RPM_ID_PLL_4, 0 }; |
| 416 | msm_rpm_set_noirq(MSM_RPM_CTX_SET_0, &iv, 1); |
| 417 | } |
| 418 | |
| 419 | static struct clk *pll4_clk_get_parent(struct clk *clk) |
| 420 | { |
| 421 | return &pxo_clk.c; |
| 422 | } |
| 423 | |
| 424 | static bool pll4_clk_is_local(struct clk *clk) |
| 425 | { |
| 426 | return false; |
| 427 | } |
| 428 | |
| 429 | static struct clk_ops clk_ops_pll4 = { |
| 430 | .enable = pll4_clk_enable, |
| 431 | .disable = pll4_clk_disable, |
| 432 | .get_rate = fixed_clk_get_rate, |
| 433 | .get_parent = pll4_clk_get_parent, |
| 434 | .is_local = pll4_clk_is_local, |
| 435 | }; |
| 436 | |
| 437 | static struct fixed_clk pll4_clk = { |
| 438 | .rate = 540672000, |
| 439 | .c = { |
| 440 | .dbg_name = "pll4_clk", |
| 441 | .ops = &clk_ops_pll4, |
| 442 | CLK_INIT(pll4_clk.c), |
| 443 | }, |
| 444 | }; |
| 445 | |
| 446 | /* |
| 447 | * SoC-specific Set-Rate Functions |
| 448 | */ |
| 449 | |
| 450 | /* Unlike other clocks, the TV rate is adjusted through PLL |
| 451 | * re-programming. It is also routed through an MND divider. */ |
| 452 | static void set_rate_tv(struct rcg_clk *clk, struct clk_freq_tbl *nf) |
| 453 | { |
| 454 | struct pll_rate *rate = nf->extra_freq_data; |
| 455 | uint32_t pll_mode, pll_config, misc_cc2; |
| 456 | |
| 457 | /* Disable PLL output. */ |
| 458 | pll_mode = readl_relaxed(MM_PLL2_MODE_REG); |
| 459 | pll_mode &= ~BIT(0); |
| 460 | writel_relaxed(pll_mode, MM_PLL2_MODE_REG); |
| 461 | |
| 462 | /* Assert active-low PLL reset. */ |
| 463 | pll_mode &= ~BIT(2); |
| 464 | writel_relaxed(pll_mode, MM_PLL2_MODE_REG); |
| 465 | |
| 466 | /* Program L, M and N values. */ |
| 467 | writel_relaxed(rate->l_val, MM_PLL2_L_VAL_REG); |
| 468 | writel_relaxed(rate->m_val, MM_PLL2_M_VAL_REG); |
| 469 | writel_relaxed(rate->n_val, MM_PLL2_N_VAL_REG); |
| 470 | |
| 471 | /* Configure MN counter, post-divide, VCO, and i-bits. */ |
| 472 | pll_config = readl_relaxed(MM_PLL2_CONFIG_REG); |
| 473 | pll_config &= ~(BM(22, 20) | BM(18, 0)); |
| 474 | pll_config |= rate->n_val ? BIT(22) : 0; |
| 475 | pll_config |= BVAL(21, 20, rate->post_div); |
| 476 | pll_config |= BVAL(17, 16, rate->vco); |
| 477 | pll_config |= rate->i_bits; |
| 478 | writel_relaxed(pll_config, MM_PLL2_CONFIG_REG); |
| 479 | |
| 480 | /* Configure MND. */ |
| 481 | set_rate_mnd(clk, nf); |
| 482 | |
| 483 | /* Configure hdmi_ref_clk to be equal to the TV clock rate. */ |
| 484 | misc_cc2 = readl_relaxed(MISC_CC2_REG); |
| 485 | misc_cc2 &= ~(BIT(28)|BM(21, 18)); |
| 486 | misc_cc2 |= (BIT(28)|BVAL(21, 18, (nf->ns_val >> 14) & 0x3)); |
| 487 | writel_relaxed(misc_cc2, MISC_CC2_REG); |
| 488 | |
| 489 | /* De-assert active-low PLL reset. */ |
| 490 | pll_mode |= BIT(2); |
| 491 | writel_relaxed(pll_mode, MM_PLL2_MODE_REG); |
| 492 | |
| 493 | /* Enable PLL output. */ |
| 494 | pll_mode |= BIT(0); |
| 495 | writel_relaxed(pll_mode, MM_PLL2_MODE_REG); |
| 496 | } |
| 497 | |
| 498 | /* |
| 499 | * SoC-specific functions required by clock-local driver |
| 500 | */ |
| 501 | |
| 502 | /* Update the sys_vdd voltage given a level. */ |
| 503 | static int msm8660_update_sys_vdd(enum sys_vdd_level level) |
| 504 | { |
| 505 | static const int vdd_uv[] = { |
| 506 | [NONE] = 500000, |
| 507 | [LOW] = 1000000, |
| 508 | [NOMINAL] = 1100000, |
| 509 | [HIGH] = 1200000, |
| 510 | }; |
| 511 | |
| 512 | return rpm_vreg_set_voltage(RPM_VREG_ID_PM8058_S1, RPM_VREG_VOTER3, |
| 513 | vdd_uv[level], vdd_uv[HIGH], 1); |
| 514 | } |
| 515 | |
| 516 | static int soc_clk_reset(struct clk *clk, enum clk_reset_action action) |
| 517 | { |
| 518 | return branch_reset(&to_rcg_clk(clk)->b, action); |
| 519 | } |
| 520 | |
| 521 | static struct clk_ops soc_clk_ops_8x60 = { |
Matt Wagantall | 0625ea0 | 2011-07-13 18:51:56 -0700 | [diff] [blame] | 522 | .enable = rcg_clk_enable, |
| 523 | .disable = rcg_clk_disable, |
| 524 | .auto_off = rcg_clk_auto_off, |
| 525 | .set_rate = rcg_clk_set_rate, |
| 526 | .set_min_rate = rcg_clk_set_min_rate, |
Matt Wagantall | 0625ea0 | 2011-07-13 18:51:56 -0700 | [diff] [blame] | 527 | .get_rate = rcg_clk_get_rate, |
| 528 | .list_rate = rcg_clk_list_rate, |
| 529 | .is_enabled = rcg_clk_is_enabled, |
| 530 | .round_rate = rcg_clk_round_rate, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 531 | .reset = soc_clk_reset, |
| 532 | .is_local = local_clk_is_local, |
Matt Wagantall | 0625ea0 | 2011-07-13 18:51:56 -0700 | [diff] [blame] | 533 | .get_parent = rcg_clk_get_parent, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 534 | }; |
| 535 | |
| 536 | static struct clk_ops clk_ops_branch = { |
| 537 | .enable = branch_clk_enable, |
| 538 | .disable = branch_clk_disable, |
| 539 | .auto_off = branch_clk_auto_off, |
| 540 | .is_enabled = branch_clk_is_enabled, |
| 541 | .reset = branch_clk_reset, |
| 542 | .is_local = local_clk_is_local, |
| 543 | .get_parent = branch_clk_get_parent, |
| 544 | .set_parent = branch_clk_set_parent, |
| 545 | }; |
| 546 | |
| 547 | static struct clk_ops clk_ops_reset = { |
| 548 | .reset = branch_clk_reset, |
| 549 | .is_local = local_clk_is_local, |
| 550 | }; |
| 551 | |
| 552 | /* |
| 553 | * Clock Descriptions |
| 554 | */ |
| 555 | |
| 556 | /* AXI Interfaces */ |
| 557 | static struct branch_clk gmem_axi_clk = { |
| 558 | .b = { |
| 559 | .ctl_reg = MAXI_EN_REG, |
| 560 | .en_mask = BIT(24), |
| 561 | .halt_reg = DBG_BUS_VEC_E_REG, |
| 562 | .halt_bit = 6, |
| 563 | }, |
| 564 | .c = { |
| 565 | .dbg_name = "gmem_axi_clk", |
| 566 | .ops = &clk_ops_branch, |
| 567 | CLK_INIT(gmem_axi_clk.c), |
| 568 | }, |
| 569 | }; |
| 570 | |
| 571 | static struct branch_clk ijpeg_axi_clk = { |
| 572 | .b = { |
| 573 | .ctl_reg = MAXI_EN_REG, |
| 574 | .en_mask = BIT(21), |
| 575 | .reset_reg = SW_RESET_AXI_REG, |
| 576 | .reset_mask = BIT(14), |
| 577 | .halt_reg = DBG_BUS_VEC_E_REG, |
| 578 | .halt_bit = 4, |
| 579 | }, |
| 580 | .c = { |
| 581 | .dbg_name = "ijpeg_axi_clk", |
| 582 | .ops = &clk_ops_branch, |
| 583 | CLK_INIT(ijpeg_axi_clk.c), |
| 584 | }, |
| 585 | }; |
| 586 | |
| 587 | static struct branch_clk imem_axi_clk = { |
| 588 | .b = { |
| 589 | .ctl_reg = MAXI_EN_REG, |
| 590 | .en_mask = BIT(22), |
| 591 | .reset_reg = SW_RESET_CORE_REG, |
| 592 | .reset_mask = BIT(10), |
| 593 | .halt_reg = DBG_BUS_VEC_E_REG, |
| 594 | .halt_bit = 7, |
| 595 | }, |
| 596 | .c = { |
| 597 | .dbg_name = "imem_axi_clk", |
| 598 | .ops = &clk_ops_branch, |
| 599 | CLK_INIT(imem_axi_clk.c), |
| 600 | }, |
| 601 | }; |
| 602 | |
| 603 | static struct branch_clk jpegd_axi_clk = { |
| 604 | .b = { |
| 605 | .ctl_reg = MAXI_EN_REG, |
| 606 | .en_mask = BIT(25), |
| 607 | .halt_reg = DBG_BUS_VEC_E_REG, |
| 608 | .halt_bit = 5, |
| 609 | }, |
| 610 | .c = { |
| 611 | .dbg_name = "jpegd_axi_clk", |
| 612 | .ops = &clk_ops_branch, |
| 613 | CLK_INIT(jpegd_axi_clk.c), |
| 614 | }, |
| 615 | }; |
| 616 | |
| 617 | static struct branch_clk mdp_axi_clk = { |
| 618 | .b = { |
| 619 | .ctl_reg = MAXI_EN_REG, |
| 620 | .en_mask = BIT(23), |
| 621 | .reset_reg = SW_RESET_AXI_REG, |
| 622 | .reset_mask = BIT(13), |
| 623 | .halt_reg = DBG_BUS_VEC_E_REG, |
| 624 | .halt_bit = 8, |
| 625 | }, |
| 626 | .c = { |
| 627 | .dbg_name = "mdp_axi_clk", |
| 628 | .ops = &clk_ops_branch, |
| 629 | CLK_INIT(mdp_axi_clk.c), |
| 630 | }, |
| 631 | }; |
| 632 | |
| 633 | static struct branch_clk vcodec_axi_clk = { |
| 634 | .b = { |
| 635 | .ctl_reg = MAXI_EN_REG, |
| 636 | .en_mask = BIT(19), |
| 637 | .reset_reg = SW_RESET_AXI_REG, |
| 638 | .reset_mask = BIT(4)|BIT(5), |
| 639 | .halt_reg = DBG_BUS_VEC_E_REG, |
| 640 | .halt_bit = 3, |
| 641 | }, |
| 642 | .c = { |
| 643 | .dbg_name = "vcodec_axi_clk", |
| 644 | .ops = &clk_ops_branch, |
| 645 | CLK_INIT(vcodec_axi_clk.c), |
| 646 | }, |
| 647 | }; |
| 648 | |
| 649 | static struct branch_clk vfe_axi_clk = { |
| 650 | .b = { |
| 651 | .ctl_reg = MAXI_EN_REG, |
| 652 | .en_mask = BIT(18), |
| 653 | .reset_reg = SW_RESET_AXI_REG, |
| 654 | .reset_mask = BIT(9), |
| 655 | .halt_reg = DBG_BUS_VEC_E_REG, |
| 656 | .halt_bit = 0, |
| 657 | }, |
| 658 | .c = { |
| 659 | .dbg_name = "vfe_axi_clk", |
| 660 | .ops = &clk_ops_branch, |
| 661 | CLK_INIT(vfe_axi_clk.c), |
| 662 | }, |
| 663 | }; |
| 664 | |
| 665 | static struct branch_clk rot_axi_clk = { |
| 666 | .b = { |
Matt Wagantall | f63a889 | 2011-06-15 16:44:46 -0700 | [diff] [blame] | 667 | .ctl_reg = MAXI_EN2_REG, |
| 668 | .en_mask = BIT(24), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 669 | .reset_reg = SW_RESET_AXI_REG, |
| 670 | .reset_mask = BIT(6), |
Matt Wagantall | f63a889 | 2011-06-15 16:44:46 -0700 | [diff] [blame] | 671 | .halt_reg = DBG_BUS_VEC_E_REG, |
| 672 | .halt_bit = 2, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 673 | }, |
| 674 | .c = { |
| 675 | .dbg_name = "rot_axi_clk", |
Matt Wagantall | f63a889 | 2011-06-15 16:44:46 -0700 | [diff] [blame] | 676 | .ops = &clk_ops_branch, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 677 | CLK_INIT(rot_axi_clk.c), |
| 678 | }, |
| 679 | }; |
| 680 | |
| 681 | static struct branch_clk vpe_axi_clk = { |
| 682 | .b = { |
Matt Wagantall | f63a889 | 2011-06-15 16:44:46 -0700 | [diff] [blame] | 683 | .ctl_reg = MAXI_EN2_REG, |
| 684 | .en_mask = BIT(26), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 685 | .reset_reg = SW_RESET_AXI_REG, |
| 686 | .reset_mask = BIT(15), |
Matt Wagantall | f63a889 | 2011-06-15 16:44:46 -0700 | [diff] [blame] | 687 | .halt_reg = DBG_BUS_VEC_E_REG, |
| 688 | .halt_bit = 1, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 689 | }, |
| 690 | .c = { |
| 691 | .dbg_name = "vpe_axi_clk", |
Matt Wagantall | f63a889 | 2011-06-15 16:44:46 -0700 | [diff] [blame] | 692 | .ops = &clk_ops_branch, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 693 | CLK_INIT(vpe_axi_clk.c), |
| 694 | }, |
| 695 | }; |
| 696 | |
| 697 | /* AHB Interfaces */ |
| 698 | static struct branch_clk amp_p_clk = { |
| 699 | .b = { |
| 700 | .ctl_reg = AHB_EN_REG, |
| 701 | .en_mask = BIT(24), |
| 702 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 703 | .halt_bit = 18, |
| 704 | }, |
| 705 | .c = { |
| 706 | .dbg_name = "amp_p_clk", |
| 707 | .ops = &clk_ops_branch, |
| 708 | CLK_INIT(amp_p_clk.c), |
| 709 | }, |
| 710 | }; |
| 711 | |
| 712 | static struct branch_clk csi0_p_clk = { |
| 713 | .b = { |
| 714 | .ctl_reg = AHB_EN_REG, |
| 715 | .en_mask = BIT(7), |
| 716 | .reset_reg = SW_RESET_AHB_REG, |
| 717 | .reset_mask = BIT(17), |
| 718 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 719 | .halt_bit = 16, |
| 720 | }, |
| 721 | .c = { |
| 722 | .dbg_name = "csi0_p_clk", |
| 723 | .ops = &clk_ops_branch, |
| 724 | CLK_INIT(csi0_p_clk.c), |
| 725 | }, |
| 726 | }; |
| 727 | |
| 728 | static struct branch_clk csi1_p_clk = { |
| 729 | .b = { |
| 730 | .ctl_reg = AHB_EN_REG, |
| 731 | .en_mask = BIT(20), |
| 732 | .reset_reg = SW_RESET_AHB_REG, |
| 733 | .reset_mask = BIT(16), |
| 734 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 735 | .halt_bit = 17, |
| 736 | }, |
| 737 | .c = { |
| 738 | .dbg_name = "csi1_p_clk", |
| 739 | .ops = &clk_ops_branch, |
| 740 | CLK_INIT(csi1_p_clk.c), |
| 741 | }, |
| 742 | }; |
| 743 | |
| 744 | static struct branch_clk dsi_m_p_clk = { |
| 745 | .b = { |
| 746 | .ctl_reg = AHB_EN_REG, |
| 747 | .en_mask = BIT(9), |
| 748 | .reset_reg = SW_RESET_AHB_REG, |
| 749 | .reset_mask = BIT(6), |
| 750 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 751 | .halt_bit = 19, |
| 752 | }, |
| 753 | .c = { |
| 754 | .dbg_name = "dsi_m_p_clk", |
| 755 | .ops = &clk_ops_branch, |
| 756 | CLK_INIT(dsi_m_p_clk.c), |
| 757 | }, |
| 758 | }; |
| 759 | |
| 760 | static struct branch_clk dsi_s_p_clk = { |
| 761 | .b = { |
| 762 | .ctl_reg = AHB_EN_REG, |
| 763 | .en_mask = BIT(18), |
| 764 | .reset_reg = SW_RESET_AHB_REG, |
| 765 | .reset_mask = BIT(5), |
| 766 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 767 | .halt_bit = 20, |
| 768 | }, |
| 769 | .c = { |
| 770 | .dbg_name = "dsi_s_p_clk", |
| 771 | .ops = &clk_ops_branch, |
| 772 | CLK_INIT(dsi_s_p_clk.c), |
| 773 | }, |
| 774 | }; |
| 775 | |
| 776 | static struct branch_clk gfx2d0_p_clk = { |
| 777 | .b = { |
| 778 | .ctl_reg = AHB_EN_REG, |
| 779 | .en_mask = BIT(19), |
| 780 | .reset_reg = SW_RESET_AHB_REG, |
| 781 | .reset_mask = BIT(12), |
| 782 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 783 | .halt_bit = 2, |
| 784 | }, |
| 785 | .c = { |
| 786 | .dbg_name = "gfx2d0_p_clk", |
| 787 | .ops = &clk_ops_branch, |
| 788 | CLK_INIT(gfx2d0_p_clk.c), |
| 789 | }, |
| 790 | }; |
| 791 | |
| 792 | static struct branch_clk gfx2d1_p_clk = { |
| 793 | .b = { |
| 794 | .ctl_reg = AHB_EN_REG, |
| 795 | .en_mask = BIT(2), |
| 796 | .reset_reg = SW_RESET_AHB_REG, |
| 797 | .reset_mask = BIT(11), |
| 798 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 799 | .halt_bit = 3, |
| 800 | }, |
| 801 | .c = { |
| 802 | .dbg_name = "gfx2d1_p_clk", |
| 803 | .ops = &clk_ops_branch, |
| 804 | CLK_INIT(gfx2d1_p_clk.c), |
| 805 | }, |
| 806 | }; |
| 807 | |
| 808 | static struct branch_clk gfx3d_p_clk = { |
| 809 | .b = { |
| 810 | .ctl_reg = AHB_EN_REG, |
| 811 | .en_mask = BIT(3), |
| 812 | .reset_reg = SW_RESET_AHB_REG, |
| 813 | .reset_mask = BIT(10), |
| 814 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 815 | .halt_bit = 4, |
| 816 | }, |
| 817 | .c = { |
| 818 | .dbg_name = "gfx3d_p_clk", |
| 819 | .ops = &clk_ops_branch, |
| 820 | CLK_INIT(gfx3d_p_clk.c), |
| 821 | }, |
| 822 | }; |
| 823 | |
| 824 | static struct branch_clk hdmi_m_p_clk = { |
| 825 | .b = { |
| 826 | .ctl_reg = AHB_EN_REG, |
| 827 | .en_mask = BIT(14), |
| 828 | .reset_reg = SW_RESET_AHB_REG, |
| 829 | .reset_mask = BIT(9), |
| 830 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 831 | .halt_bit = 5, |
| 832 | }, |
| 833 | .c = { |
| 834 | .dbg_name = "hdmi_m_p_clk", |
| 835 | .ops = &clk_ops_branch, |
| 836 | CLK_INIT(hdmi_m_p_clk.c), |
| 837 | }, |
| 838 | }; |
| 839 | |
| 840 | static struct branch_clk hdmi_s_p_clk = { |
| 841 | .b = { |
| 842 | .ctl_reg = AHB_EN_REG, |
| 843 | .en_mask = BIT(4), |
| 844 | .reset_reg = SW_RESET_AHB_REG, |
| 845 | .reset_mask = BIT(9), |
| 846 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 847 | .halt_bit = 6, |
| 848 | }, |
| 849 | .c = { |
| 850 | .dbg_name = "hdmi_s_p_clk", |
| 851 | .ops = &clk_ops_branch, |
| 852 | CLK_INIT(hdmi_s_p_clk.c), |
| 853 | }, |
| 854 | }; |
| 855 | |
| 856 | static struct branch_clk ijpeg_p_clk = { |
| 857 | .b = { |
| 858 | .ctl_reg = AHB_EN_REG, |
| 859 | .en_mask = BIT(5), |
| 860 | .reset_reg = SW_RESET_AHB_REG, |
| 861 | .reset_mask = BIT(7), |
| 862 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 863 | .halt_bit = 9, |
| 864 | }, |
| 865 | .c = { |
| 866 | .dbg_name = "ijpeg_p_clk", |
| 867 | .ops = &clk_ops_branch, |
| 868 | CLK_INIT(ijpeg_p_clk.c), |
| 869 | }, |
| 870 | }; |
| 871 | |
| 872 | static struct branch_clk imem_p_clk = { |
| 873 | .b = { |
| 874 | .ctl_reg = AHB_EN_REG, |
| 875 | .en_mask = BIT(6), |
| 876 | .reset_reg = SW_RESET_AHB_REG, |
| 877 | .reset_mask = BIT(8), |
| 878 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 879 | .halt_bit = 10, |
| 880 | }, |
| 881 | .c = { |
| 882 | .dbg_name = "imem_p_clk", |
| 883 | .ops = &clk_ops_branch, |
| 884 | CLK_INIT(imem_p_clk.c), |
| 885 | }, |
| 886 | }; |
| 887 | |
| 888 | static struct branch_clk jpegd_p_clk = { |
| 889 | .b = { |
| 890 | .ctl_reg = AHB_EN_REG, |
| 891 | .en_mask = BIT(21), |
| 892 | .reset_reg = SW_RESET_AHB_REG, |
| 893 | .reset_mask = BIT(4), |
| 894 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 895 | .halt_bit = 7, |
| 896 | }, |
| 897 | .c = { |
| 898 | .dbg_name = "jpegd_p_clk", |
| 899 | .ops = &clk_ops_branch, |
| 900 | CLK_INIT(jpegd_p_clk.c), |
| 901 | }, |
| 902 | }; |
| 903 | |
| 904 | static struct branch_clk mdp_p_clk = { |
| 905 | .b = { |
| 906 | .ctl_reg = AHB_EN_REG, |
| 907 | .en_mask = BIT(10), |
| 908 | .reset_reg = SW_RESET_AHB_REG, |
| 909 | .reset_mask = BIT(3), |
| 910 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 911 | .halt_bit = 11, |
| 912 | }, |
| 913 | .c = { |
| 914 | .dbg_name = "mdp_p_clk", |
| 915 | .ops = &clk_ops_branch, |
| 916 | CLK_INIT(mdp_p_clk.c), |
| 917 | }, |
| 918 | }; |
| 919 | |
| 920 | static struct branch_clk rot_p_clk = { |
| 921 | .b = { |
| 922 | .ctl_reg = AHB_EN_REG, |
| 923 | .en_mask = BIT(12), |
| 924 | .reset_reg = SW_RESET_AHB_REG, |
| 925 | .reset_mask = BIT(2), |
| 926 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 927 | .halt_bit = 13, |
| 928 | }, |
| 929 | .c = { |
| 930 | .dbg_name = "rot_p_clk", |
| 931 | .ops = &clk_ops_branch, |
| 932 | CLK_INIT(rot_p_clk.c), |
| 933 | }, |
| 934 | }; |
| 935 | |
| 936 | static struct branch_clk smmu_p_clk = { |
| 937 | .b = { |
| 938 | .ctl_reg = AHB_EN_REG, |
| 939 | .en_mask = BIT(15), |
| 940 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 941 | .halt_bit = 22, |
| 942 | }, |
| 943 | .c = { |
| 944 | .dbg_name = "smmu_p_clk", |
| 945 | .ops = &clk_ops_branch, |
| 946 | CLK_INIT(smmu_p_clk.c), |
| 947 | }, |
| 948 | }; |
| 949 | |
| 950 | static struct branch_clk tv_enc_p_clk = { |
| 951 | .b = { |
| 952 | .ctl_reg = AHB_EN_REG, |
| 953 | .en_mask = BIT(25), |
| 954 | .reset_reg = SW_RESET_AHB_REG, |
| 955 | .reset_mask = BIT(15), |
| 956 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 957 | .halt_bit = 23, |
| 958 | }, |
| 959 | .c = { |
| 960 | .dbg_name = "tv_enc_p_clk", |
| 961 | .ops = &clk_ops_branch, |
| 962 | CLK_INIT(tv_enc_p_clk.c), |
| 963 | }, |
| 964 | }; |
| 965 | |
| 966 | static struct branch_clk vcodec_p_clk = { |
| 967 | .b = { |
| 968 | .ctl_reg = AHB_EN_REG, |
| 969 | .en_mask = BIT(11), |
| 970 | .reset_reg = SW_RESET_AHB_REG, |
| 971 | .reset_mask = BIT(1), |
| 972 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 973 | .halt_bit = 12, |
| 974 | }, |
| 975 | .c = { |
| 976 | .dbg_name = "vcodec_p_clk", |
| 977 | .ops = &clk_ops_branch, |
| 978 | CLK_INIT(vcodec_p_clk.c), |
| 979 | }, |
| 980 | }; |
| 981 | |
| 982 | static struct branch_clk vfe_p_clk = { |
| 983 | .b = { |
| 984 | .ctl_reg = AHB_EN_REG, |
| 985 | .en_mask = BIT(13), |
| 986 | .reset_reg = SW_RESET_AHB_REG, |
| 987 | .reset_mask = BIT(0), |
| 988 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 989 | .halt_bit = 14, |
| 990 | }, |
| 991 | .c = { |
| 992 | .dbg_name = "vfe_p_clk", |
| 993 | .ops = &clk_ops_branch, |
| 994 | CLK_INIT(vfe_p_clk.c), |
| 995 | }, |
| 996 | }; |
| 997 | |
| 998 | static struct branch_clk vpe_p_clk = { |
| 999 | .b = { |
| 1000 | .ctl_reg = AHB_EN_REG, |
| 1001 | .en_mask = BIT(16), |
| 1002 | .reset_reg = SW_RESET_AHB_REG, |
| 1003 | .reset_mask = BIT(14), |
| 1004 | .halt_reg = DBG_BUS_VEC_F_REG, |
| 1005 | .halt_bit = 15, |
| 1006 | }, |
| 1007 | .c = { |
| 1008 | .dbg_name = "vpe_p_clk", |
| 1009 | .ops = &clk_ops_branch, |
| 1010 | CLK_INIT(vpe_p_clk.c), |
| 1011 | }, |
| 1012 | }; |
| 1013 | |
| 1014 | /* |
| 1015 | * Peripheral Clocks |
| 1016 | */ |
| 1017 | #define CLK_GSBI_UART(i, n, h_r, h_b) \ |
| 1018 | struct rcg_clk i##_clk = { \ |
| 1019 | .b = { \ |
| 1020 | .ctl_reg = GSBIn_UART_APPS_NS_REG(n), \ |
| 1021 | .en_mask = BIT(9), \ |
| 1022 | .reset_reg = GSBIn_RESET_REG(n), \ |
| 1023 | .reset_mask = BIT(0), \ |
| 1024 | .halt_reg = h_r, \ |
| 1025 | .halt_bit = h_b, \ |
| 1026 | }, \ |
| 1027 | .ns_reg = GSBIn_UART_APPS_NS_REG(n), \ |
| 1028 | .md_reg = GSBIn_UART_APPS_MD_REG(n), \ |
| 1029 | .root_en_mask = BIT(11), \ |
| 1030 | .ns_mask = (BM(31, 16) | BM(6, 0)), \ |
| 1031 | .set_rate = set_rate_mnd, \ |
| 1032 | .freq_tbl = clk_tbl_gsbi_uart, \ |
| 1033 | .current_freq = &local_dummy_freq, \ |
| 1034 | .c = { \ |
| 1035 | .dbg_name = #i "_clk", \ |
| 1036 | .ops = &soc_clk_ops_8x60, \ |
| 1037 | CLK_INIT(i##_clk.c), \ |
| 1038 | }, \ |
| 1039 | } |
| 1040 | #define F_GSBI_UART(f, s, d, m, n, v) \ |
| 1041 | { \ |
| 1042 | .freq_hz = f, \ |
| 1043 | .src_clk = &s##_clk.c, \ |
| 1044 | .md_val = MD16(m, n), \ |
| 1045 | .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \ |
| 1046 | .mnd_en_mask = BIT(8) * !!(n), \ |
| 1047 | .sys_vdd = v, \ |
| 1048 | } |
| 1049 | static struct clk_freq_tbl clk_tbl_gsbi_uart[] = { |
| 1050 | F_GSBI_UART( 0, gnd, 1, 0, 0, NONE), |
| 1051 | F_GSBI_UART( 1843200, pll8, 1, 3, 625, LOW), |
| 1052 | F_GSBI_UART( 3686400, pll8, 1, 6, 625, LOW), |
| 1053 | F_GSBI_UART( 7372800, pll8, 1, 12, 625, LOW), |
| 1054 | F_GSBI_UART(14745600, pll8, 1, 24, 625, LOW), |
| 1055 | F_GSBI_UART(16000000, pll8, 4, 1, 6, LOW), |
| 1056 | F_GSBI_UART(24000000, pll8, 4, 1, 4, LOW), |
| 1057 | F_GSBI_UART(32000000, pll8, 4, 1, 3, LOW), |
| 1058 | F_GSBI_UART(40000000, pll8, 1, 5, 48, NOMINAL), |
| 1059 | F_GSBI_UART(46400000, pll8, 1, 29, 240, NOMINAL), |
| 1060 | F_GSBI_UART(48000000, pll8, 4, 1, 2, NOMINAL), |
| 1061 | F_GSBI_UART(51200000, pll8, 1, 2, 15, NOMINAL), |
| 1062 | F_GSBI_UART(56000000, pll8, 1, 7, 48, NOMINAL), |
| 1063 | F_GSBI_UART(58982400, pll8, 1, 96, 625, NOMINAL), |
| 1064 | F_GSBI_UART(64000000, pll8, 2, 1, 3, NOMINAL), |
| 1065 | F_END |
| 1066 | }; |
| 1067 | |
| 1068 | static CLK_GSBI_UART(gsbi1_uart, 1, CLK_HALT_CFPB_STATEA_REG, 10); |
| 1069 | static CLK_GSBI_UART(gsbi2_uart, 2, CLK_HALT_CFPB_STATEA_REG, 6); |
| 1070 | static CLK_GSBI_UART(gsbi3_uart, 3, CLK_HALT_CFPB_STATEA_REG, 2); |
| 1071 | static CLK_GSBI_UART(gsbi4_uart, 4, CLK_HALT_CFPB_STATEB_REG, 26); |
| 1072 | static CLK_GSBI_UART(gsbi5_uart, 5, CLK_HALT_CFPB_STATEB_REG, 22); |
| 1073 | static CLK_GSBI_UART(gsbi6_uart, 6, CLK_HALT_CFPB_STATEB_REG, 18); |
| 1074 | static CLK_GSBI_UART(gsbi7_uart, 7, CLK_HALT_CFPB_STATEB_REG, 14); |
| 1075 | static CLK_GSBI_UART(gsbi8_uart, 8, CLK_HALT_CFPB_STATEB_REG, 10); |
| 1076 | static CLK_GSBI_UART(gsbi9_uart, 9, CLK_HALT_CFPB_STATEB_REG, 6); |
| 1077 | static CLK_GSBI_UART(gsbi10_uart, 10, CLK_HALT_CFPB_STATEB_REG, 2); |
| 1078 | static CLK_GSBI_UART(gsbi11_uart, 11, CLK_HALT_CFPB_STATEC_REG, 17); |
| 1079 | static CLK_GSBI_UART(gsbi12_uart, 12, CLK_HALT_CFPB_STATEC_REG, 13); |
| 1080 | |
| 1081 | #define CLK_GSBI_QUP(i, n, h_r, h_b) \ |
| 1082 | struct rcg_clk i##_clk = { \ |
| 1083 | .b = { \ |
| 1084 | .ctl_reg = GSBIn_QUP_APPS_NS_REG(n), \ |
| 1085 | .en_mask = BIT(9), \ |
| 1086 | .reset_reg = GSBIn_RESET_REG(n), \ |
| 1087 | .reset_mask = BIT(0), \ |
| 1088 | .halt_reg = h_r, \ |
| 1089 | .halt_bit = h_b, \ |
| 1090 | }, \ |
| 1091 | .ns_reg = GSBIn_QUP_APPS_NS_REG(n), \ |
| 1092 | .md_reg = GSBIn_QUP_APPS_MD_REG(n), \ |
| 1093 | .root_en_mask = BIT(11), \ |
| 1094 | .ns_mask = (BM(23, 16) | BM(6, 0)), \ |
| 1095 | .set_rate = set_rate_mnd, \ |
| 1096 | .freq_tbl = clk_tbl_gsbi_qup, \ |
| 1097 | .current_freq = &local_dummy_freq, \ |
| 1098 | .c = { \ |
| 1099 | .dbg_name = #i "_clk", \ |
| 1100 | .ops = &soc_clk_ops_8x60, \ |
| 1101 | CLK_INIT(i##_clk.c), \ |
| 1102 | }, \ |
| 1103 | } |
| 1104 | #define F_GSBI_QUP(f, s, d, m, n, v) \ |
| 1105 | { \ |
| 1106 | .freq_hz = f, \ |
| 1107 | .src_clk = &s##_clk.c, \ |
| 1108 | .md_val = MD8(16, m, 0, n), \ |
| 1109 | .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \ |
| 1110 | .mnd_en_mask = BIT(8) * !!(n), \ |
| 1111 | .sys_vdd = v, \ |
| 1112 | } |
| 1113 | static struct clk_freq_tbl clk_tbl_gsbi_qup[] = { |
| 1114 | F_GSBI_QUP( 0, gnd, 1, 0, 0, NONE), |
| 1115 | F_GSBI_QUP( 1100000, pxo, 1, 2, 49, LOW), |
| 1116 | F_GSBI_QUP( 5400000, pxo, 1, 1, 5, LOW), |
| 1117 | F_GSBI_QUP(10800000, pxo, 1, 2, 5, LOW), |
| 1118 | F_GSBI_QUP(15060000, pll8, 1, 2, 51, LOW), |
| 1119 | F_GSBI_QUP(24000000, pll8, 4, 1, 4, LOW), |
| 1120 | F_GSBI_QUP(25600000, pll8, 1, 1, 15, NOMINAL), |
| 1121 | F_GSBI_QUP(27000000, pxo, 1, 0, 0, NOMINAL), |
| 1122 | F_GSBI_QUP(48000000, pll8, 4, 1, 2, NOMINAL), |
| 1123 | F_GSBI_QUP(51200000, pll8, 1, 2, 15, NOMINAL), |
| 1124 | F_END |
| 1125 | }; |
| 1126 | |
| 1127 | static CLK_GSBI_QUP(gsbi1_qup, 1, CLK_HALT_CFPB_STATEA_REG, 9); |
| 1128 | static CLK_GSBI_QUP(gsbi2_qup, 2, CLK_HALT_CFPB_STATEA_REG, 4); |
| 1129 | static CLK_GSBI_QUP(gsbi3_qup, 3, CLK_HALT_CFPB_STATEA_REG, 0); |
| 1130 | static CLK_GSBI_QUP(gsbi4_qup, 4, CLK_HALT_CFPB_STATEB_REG, 24); |
| 1131 | static CLK_GSBI_QUP(gsbi5_qup, 5, CLK_HALT_CFPB_STATEB_REG, 20); |
| 1132 | static CLK_GSBI_QUP(gsbi6_qup, 6, CLK_HALT_CFPB_STATEB_REG, 16); |
| 1133 | static CLK_GSBI_QUP(gsbi7_qup, 7, CLK_HALT_CFPB_STATEB_REG, 12); |
| 1134 | static CLK_GSBI_QUP(gsbi8_qup, 8, CLK_HALT_CFPB_STATEB_REG, 8); |
| 1135 | static CLK_GSBI_QUP(gsbi9_qup, 9, CLK_HALT_CFPB_STATEB_REG, 4); |
| 1136 | static CLK_GSBI_QUP(gsbi10_qup, 10, CLK_HALT_CFPB_STATEB_REG, 0); |
| 1137 | static CLK_GSBI_QUP(gsbi11_qup, 11, CLK_HALT_CFPB_STATEC_REG, 15); |
| 1138 | static CLK_GSBI_QUP(gsbi12_qup, 12, CLK_HALT_CFPB_STATEC_REG, 11); |
| 1139 | |
| 1140 | #define F_PDM(f, s, d, v) \ |
| 1141 | { \ |
| 1142 | .freq_hz = f, \ |
| 1143 | .src_clk = &s##_clk.c, \ |
| 1144 | .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \ |
| 1145 | .sys_vdd = v, \ |
| 1146 | } |
| 1147 | static struct clk_freq_tbl clk_tbl_pdm[] = { |
| 1148 | F_PDM( 0, gnd, 1, NONE), |
| 1149 | F_PDM(27000000, pxo, 1, LOW), |
| 1150 | F_END |
| 1151 | }; |
| 1152 | |
| 1153 | static struct rcg_clk pdm_clk = { |
| 1154 | .b = { |
| 1155 | .ctl_reg = PDM_CLK_NS_REG, |
| 1156 | .en_mask = BIT(9), |
| 1157 | .reset_reg = PDM_CLK_NS_REG, |
| 1158 | .reset_mask = BIT(12), |
| 1159 | .halt_reg = CLK_HALT_CFPB_STATEC_REG, |
| 1160 | .halt_bit = 3, |
| 1161 | }, |
| 1162 | .ns_reg = PDM_CLK_NS_REG, |
| 1163 | .root_en_mask = BIT(11), |
| 1164 | .ns_mask = BM(1, 0), |
| 1165 | .set_rate = set_rate_nop, |
| 1166 | .freq_tbl = clk_tbl_pdm, |
| 1167 | .current_freq = &local_dummy_freq, |
| 1168 | .c = { |
| 1169 | .dbg_name = "pdm_clk", |
| 1170 | .ops = &soc_clk_ops_8x60, |
| 1171 | CLK_INIT(pdm_clk.c), |
| 1172 | }, |
| 1173 | }; |
| 1174 | |
| 1175 | static struct branch_clk pmem_clk = { |
| 1176 | .b = { |
| 1177 | .ctl_reg = PMEM_ACLK_CTL_REG, |
| 1178 | .en_mask = BIT(4), |
| 1179 | .halt_reg = CLK_HALT_DFAB_STATE_REG, |
| 1180 | .halt_bit = 20, |
| 1181 | }, |
| 1182 | .c = { |
| 1183 | .dbg_name = "pmem_clk", |
| 1184 | .ops = &clk_ops_branch, |
| 1185 | CLK_INIT(pmem_clk.c), |
| 1186 | }, |
| 1187 | }; |
| 1188 | |
| 1189 | #define F_PRNG(f, s, v) \ |
| 1190 | { \ |
| 1191 | .freq_hz = f, \ |
| 1192 | .src_clk = &s##_clk.c, \ |
| 1193 | .sys_vdd = v, \ |
| 1194 | } |
| 1195 | static struct clk_freq_tbl clk_tbl_prng[] = { |
| 1196 | F_PRNG(64000000, pll8, NOMINAL), |
| 1197 | F_END |
| 1198 | }; |
| 1199 | |
| 1200 | static struct rcg_clk prng_clk = { |
| 1201 | .b = { |
| 1202 | .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG, |
| 1203 | .en_mask = BIT(10), |
| 1204 | .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG, |
| 1205 | .halt_check = HALT_VOTED, |
| 1206 | .halt_bit = 10, |
| 1207 | }, |
| 1208 | .set_rate = set_rate_nop, |
| 1209 | .freq_tbl = clk_tbl_prng, |
| 1210 | .current_freq = &local_dummy_freq, |
| 1211 | .c = { |
| 1212 | .dbg_name = "prng_clk", |
| 1213 | .ops = &soc_clk_ops_8x60, |
| 1214 | CLK_INIT(prng_clk.c), |
| 1215 | }, |
| 1216 | }; |
| 1217 | |
| 1218 | #define CLK_SDC(i, n, h_r, h_b) \ |
| 1219 | struct rcg_clk i##_clk = { \ |
| 1220 | .b = { \ |
| 1221 | .ctl_reg = SDCn_APPS_CLK_NS_REG(n), \ |
| 1222 | .en_mask = BIT(9), \ |
| 1223 | .reset_reg = SDCn_RESET_REG(n), \ |
| 1224 | .reset_mask = BIT(0), \ |
| 1225 | .halt_reg = h_r, \ |
| 1226 | .halt_bit = h_b, \ |
| 1227 | }, \ |
| 1228 | .ns_reg = SDCn_APPS_CLK_NS_REG(n), \ |
| 1229 | .md_reg = SDCn_APPS_CLK_MD_REG(n), \ |
| 1230 | .root_en_mask = BIT(11), \ |
| 1231 | .ns_mask = (BM(23, 16) | BM(6, 0)), \ |
| 1232 | .set_rate = set_rate_mnd, \ |
| 1233 | .freq_tbl = clk_tbl_sdc, \ |
| 1234 | .current_freq = &local_dummy_freq, \ |
| 1235 | .c = { \ |
| 1236 | .dbg_name = #i "_clk", \ |
| 1237 | .ops = &soc_clk_ops_8x60, \ |
| 1238 | CLK_INIT(i##_clk.c), \ |
| 1239 | }, \ |
| 1240 | } |
| 1241 | #define F_SDC(f, s, d, m, n, v) \ |
| 1242 | { \ |
| 1243 | .freq_hz = f, \ |
| 1244 | .src_clk = &s##_clk.c, \ |
| 1245 | .md_val = MD8(16, m, 0, n), \ |
| 1246 | .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \ |
| 1247 | .mnd_en_mask = BIT(8) * !!(n), \ |
| 1248 | .sys_vdd = v, \ |
| 1249 | } |
| 1250 | static struct clk_freq_tbl clk_tbl_sdc[] = { |
| 1251 | F_SDC( 0, gnd, 1, 0, 0, NONE), |
| 1252 | F_SDC( 144000, pxo, 3, 2, 125, LOW), |
| 1253 | F_SDC( 400000, pll8, 4, 1, 240, LOW), |
| 1254 | F_SDC(16000000, pll8, 4, 1, 6, LOW), |
| 1255 | F_SDC(17070000, pll8, 1, 2, 45, LOW), |
| 1256 | F_SDC(20210000, pll8, 1, 1, 19, LOW), |
| 1257 | F_SDC(24000000, pll8, 4, 1, 4, LOW), |
| 1258 | F_SDC(48000000, pll8, 4, 1, 2, NOMINAL), |
| 1259 | F_END |
| 1260 | }; |
| 1261 | |
| 1262 | static CLK_SDC(sdc1, 1, CLK_HALT_DFAB_STATE_REG, 6); |
| 1263 | static CLK_SDC(sdc2, 2, CLK_HALT_DFAB_STATE_REG, 5); |
| 1264 | static CLK_SDC(sdc3, 3, CLK_HALT_DFAB_STATE_REG, 4); |
| 1265 | static CLK_SDC(sdc4, 4, CLK_HALT_DFAB_STATE_REG, 3); |
| 1266 | static CLK_SDC(sdc5, 5, CLK_HALT_DFAB_STATE_REG, 2); |
| 1267 | |
| 1268 | #define F_TSIF_REF(f, s, d, m, n, v) \ |
| 1269 | { \ |
| 1270 | .freq_hz = f, \ |
| 1271 | .src_clk = &s##_clk.c, \ |
| 1272 | .md_val = MD16(m, n), \ |
| 1273 | .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \ |
| 1274 | .mnd_en_mask = BIT(8) * !!(n), \ |
| 1275 | .sys_vdd = v, \ |
| 1276 | } |
| 1277 | static struct clk_freq_tbl clk_tbl_tsif_ref[] = { |
| 1278 | F_TSIF_REF( 0, gnd, 1, 0, 0, NONE), |
| 1279 | F_TSIF_REF(105000, pxo, 1, 1, 256, LOW), |
| 1280 | F_END |
| 1281 | }; |
| 1282 | |
| 1283 | static struct rcg_clk tsif_ref_clk = { |
| 1284 | .b = { |
| 1285 | .ctl_reg = TSIF_REF_CLK_NS_REG, |
| 1286 | .en_mask = BIT(9), |
| 1287 | .halt_reg = CLK_HALT_CFPB_STATEC_REG, |
| 1288 | .halt_bit = 5, |
| 1289 | }, |
| 1290 | .ns_reg = TSIF_REF_CLK_NS_REG, |
| 1291 | .md_reg = TSIF_REF_CLK_MD_REG, |
| 1292 | .root_en_mask = BIT(11), |
| 1293 | .ns_mask = (BM(31, 16) | BM(6, 0)), |
| 1294 | .set_rate = set_rate_mnd, |
| 1295 | .freq_tbl = clk_tbl_tsif_ref, |
| 1296 | .current_freq = &local_dummy_freq, |
| 1297 | .c = { |
| 1298 | .dbg_name = "tsif_ref_clk", |
| 1299 | .ops = &soc_clk_ops_8x60, |
| 1300 | CLK_INIT(tsif_ref_clk.c), |
| 1301 | }, |
| 1302 | }; |
| 1303 | |
| 1304 | #define F_TSSC(f, s, v) \ |
| 1305 | { \ |
| 1306 | .freq_hz = f, \ |
| 1307 | .src_clk = &s##_clk.c, \ |
| 1308 | .ns_val = NS_SRC_SEL(1, 0, s##_to_xo_mux), \ |
| 1309 | .sys_vdd = v, \ |
| 1310 | } |
| 1311 | static struct clk_freq_tbl clk_tbl_tssc[] = { |
| 1312 | F_TSSC( 0, gnd, NONE), |
| 1313 | F_TSSC(27000000, pxo, LOW), |
| 1314 | F_END |
| 1315 | }; |
| 1316 | |
| 1317 | static struct rcg_clk tssc_clk = { |
| 1318 | .b = { |
| 1319 | .ctl_reg = TSSC_CLK_CTL_REG, |
| 1320 | .en_mask = BIT(4), |
| 1321 | .halt_reg = CLK_HALT_CFPB_STATEC_REG, |
| 1322 | .halt_bit = 4, |
| 1323 | }, |
| 1324 | .ns_reg = TSSC_CLK_CTL_REG, |
| 1325 | .ns_mask = BM(1, 0), |
| 1326 | .set_rate = set_rate_nop, |
| 1327 | .freq_tbl = clk_tbl_tssc, |
| 1328 | .current_freq = &local_dummy_freq, |
| 1329 | .c = { |
| 1330 | .dbg_name = "tssc_clk", |
| 1331 | .ops = &soc_clk_ops_8x60, |
| 1332 | CLK_INIT(tssc_clk.c), |
| 1333 | }, |
| 1334 | }; |
| 1335 | |
| 1336 | #define F_USB(f, s, d, m, n, v) \ |
| 1337 | { \ |
| 1338 | .freq_hz = f, \ |
| 1339 | .src_clk = &s##_clk.c, \ |
| 1340 | .md_val = MD8(16, m, 0, n), \ |
| 1341 | .ns_val = NS(23, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_bb_mux), \ |
| 1342 | .mnd_en_mask = BIT(8) * !!(n), \ |
| 1343 | .sys_vdd = v, \ |
| 1344 | } |
| 1345 | static struct clk_freq_tbl clk_tbl_usb[] = { |
| 1346 | F_USB( 0, gnd, 1, 0, 0, NONE), |
| 1347 | F_USB(60000000, pll8, 1, 5, 32, NOMINAL), |
| 1348 | F_END |
| 1349 | }; |
| 1350 | |
| 1351 | static struct rcg_clk usb_hs1_xcvr_clk = { |
| 1352 | .b = { |
| 1353 | .ctl_reg = USB_HS1_XCVR_FS_CLK_NS_REG, |
| 1354 | .en_mask = BIT(9), |
| 1355 | .reset_reg = USB_HS1_RESET_REG, |
| 1356 | .reset_mask = BIT(0), |
| 1357 | .halt_reg = CLK_HALT_DFAB_STATE_REG, |
| 1358 | .halt_bit = 0, |
| 1359 | }, |
| 1360 | .ns_reg = USB_HS1_XCVR_FS_CLK_NS_REG, |
| 1361 | .md_reg = USB_HS1_XCVR_FS_CLK_MD_REG, |
| 1362 | .root_en_mask = BIT(11), |
| 1363 | .ns_mask = (BM(23, 16) | BM(6, 0)), |
| 1364 | .set_rate = set_rate_mnd, |
| 1365 | .freq_tbl = clk_tbl_usb, |
| 1366 | .current_freq = &local_dummy_freq, |
| 1367 | .c = { |
| 1368 | .dbg_name = "usb_hs1_xcvr_clk", |
| 1369 | .ops = &soc_clk_ops_8x60, |
| 1370 | CLK_INIT(usb_hs1_xcvr_clk.c), |
| 1371 | }, |
| 1372 | }; |
| 1373 | |
| 1374 | static struct branch_clk usb_phy0_clk = { |
| 1375 | .b = { |
| 1376 | .reset_reg = USB_PHY0_RESET_REG, |
| 1377 | .reset_mask = BIT(0), |
| 1378 | }, |
| 1379 | .c = { |
| 1380 | .dbg_name = "usb_phy0_clk", |
| 1381 | .ops = &clk_ops_reset, |
| 1382 | CLK_INIT(usb_phy0_clk.c), |
| 1383 | }, |
| 1384 | }; |
| 1385 | |
| 1386 | #define CLK_USB_FS(i, n) \ |
| 1387 | struct rcg_clk i##_clk = { \ |
| 1388 | .ns_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \ |
| 1389 | .b = { \ |
| 1390 | .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(n), \ |
| 1391 | .halt_check = NOCHECK, \ |
| 1392 | }, \ |
| 1393 | .md_reg = USB_FSn_XCVR_FS_CLK_MD_REG(n), \ |
| 1394 | .root_en_mask = BIT(11), \ |
| 1395 | .ns_mask = (BM(23, 16) | BM(6, 0)), \ |
| 1396 | .set_rate = set_rate_mnd, \ |
| 1397 | .freq_tbl = clk_tbl_usb, \ |
| 1398 | .current_freq = &local_dummy_freq, \ |
| 1399 | .c = { \ |
| 1400 | .dbg_name = #i "_clk", \ |
| 1401 | .ops = &soc_clk_ops_8x60, \ |
| 1402 | CLK_INIT(i##_clk.c), \ |
| 1403 | }, \ |
| 1404 | } |
| 1405 | |
| 1406 | static CLK_USB_FS(usb_fs1_src, 1); |
| 1407 | static struct branch_clk usb_fs1_xcvr_clk = { |
| 1408 | .b = { |
| 1409 | .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(1), |
| 1410 | .en_mask = BIT(9), |
| 1411 | .reset_reg = USB_FSn_RESET_REG(1), |
| 1412 | .reset_mask = BIT(1), |
| 1413 | .halt_reg = CLK_HALT_CFPB_STATEA_REG, |
| 1414 | .halt_bit = 15, |
| 1415 | }, |
| 1416 | .parent = &usb_fs1_src_clk.c, |
| 1417 | .c = { |
| 1418 | .dbg_name = "usb_fs1_xcvr_clk", |
| 1419 | .ops = &clk_ops_branch, |
| 1420 | CLK_INIT(usb_fs1_xcvr_clk.c), |
| 1421 | }, |
| 1422 | }; |
| 1423 | |
| 1424 | static struct branch_clk usb_fs1_sys_clk = { |
| 1425 | .b = { |
| 1426 | .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(1), |
| 1427 | .en_mask = BIT(4), |
| 1428 | .reset_reg = USB_FSn_RESET_REG(1), |
| 1429 | .reset_mask = BIT(0), |
| 1430 | .halt_reg = CLK_HALT_CFPB_STATEA_REG, |
| 1431 | .halt_bit = 16, |
| 1432 | }, |
| 1433 | .parent = &usb_fs1_src_clk.c, |
| 1434 | .c = { |
| 1435 | .dbg_name = "usb_fs1_sys_clk", |
| 1436 | .ops = &clk_ops_branch, |
| 1437 | CLK_INIT(usb_fs1_sys_clk.c), |
| 1438 | }, |
| 1439 | }; |
| 1440 | |
| 1441 | static CLK_USB_FS(usb_fs2_src, 2); |
| 1442 | static struct branch_clk usb_fs2_xcvr_clk = { |
| 1443 | .b = { |
| 1444 | .ctl_reg = USB_FSn_XCVR_FS_CLK_NS_REG(2), |
| 1445 | .en_mask = BIT(9), |
| 1446 | .reset_reg = USB_FSn_RESET_REG(2), |
| 1447 | .reset_mask = BIT(1), |
| 1448 | .halt_reg = CLK_HALT_CFPB_STATEA_REG, |
| 1449 | .halt_bit = 12, |
| 1450 | }, |
| 1451 | .parent = &usb_fs2_src_clk.c, |
| 1452 | .c = { |
| 1453 | .dbg_name = "usb_fs2_xcvr_clk", |
| 1454 | .ops = &clk_ops_branch, |
| 1455 | CLK_INIT(usb_fs2_xcvr_clk.c), |
| 1456 | }, |
| 1457 | }; |
| 1458 | |
| 1459 | static struct branch_clk usb_fs2_sys_clk = { |
| 1460 | .b = { |
| 1461 | .ctl_reg = USB_FSn_SYSTEM_CLK_CTL_REG(2), |
| 1462 | .en_mask = BIT(4), |
| 1463 | .reset_reg = USB_FSn_RESET_REG(2), |
| 1464 | .reset_mask = BIT(0), |
| 1465 | .halt_reg = CLK_HALT_CFPB_STATEA_REG, |
| 1466 | .halt_bit = 13, |
| 1467 | }, |
| 1468 | .parent = &usb_fs2_src_clk.c, |
| 1469 | .c = { |
| 1470 | .dbg_name = "usb_fs2_sys_clk", |
| 1471 | .ops = &clk_ops_branch, |
| 1472 | CLK_INIT(usb_fs2_sys_clk.c), |
| 1473 | }, |
| 1474 | }; |
| 1475 | |
| 1476 | /* Fast Peripheral Bus Clocks */ |
| 1477 | static struct branch_clk ce2_p_clk = { |
| 1478 | .b = { |
| 1479 | .ctl_reg = CE2_HCLK_CTL_REG, |
| 1480 | .en_mask = BIT(4), |
| 1481 | .halt_reg = CLK_HALT_CFPB_STATEC_REG, |
| 1482 | .halt_bit = 0, |
| 1483 | }, |
| 1484 | .parent = &pxo_clk.c, |
| 1485 | .c = { |
| 1486 | .dbg_name = "ce2_p_clk", |
| 1487 | .ops = &clk_ops_branch, |
| 1488 | CLK_INIT(ce2_p_clk.c), |
| 1489 | }, |
| 1490 | }; |
| 1491 | |
| 1492 | static struct branch_clk gsbi1_p_clk = { |
| 1493 | .b = { |
| 1494 | .ctl_reg = GSBIn_HCLK_CTL_REG(1), |
| 1495 | .en_mask = BIT(4), |
| 1496 | .halt_reg = CLK_HALT_CFPB_STATEA_REG, |
| 1497 | .halt_bit = 11, |
| 1498 | }, |
| 1499 | .c = { |
| 1500 | .dbg_name = "gsbi1_p_clk", |
| 1501 | .ops = &clk_ops_branch, |
| 1502 | CLK_INIT(gsbi1_p_clk.c), |
| 1503 | }, |
| 1504 | }; |
| 1505 | |
| 1506 | static struct branch_clk gsbi2_p_clk = { |
| 1507 | .b = { |
| 1508 | .ctl_reg = GSBIn_HCLK_CTL_REG(2), |
| 1509 | .en_mask = BIT(4), |
| 1510 | .halt_reg = CLK_HALT_CFPB_STATEA_REG, |
| 1511 | .halt_bit = 7, |
| 1512 | }, |
| 1513 | .c = { |
| 1514 | .dbg_name = "gsbi2_p_clk", |
| 1515 | .ops = &clk_ops_branch, |
| 1516 | CLK_INIT(gsbi2_p_clk.c), |
| 1517 | }, |
| 1518 | }; |
| 1519 | |
| 1520 | static struct branch_clk gsbi3_p_clk = { |
| 1521 | .b = { |
| 1522 | .ctl_reg = GSBIn_HCLK_CTL_REG(3), |
| 1523 | .en_mask = BIT(4), |
| 1524 | .halt_reg = CLK_HALT_CFPB_STATEA_REG, |
| 1525 | .halt_bit = 3, |
| 1526 | }, |
| 1527 | .c = { |
| 1528 | .dbg_name = "gsbi3_p_clk", |
| 1529 | .ops = &clk_ops_branch, |
| 1530 | CLK_INIT(gsbi3_p_clk.c), |
| 1531 | }, |
| 1532 | }; |
| 1533 | |
| 1534 | static struct branch_clk gsbi4_p_clk = { |
| 1535 | .b = { |
| 1536 | .ctl_reg = GSBIn_HCLK_CTL_REG(4), |
| 1537 | .en_mask = BIT(4), |
| 1538 | .halt_reg = CLK_HALT_CFPB_STATEB_REG, |
| 1539 | .halt_bit = 27, |
| 1540 | }, |
| 1541 | .c = { |
| 1542 | .dbg_name = "gsbi4_p_clk", |
| 1543 | .ops = &clk_ops_branch, |
| 1544 | CLK_INIT(gsbi4_p_clk.c), |
| 1545 | }, |
| 1546 | }; |
| 1547 | |
| 1548 | static struct branch_clk gsbi5_p_clk = { |
| 1549 | .b = { |
| 1550 | .ctl_reg = GSBIn_HCLK_CTL_REG(5), |
| 1551 | .en_mask = BIT(4), |
| 1552 | .halt_reg = CLK_HALT_CFPB_STATEB_REG, |
| 1553 | .halt_bit = 23, |
| 1554 | }, |
| 1555 | .c = { |
| 1556 | .dbg_name = "gsbi5_p_clk", |
| 1557 | .ops = &clk_ops_branch, |
| 1558 | CLK_INIT(gsbi5_p_clk.c), |
| 1559 | }, |
| 1560 | }; |
| 1561 | |
| 1562 | static struct branch_clk gsbi6_p_clk = { |
| 1563 | .b = { |
| 1564 | .ctl_reg = GSBIn_HCLK_CTL_REG(6), |
| 1565 | .en_mask = BIT(4), |
| 1566 | .halt_reg = CLK_HALT_CFPB_STATEB_REG, |
| 1567 | .halt_bit = 19, |
| 1568 | }, |
| 1569 | .c = { |
| 1570 | .dbg_name = "gsbi6_p_clk", |
| 1571 | .ops = &clk_ops_branch, |
| 1572 | CLK_INIT(gsbi6_p_clk.c), |
| 1573 | }, |
| 1574 | }; |
| 1575 | |
| 1576 | static struct branch_clk gsbi7_p_clk = { |
| 1577 | .b = { |
| 1578 | .ctl_reg = GSBIn_HCLK_CTL_REG(7), |
| 1579 | .en_mask = BIT(4), |
| 1580 | .halt_reg = CLK_HALT_CFPB_STATEB_REG, |
| 1581 | .halt_bit = 15, |
| 1582 | }, |
| 1583 | .c = { |
| 1584 | .dbg_name = "gsbi7_p_clk", |
| 1585 | .ops = &clk_ops_branch, |
| 1586 | CLK_INIT(gsbi7_p_clk.c), |
| 1587 | }, |
| 1588 | }; |
| 1589 | |
| 1590 | static struct branch_clk gsbi8_p_clk = { |
| 1591 | .b = { |
| 1592 | .ctl_reg = GSBIn_HCLK_CTL_REG(8), |
| 1593 | .en_mask = BIT(4), |
| 1594 | .halt_reg = CLK_HALT_CFPB_STATEB_REG, |
| 1595 | .halt_bit = 11, |
| 1596 | }, |
| 1597 | .c = { |
| 1598 | .dbg_name = "gsbi8_p_clk", |
| 1599 | .ops = &clk_ops_branch, |
| 1600 | CLK_INIT(gsbi8_p_clk.c), |
| 1601 | }, |
| 1602 | }; |
| 1603 | |
| 1604 | static struct branch_clk gsbi9_p_clk = { |
| 1605 | .b = { |
| 1606 | .ctl_reg = GSBIn_HCLK_CTL_REG(9), |
| 1607 | .en_mask = BIT(4), |
| 1608 | .halt_reg = CLK_HALT_CFPB_STATEB_REG, |
| 1609 | .halt_bit = 7, |
| 1610 | }, |
| 1611 | .c = { |
| 1612 | .dbg_name = "gsbi9_p_clk", |
| 1613 | .ops = &clk_ops_branch, |
| 1614 | CLK_INIT(gsbi9_p_clk.c), |
| 1615 | }, |
| 1616 | }; |
| 1617 | |
| 1618 | static struct branch_clk gsbi10_p_clk = { |
| 1619 | .b = { |
| 1620 | .ctl_reg = GSBIn_HCLK_CTL_REG(10), |
| 1621 | .en_mask = BIT(4), |
| 1622 | .halt_reg = CLK_HALT_CFPB_STATEB_REG, |
| 1623 | .halt_bit = 3, |
| 1624 | }, |
| 1625 | .c = { |
| 1626 | .dbg_name = "gsbi10_p_clk", |
| 1627 | .ops = &clk_ops_branch, |
| 1628 | CLK_INIT(gsbi10_p_clk.c), |
| 1629 | }, |
| 1630 | }; |
| 1631 | |
| 1632 | static struct branch_clk gsbi11_p_clk = { |
| 1633 | .b = { |
| 1634 | .ctl_reg = GSBIn_HCLK_CTL_REG(11), |
| 1635 | .en_mask = BIT(4), |
| 1636 | .halt_reg = CLK_HALT_CFPB_STATEC_REG, |
| 1637 | .halt_bit = 18, |
| 1638 | }, |
| 1639 | .c = { |
| 1640 | .dbg_name = "gsbi11_p_clk", |
| 1641 | .ops = &clk_ops_branch, |
| 1642 | CLK_INIT(gsbi11_p_clk.c), |
| 1643 | }, |
| 1644 | }; |
| 1645 | |
| 1646 | static struct branch_clk gsbi12_p_clk = { |
| 1647 | .b = { |
| 1648 | .ctl_reg = GSBIn_HCLK_CTL_REG(12), |
| 1649 | .en_mask = BIT(4), |
| 1650 | .halt_reg = CLK_HALT_CFPB_STATEC_REG, |
| 1651 | .halt_bit = 14, |
| 1652 | }, |
| 1653 | .c = { |
| 1654 | .dbg_name = "gsbi12_p_clk", |
| 1655 | .ops = &clk_ops_branch, |
| 1656 | CLK_INIT(gsbi12_p_clk.c), |
| 1657 | }, |
| 1658 | }; |
| 1659 | |
| 1660 | static struct branch_clk ppss_p_clk = { |
| 1661 | .b = { |
| 1662 | .ctl_reg = PPSS_HCLK_CTL_REG, |
| 1663 | .en_mask = BIT(4), |
| 1664 | .halt_reg = CLK_HALT_DFAB_STATE_REG, |
| 1665 | .halt_bit = 19, |
| 1666 | }, |
| 1667 | .c = { |
| 1668 | .dbg_name = "ppss_p_clk", |
| 1669 | .ops = &clk_ops_branch, |
| 1670 | CLK_INIT(ppss_p_clk.c), |
| 1671 | }, |
| 1672 | }; |
| 1673 | |
| 1674 | static struct branch_clk tsif_p_clk = { |
| 1675 | .b = { |
| 1676 | .ctl_reg = TSIF_HCLK_CTL_REG, |
| 1677 | .en_mask = BIT(4), |
| 1678 | .halt_reg = CLK_HALT_CFPB_STATEC_REG, |
| 1679 | .halt_bit = 7, |
| 1680 | }, |
| 1681 | .c = { |
| 1682 | .dbg_name = "tsif_p_clk", |
| 1683 | .ops = &clk_ops_branch, |
| 1684 | CLK_INIT(tsif_p_clk.c), |
| 1685 | }, |
| 1686 | }; |
| 1687 | |
| 1688 | static struct branch_clk usb_fs1_p_clk = { |
| 1689 | .b = { |
| 1690 | .ctl_reg = USB_FSn_HCLK_CTL_REG(1), |
| 1691 | .en_mask = BIT(4), |
| 1692 | .halt_reg = CLK_HALT_CFPB_STATEA_REG, |
| 1693 | .halt_bit = 17, |
| 1694 | }, |
| 1695 | .c = { |
| 1696 | .dbg_name = "usb_fs1_p_clk", |
| 1697 | .ops = &clk_ops_branch, |
| 1698 | CLK_INIT(usb_fs1_p_clk.c), |
| 1699 | }, |
| 1700 | }; |
| 1701 | |
| 1702 | static struct branch_clk usb_fs2_p_clk = { |
| 1703 | .b = { |
| 1704 | .ctl_reg = USB_FSn_HCLK_CTL_REG(2), |
| 1705 | .en_mask = BIT(4), |
| 1706 | .halt_reg = CLK_HALT_CFPB_STATEA_REG, |
| 1707 | .halt_bit = 14, |
| 1708 | }, |
| 1709 | .c = { |
| 1710 | .dbg_name = "usb_fs2_p_clk", |
| 1711 | .ops = &clk_ops_branch, |
| 1712 | CLK_INIT(usb_fs2_p_clk.c), |
| 1713 | }, |
| 1714 | }; |
| 1715 | |
| 1716 | static struct branch_clk usb_hs1_p_clk = { |
| 1717 | .b = { |
| 1718 | .ctl_reg = USB_HS1_HCLK_CTL_REG, |
| 1719 | .en_mask = BIT(4), |
| 1720 | .halt_reg = CLK_HALT_DFAB_STATE_REG, |
| 1721 | .halt_bit = 1, |
| 1722 | }, |
| 1723 | .c = { |
| 1724 | .dbg_name = "usb_hs1_p_clk", |
| 1725 | .ops = &clk_ops_branch, |
| 1726 | CLK_INIT(usb_hs1_p_clk.c), |
| 1727 | }, |
| 1728 | }; |
| 1729 | |
| 1730 | static struct branch_clk sdc1_p_clk = { |
| 1731 | .b = { |
| 1732 | .ctl_reg = SDCn_HCLK_CTL_REG(1), |
| 1733 | .en_mask = BIT(4), |
| 1734 | .halt_reg = CLK_HALT_DFAB_STATE_REG, |
| 1735 | .halt_bit = 11, |
| 1736 | }, |
| 1737 | .c = { |
| 1738 | .dbg_name = "sdc1_p_clk", |
| 1739 | .ops = &clk_ops_branch, |
| 1740 | CLK_INIT(sdc1_p_clk.c), |
| 1741 | }, |
| 1742 | }; |
| 1743 | |
| 1744 | static struct branch_clk sdc2_p_clk = { |
| 1745 | .b = { |
| 1746 | .ctl_reg = SDCn_HCLK_CTL_REG(2), |
| 1747 | .en_mask = BIT(4), |
| 1748 | .halt_reg = CLK_HALT_DFAB_STATE_REG, |
| 1749 | .halt_bit = 10, |
| 1750 | }, |
| 1751 | .c = { |
| 1752 | .dbg_name = "sdc2_p_clk", |
| 1753 | .ops = &clk_ops_branch, |
| 1754 | CLK_INIT(sdc2_p_clk.c), |
| 1755 | }, |
| 1756 | }; |
| 1757 | |
| 1758 | static struct branch_clk sdc3_p_clk = { |
| 1759 | .b = { |
| 1760 | .ctl_reg = SDCn_HCLK_CTL_REG(3), |
| 1761 | .en_mask = BIT(4), |
| 1762 | .halt_reg = CLK_HALT_DFAB_STATE_REG, |
| 1763 | .halt_bit = 9, |
| 1764 | }, |
| 1765 | .c = { |
| 1766 | .dbg_name = "sdc3_p_clk", |
| 1767 | .ops = &clk_ops_branch, |
| 1768 | CLK_INIT(sdc3_p_clk.c), |
| 1769 | }, |
| 1770 | }; |
| 1771 | |
| 1772 | static struct branch_clk sdc4_p_clk = { |
| 1773 | .b = { |
| 1774 | .ctl_reg = SDCn_HCLK_CTL_REG(4), |
| 1775 | .en_mask = BIT(4), |
| 1776 | .halt_reg = CLK_HALT_DFAB_STATE_REG, |
| 1777 | .halt_bit = 8, |
| 1778 | }, |
| 1779 | .c = { |
| 1780 | .dbg_name = "sdc4_p_clk", |
| 1781 | .ops = &clk_ops_branch, |
| 1782 | CLK_INIT(sdc4_p_clk.c), |
| 1783 | }, |
| 1784 | }; |
| 1785 | |
| 1786 | static struct branch_clk sdc5_p_clk = { |
| 1787 | .b = { |
| 1788 | .ctl_reg = SDCn_HCLK_CTL_REG(5), |
| 1789 | .en_mask = BIT(4), |
| 1790 | .halt_reg = CLK_HALT_DFAB_STATE_REG, |
| 1791 | .halt_bit = 7, |
| 1792 | }, |
| 1793 | .c = { |
| 1794 | .dbg_name = "sdc5_p_clk", |
| 1795 | .ops = &clk_ops_branch, |
| 1796 | CLK_INIT(sdc5_p_clk.c), |
| 1797 | }, |
| 1798 | }; |
| 1799 | |
| 1800 | /* HW-Voteable Clocks */ |
| 1801 | static struct branch_clk adm0_clk = { |
| 1802 | .b = { |
| 1803 | .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG, |
| 1804 | .en_mask = BIT(2), |
| 1805 | .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG, |
| 1806 | .halt_check = HALT_VOTED, |
| 1807 | .halt_bit = 14, |
| 1808 | }, |
| 1809 | .parent = &pxo_clk.c, |
| 1810 | .c = { |
| 1811 | .dbg_name = "adm0_clk", |
| 1812 | .ops = &clk_ops_branch, |
| 1813 | CLK_INIT(adm0_clk.c), |
| 1814 | }, |
| 1815 | }; |
| 1816 | |
| 1817 | static struct branch_clk adm0_p_clk = { |
| 1818 | .b = { |
| 1819 | .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG, |
| 1820 | .en_mask = BIT(3), |
| 1821 | .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG, |
| 1822 | .halt_check = HALT_VOTED, |
| 1823 | .halt_bit = 13, |
| 1824 | }, |
| 1825 | .c = { |
| 1826 | .dbg_name = "adm0_p_clk", |
| 1827 | .ops = &clk_ops_branch, |
| 1828 | CLK_INIT(adm0_p_clk.c), |
| 1829 | }, |
| 1830 | }; |
| 1831 | |
| 1832 | static struct branch_clk adm1_clk = { |
| 1833 | .b = { |
| 1834 | .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG, |
| 1835 | .en_mask = BIT(4), |
| 1836 | .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG, |
| 1837 | .halt_check = HALT_VOTED, |
| 1838 | .halt_bit = 12, |
| 1839 | }, |
| 1840 | .parent = &pxo_clk.c, |
| 1841 | .c = { |
| 1842 | .dbg_name = "adm1_clk", |
| 1843 | .ops = &clk_ops_branch, |
| 1844 | CLK_INIT(adm1_clk.c), |
| 1845 | }, |
| 1846 | }; |
| 1847 | |
| 1848 | static struct branch_clk adm1_p_clk = { |
| 1849 | .b = { |
| 1850 | .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG, |
| 1851 | .en_mask = BIT(5), |
| 1852 | .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG, |
| 1853 | .halt_check = HALT_VOTED, |
| 1854 | .halt_bit = 11, |
| 1855 | }, |
| 1856 | .c = { |
| 1857 | .dbg_name = "adm1_p_clk", |
| 1858 | .ops = &clk_ops_branch, |
| 1859 | CLK_INIT(adm1_p_clk.c), |
| 1860 | }, |
| 1861 | }; |
| 1862 | |
| 1863 | static struct branch_clk modem_ahb1_p_clk = { |
| 1864 | .b = { |
| 1865 | .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG, |
| 1866 | .en_mask = BIT(0), |
| 1867 | .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG, |
| 1868 | .halt_check = HALT_VOTED, |
| 1869 | .halt_bit = 8, |
| 1870 | }, |
| 1871 | .c = { |
| 1872 | .dbg_name = "modem_ahb1_p_clk", |
| 1873 | .ops = &clk_ops_branch, |
| 1874 | CLK_INIT(modem_ahb1_p_clk.c), |
| 1875 | }, |
| 1876 | }; |
| 1877 | |
| 1878 | static struct branch_clk modem_ahb2_p_clk = { |
| 1879 | .b = { |
| 1880 | .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG, |
| 1881 | .en_mask = BIT(1), |
| 1882 | .halt_reg = CLK_HALT_MSS_SMPSS_MISC_STATE_REG, |
| 1883 | .halt_check = HALT_VOTED, |
| 1884 | .halt_bit = 7, |
| 1885 | }, |
| 1886 | .c = { |
| 1887 | .dbg_name = "modem_ahb2_p_clk", |
| 1888 | .ops = &clk_ops_branch, |
| 1889 | CLK_INIT(modem_ahb2_p_clk.c), |
| 1890 | }, |
| 1891 | }; |
| 1892 | |
| 1893 | static struct branch_clk pmic_arb0_p_clk = { |
| 1894 | .b = { |
| 1895 | .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG, |
| 1896 | .en_mask = BIT(8), |
| 1897 | .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG, |
| 1898 | .halt_check = HALT_VOTED, |
| 1899 | .halt_bit = 22, |
| 1900 | }, |
| 1901 | .c = { |
| 1902 | .dbg_name = "pmic_arb0_p_clk", |
| 1903 | .ops = &clk_ops_branch, |
| 1904 | CLK_INIT(pmic_arb0_p_clk.c), |
| 1905 | }, |
| 1906 | }; |
| 1907 | |
| 1908 | static struct branch_clk pmic_arb1_p_clk = { |
| 1909 | .b = { |
| 1910 | .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG, |
| 1911 | .en_mask = BIT(9), |
| 1912 | .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG, |
| 1913 | .halt_check = HALT_VOTED, |
| 1914 | .halt_bit = 21, |
| 1915 | }, |
| 1916 | .c = { |
| 1917 | .dbg_name = "pmic_arb1_p_clk", |
| 1918 | .ops = &clk_ops_branch, |
| 1919 | CLK_INIT(pmic_arb1_p_clk.c), |
| 1920 | }, |
| 1921 | }; |
| 1922 | |
| 1923 | static struct branch_clk pmic_ssbi2_clk = { |
| 1924 | .b = { |
| 1925 | .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG, |
| 1926 | .en_mask = BIT(7), |
| 1927 | .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG, |
| 1928 | .halt_check = HALT_VOTED, |
| 1929 | .halt_bit = 23, |
| 1930 | }, |
| 1931 | .c = { |
| 1932 | .dbg_name = "pmic_ssbi2_clk", |
| 1933 | .ops = &clk_ops_branch, |
| 1934 | CLK_INIT(pmic_ssbi2_clk.c), |
| 1935 | }, |
| 1936 | }; |
| 1937 | |
| 1938 | static struct branch_clk rpm_msg_ram_p_clk = { |
| 1939 | .b = { |
| 1940 | .ctl_reg = SC0_U_CLK_BRANCH_ENA_VOTE_REG, |
| 1941 | .en_mask = BIT(6), |
| 1942 | .halt_reg = CLK_HALT_SFPB_MISC_STATE_REG, |
| 1943 | .halt_check = HALT_VOTED, |
| 1944 | .halt_bit = 12, |
| 1945 | }, |
| 1946 | .c = { |
| 1947 | .dbg_name = "rpm_msg_ram_p_clk", |
| 1948 | .ops = &clk_ops_branch, |
| 1949 | CLK_INIT(rpm_msg_ram_p_clk.c), |
| 1950 | }, |
| 1951 | }; |
| 1952 | |
| 1953 | /* |
| 1954 | * Multimedia Clocks |
| 1955 | */ |
| 1956 | |
| 1957 | static struct branch_clk amp_clk = { |
| 1958 | .b = { |
| 1959 | .reset_reg = SW_RESET_CORE_REG, |
| 1960 | .reset_mask = BIT(20), |
| 1961 | }, |
| 1962 | .c = { |
| 1963 | .dbg_name = "amp_clk", |
| 1964 | .ops = &clk_ops_reset, |
| 1965 | CLK_INIT(amp_clk.c), |
| 1966 | }, |
| 1967 | }; |
| 1968 | |
| 1969 | #define F_CAM(f, s, d, m, n, v) \ |
| 1970 | { \ |
| 1971 | .freq_hz = f, \ |
| 1972 | .src_clk = &s##_clk.c, \ |
| 1973 | .md_val = MD8(8, m, 0, n), \ |
| 1974 | .ns_val = NS_MM(31, 24, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \ |
| 1975 | .ctl_val = CC(6, n), \ |
| 1976 | .mnd_en_mask = BIT(5) * !!(n), \ |
| 1977 | .sys_vdd = v, \ |
| 1978 | } |
| 1979 | static struct clk_freq_tbl clk_tbl_cam[] = { |
| 1980 | F_CAM( 0, gnd, 1, 0, 0, NONE), |
| 1981 | F_CAM( 6000000, pll8, 4, 1, 16, LOW), |
| 1982 | F_CAM( 8000000, pll8, 4, 1, 12, LOW), |
| 1983 | F_CAM( 12000000, pll8, 4, 1, 8, LOW), |
| 1984 | F_CAM( 16000000, pll8, 4, 1, 6, LOW), |
| 1985 | F_CAM( 19200000, pll8, 4, 1, 5, LOW), |
| 1986 | F_CAM( 24000000, pll8, 4, 1, 4, LOW), |
| 1987 | F_CAM( 32000000, pll8, 4, 1, 3, LOW), |
| 1988 | F_CAM( 48000000, pll8, 4, 1, 2, LOW), |
| 1989 | F_CAM( 64000000, pll8, 3, 1, 2, LOW), |
| 1990 | F_CAM( 96000000, pll8, 4, 0, 0, NOMINAL), |
| 1991 | F_CAM(128000000, pll8, 3, 0, 0, NOMINAL), |
| 1992 | F_END |
| 1993 | }; |
| 1994 | |
| 1995 | static struct rcg_clk cam_clk = { |
| 1996 | .b = { |
| 1997 | .ctl_reg = CAMCLK_CC_REG, |
| 1998 | .en_mask = BIT(0), |
| 1999 | .halt_check = DELAY, |
| 2000 | }, |
| 2001 | .ns_reg = CAMCLK_NS_REG, |
| 2002 | .md_reg = CAMCLK_MD_REG, |
| 2003 | .root_en_mask = BIT(2), |
| 2004 | .ns_mask = (BM(31, 24) | BM(15, 14) | BM(2, 0)), |
| 2005 | .ctl_mask = BM(7, 6), |
| 2006 | .set_rate = set_rate_mnd_8, |
| 2007 | .freq_tbl = clk_tbl_cam, |
| 2008 | .current_freq = &local_dummy_freq, |
| 2009 | .c = { |
| 2010 | .dbg_name = "cam_clk", |
| 2011 | .ops = &soc_clk_ops_8x60, |
| 2012 | CLK_INIT(cam_clk.c), |
| 2013 | }, |
| 2014 | }; |
| 2015 | |
| 2016 | #define F_CSI(f, s, d, v) \ |
| 2017 | { \ |
| 2018 | .freq_hz = f, \ |
| 2019 | .src_clk = &s##_clk.c, \ |
| 2020 | .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \ |
| 2021 | .sys_vdd = v, \ |
| 2022 | } |
| 2023 | static struct clk_freq_tbl clk_tbl_csi[] = { |
| 2024 | F_CSI( 0, gnd, 1, NONE), |
| 2025 | F_CSI(192000000, pll8, 2, LOW), |
| 2026 | F_CSI(384000000, pll8, 1, NOMINAL), |
| 2027 | F_END |
| 2028 | }; |
| 2029 | |
| 2030 | static struct rcg_clk csi_src_clk = { |
| 2031 | .ns_reg = CSI_NS_REG, |
| 2032 | .b = { |
| 2033 | .ctl_reg = CSI_CC_REG, |
| 2034 | .halt_check = NOCHECK, |
| 2035 | }, |
| 2036 | .root_en_mask = BIT(2), |
| 2037 | .ns_mask = (BM(15, 12) | BM(2, 0)), |
| 2038 | .set_rate = set_rate_nop, |
| 2039 | .freq_tbl = clk_tbl_csi, |
| 2040 | .current_freq = &local_dummy_freq, |
| 2041 | .c = { |
| 2042 | .dbg_name = "csi_src_clk", |
| 2043 | .ops = &soc_clk_ops_8x60, |
| 2044 | CLK_INIT(csi_src_clk.c), |
| 2045 | }, |
| 2046 | }; |
| 2047 | |
| 2048 | static struct branch_clk csi0_clk = { |
| 2049 | .b = { |
| 2050 | .ctl_reg = CSI_CC_REG, |
| 2051 | .en_mask = BIT(0), |
| 2052 | .reset_reg = SW_RESET_CORE_REG, |
| 2053 | .reset_mask = BIT(8), |
| 2054 | .halt_reg = DBG_BUS_VEC_B_REG, |
| 2055 | .halt_bit = 13, |
| 2056 | }, |
| 2057 | .parent = &csi_src_clk.c, |
| 2058 | .c = { |
| 2059 | .dbg_name = "csi0_clk", |
| 2060 | .ops = &clk_ops_branch, |
| 2061 | CLK_INIT(csi0_clk.c), |
| 2062 | }, |
| 2063 | }; |
| 2064 | |
| 2065 | static struct branch_clk csi1_clk = { |
| 2066 | .b = { |
| 2067 | .ctl_reg = CSI_CC_REG, |
| 2068 | .en_mask = BIT(7), |
| 2069 | .reset_reg = SW_RESET_CORE_REG, |
| 2070 | .reset_mask = BIT(18), |
| 2071 | .halt_reg = DBG_BUS_VEC_B_REG, |
| 2072 | .halt_bit = 14, |
| 2073 | }, |
| 2074 | .parent = &csi_src_clk.c, |
| 2075 | .c = { |
| 2076 | .dbg_name = "csi1_clk", |
| 2077 | .ops = &clk_ops_branch, |
| 2078 | CLK_INIT(csi1_clk.c), |
| 2079 | }, |
| 2080 | }; |
| 2081 | |
| 2082 | #define F_DSI(d) \ |
| 2083 | { \ |
| 2084 | .freq_hz = d, \ |
| 2085 | .ns_val = BVAL(27, 24, (d-1)), \ |
| 2086 | } |
| 2087 | /* The DSI_BYTE clock is sourced from the DSI PHY PLL, which may change rate |
| 2088 | * without this clock driver knowing. So, overload the clk_set_rate() to set |
| 2089 | * the divider (1 to 16) of the clock with respect to the PLL rate. */ |
| 2090 | static struct clk_freq_tbl clk_tbl_dsi_byte[] = { |
| 2091 | F_DSI(1), F_DSI(2), F_DSI(3), F_DSI(4), |
| 2092 | F_DSI(5), F_DSI(6), F_DSI(7), F_DSI(8), |
| 2093 | F_DSI(9), F_DSI(10), F_DSI(11), F_DSI(12), |
| 2094 | F_DSI(13), F_DSI(14), F_DSI(15), F_DSI(16), |
| 2095 | F_END |
| 2096 | }; |
| 2097 | |
| 2098 | |
| 2099 | static struct rcg_clk dsi_byte_clk = { |
| 2100 | .b = { |
| 2101 | .ctl_reg = MISC_CC_REG, |
| 2102 | .halt_check = DELAY, |
| 2103 | .reset_reg = SW_RESET_CORE_REG, |
| 2104 | .reset_mask = BIT(7), |
| 2105 | }, |
| 2106 | .ns_reg = MISC_CC2_REG, |
| 2107 | .root_en_mask = BIT(2), |
| 2108 | .ns_mask = BM(27, 24), |
| 2109 | .set_rate = set_rate_nop, |
| 2110 | .freq_tbl = clk_tbl_dsi_byte, |
| 2111 | .current_freq = &local_dummy_freq, |
| 2112 | .c = { |
| 2113 | .dbg_name = "dsi_byte_clk", |
| 2114 | .ops = &soc_clk_ops_8x60, |
| 2115 | CLK_INIT(dsi_byte_clk.c), |
| 2116 | }, |
| 2117 | }; |
| 2118 | |
| 2119 | static struct branch_clk dsi_esc_clk = { |
| 2120 | .b = { |
| 2121 | .ctl_reg = MISC_CC_REG, |
| 2122 | .en_mask = BIT(0), |
| 2123 | .halt_reg = DBG_BUS_VEC_B_REG, |
| 2124 | .halt_bit = 24, |
| 2125 | }, |
| 2126 | .c = { |
| 2127 | .dbg_name = "dsi_esc_clk", |
| 2128 | .ops = &clk_ops_branch, |
| 2129 | CLK_INIT(dsi_esc_clk.c), |
| 2130 | }, |
| 2131 | }; |
| 2132 | |
| 2133 | #define F_GFX2D(f, s, m, n, v) \ |
| 2134 | { \ |
| 2135 | .freq_hz = f, \ |
| 2136 | .src_clk = &s##_clk.c, \ |
| 2137 | .md_val = MD4(4, m, 0, n), \ |
| 2138 | .ns_val = NS_MND_BANKED4(20, 16, n, m, 3, 0, s##_to_mm_mux), \ |
| 2139 | .ctl_val = CC_BANKED(9, 6, n), \ |
| 2140 | .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \ |
| 2141 | .sys_vdd = v, \ |
| 2142 | } |
| 2143 | static struct clk_freq_tbl clk_tbl_gfx2d[] = { |
| 2144 | F_GFX2D( 0, gnd, 0, 0, NONE), |
| 2145 | F_GFX2D( 27000000, pxo, 0, 0, LOW), |
| 2146 | F_GFX2D( 48000000, pll8, 1, 8, LOW), |
| 2147 | F_GFX2D( 54857000, pll8, 1, 7, LOW), |
| 2148 | F_GFX2D( 64000000, pll8, 1, 6, LOW), |
| 2149 | F_GFX2D( 76800000, pll8, 1, 5, LOW), |
| 2150 | F_GFX2D( 96000000, pll8, 1, 4, LOW), |
| 2151 | F_GFX2D(128000000, pll8, 1, 3, NOMINAL), |
| 2152 | F_GFX2D(145455000, pll2, 2, 11, NOMINAL), |
| 2153 | F_GFX2D(160000000, pll2, 1, 5, NOMINAL), |
| 2154 | F_GFX2D(177778000, pll2, 2, 9, NOMINAL), |
| 2155 | F_GFX2D(200000000, pll2, 1, 4, NOMINAL), |
| 2156 | F_GFX2D(228571000, pll2, 2, 7, HIGH), |
| 2157 | F_END |
| 2158 | }; |
| 2159 | |
| 2160 | static struct bank_masks bmnd_info_gfx2d0 = { |
| 2161 | .bank_sel_mask = BIT(11), |
| 2162 | .bank0_mask = { |
| 2163 | .md_reg = GFX2D0_MD0_REG, |
| 2164 | .ns_mask = BM(23, 20) | BM(5, 3), |
| 2165 | .rst_mask = BIT(25), |
| 2166 | .mnd_en_mask = BIT(8), |
| 2167 | .mode_mask = BM(10, 9), |
| 2168 | }, |
| 2169 | .bank1_mask = { |
| 2170 | .md_reg = GFX2D0_MD1_REG, |
| 2171 | .ns_mask = BM(19, 16) | BM(2, 0), |
| 2172 | .rst_mask = BIT(24), |
| 2173 | .mnd_en_mask = BIT(5), |
| 2174 | .mode_mask = BM(7, 6), |
| 2175 | }, |
| 2176 | }; |
| 2177 | |
| 2178 | static struct rcg_clk gfx2d0_clk = { |
| 2179 | .b = { |
| 2180 | .ctl_reg = GFX2D0_CC_REG, |
| 2181 | .en_mask = BIT(0), |
| 2182 | .reset_reg = SW_RESET_CORE_REG, |
| 2183 | .reset_mask = BIT(14), |
| 2184 | .halt_reg = DBG_BUS_VEC_A_REG, |
| 2185 | .halt_bit = 9, |
| 2186 | }, |
| 2187 | .ns_reg = GFX2D0_NS_REG, |
| 2188 | .root_en_mask = BIT(2), |
| 2189 | .set_rate = set_rate_mnd_banked, |
| 2190 | .freq_tbl = clk_tbl_gfx2d, |
| 2191 | .bank_masks = &bmnd_info_gfx2d0, |
| 2192 | .current_freq = &local_dummy_freq, |
| 2193 | .c = { |
| 2194 | .dbg_name = "gfx2d0_clk", |
| 2195 | .ops = &soc_clk_ops_8x60, |
| 2196 | CLK_INIT(gfx2d0_clk.c), |
| 2197 | }, |
| 2198 | }; |
| 2199 | |
| 2200 | static struct bank_masks bmnd_info_gfx2d1 = { |
| 2201 | .bank_sel_mask = BIT(11), |
| 2202 | .bank0_mask = { |
| 2203 | .md_reg = GFX2D1_MD0_REG, |
| 2204 | .ns_mask = BM(23, 20) | BM(5, 3), |
| 2205 | .rst_mask = BIT(25), |
| 2206 | .mnd_en_mask = BIT(8), |
| 2207 | .mode_mask = BM(10, 9), |
| 2208 | }, |
| 2209 | .bank1_mask = { |
| 2210 | .md_reg = GFX2D1_MD1_REG, |
| 2211 | .ns_mask = BM(19, 16) | BM(2, 0), |
| 2212 | .rst_mask = BIT(24), |
| 2213 | .mnd_en_mask = BIT(5), |
| 2214 | .mode_mask = BM(7, 6), |
| 2215 | }, |
| 2216 | }; |
| 2217 | |
| 2218 | static struct rcg_clk gfx2d1_clk = { |
| 2219 | .b = { |
| 2220 | .ctl_reg = GFX2D1_CC_REG, |
| 2221 | .en_mask = BIT(0), |
| 2222 | .reset_reg = SW_RESET_CORE_REG, |
| 2223 | .reset_mask = BIT(13), |
| 2224 | .halt_reg = DBG_BUS_VEC_A_REG, |
| 2225 | .halt_bit = 14, |
| 2226 | }, |
| 2227 | .ns_reg = GFX2D1_NS_REG, |
| 2228 | .root_en_mask = BIT(2), |
| 2229 | .set_rate = set_rate_mnd_banked, |
| 2230 | .freq_tbl = clk_tbl_gfx2d, |
| 2231 | .bank_masks = &bmnd_info_gfx2d1, |
| 2232 | .current_freq = &local_dummy_freq, |
| 2233 | .c = { |
| 2234 | .dbg_name = "gfx2d1_clk", |
| 2235 | .ops = &soc_clk_ops_8x60, |
| 2236 | CLK_INIT(gfx2d1_clk.c), |
| 2237 | }, |
| 2238 | }; |
| 2239 | |
| 2240 | #define F_GFX3D(f, s, m, n, v) \ |
| 2241 | { \ |
| 2242 | .freq_hz = f, \ |
| 2243 | .src_clk = &s##_clk.c, \ |
| 2244 | .md_val = MD4(4, m, 0, n), \ |
| 2245 | .ns_val = NS_MND_BANKED4(18, 14, n, m, 3, 0, s##_to_mm_mux), \ |
| 2246 | .ctl_val = CC_BANKED(9, 6, n), \ |
| 2247 | .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \ |
| 2248 | .sys_vdd = v, \ |
| 2249 | } |
| 2250 | static struct clk_freq_tbl clk_tbl_gfx3d[] = { |
| 2251 | F_GFX3D( 0, gnd, 0, 0, NONE), |
| 2252 | F_GFX3D( 27000000, pxo, 0, 0, LOW), |
| 2253 | F_GFX3D( 48000000, pll8, 1, 8, LOW), |
| 2254 | F_GFX3D( 54857000, pll8, 1, 7, LOW), |
| 2255 | F_GFX3D( 64000000, pll8, 1, 6, LOW), |
| 2256 | F_GFX3D( 76800000, pll8, 1, 5, LOW), |
| 2257 | F_GFX3D( 96000000, pll8, 1, 4, LOW), |
| 2258 | F_GFX3D(128000000, pll8, 1, 3, NOMINAL), |
| 2259 | F_GFX3D(145455000, pll2, 2, 11, NOMINAL), |
| 2260 | F_GFX3D(160000000, pll2, 1, 5, NOMINAL), |
| 2261 | F_GFX3D(177778000, pll2, 2, 9, NOMINAL), |
| 2262 | F_GFX3D(200000000, pll2, 1, 4, NOMINAL), |
| 2263 | F_GFX3D(228571000, pll2, 2, 7, HIGH), |
| 2264 | F_GFX3D(266667000, pll2, 1, 3, HIGH), |
| 2265 | F_GFX3D(320000000, pll2, 2, 5, HIGH), |
| 2266 | F_END |
| 2267 | }; |
| 2268 | |
| 2269 | static struct bank_masks bmnd_info_gfx3d = { |
| 2270 | .bank_sel_mask = BIT(11), |
| 2271 | .bank0_mask = { |
| 2272 | .md_reg = GFX3D_MD0_REG, |
| 2273 | .ns_mask = BM(21, 18) | BM(5, 3), |
| 2274 | .rst_mask = BIT(23), |
| 2275 | .mnd_en_mask = BIT(8), |
| 2276 | .mode_mask = BM(10, 9), |
| 2277 | }, |
| 2278 | .bank1_mask = { |
| 2279 | .md_reg = GFX3D_MD1_REG, |
| 2280 | .ns_mask = BM(17, 14) | BM(2, 0), |
| 2281 | .rst_mask = BIT(22), |
| 2282 | .mnd_en_mask = BIT(5), |
| 2283 | .mode_mask = BM(7, 6), |
| 2284 | }, |
| 2285 | }; |
| 2286 | |
| 2287 | static struct rcg_clk gfx3d_clk = { |
| 2288 | .b = { |
| 2289 | .ctl_reg = GFX3D_CC_REG, |
| 2290 | .en_mask = BIT(0), |
| 2291 | .reset_reg = SW_RESET_CORE_REG, |
| 2292 | .reset_mask = BIT(12), |
| 2293 | .halt_reg = DBG_BUS_VEC_A_REG, |
| 2294 | .halt_bit = 4, |
| 2295 | }, |
| 2296 | .ns_reg = GFX3D_NS_REG, |
| 2297 | .root_en_mask = BIT(2), |
| 2298 | .set_rate = set_rate_mnd_banked, |
| 2299 | .freq_tbl = clk_tbl_gfx3d, |
| 2300 | .bank_masks = &bmnd_info_gfx3d, |
| 2301 | .depends = &gmem_axi_clk.c, |
| 2302 | .current_freq = &local_dummy_freq, |
| 2303 | .c = { |
| 2304 | .dbg_name = "gfx3d_clk", |
| 2305 | .ops = &soc_clk_ops_8x60, |
| 2306 | CLK_INIT(gfx3d_clk.c), |
| 2307 | }, |
| 2308 | }; |
| 2309 | |
| 2310 | #define F_IJPEG(f, s, d, m, n, v) \ |
| 2311 | { \ |
| 2312 | .freq_hz = f, \ |
| 2313 | .src_clk = &s##_clk.c, \ |
| 2314 | .md_val = MD8(8, m, 0, n), \ |
| 2315 | .ns_val = NS_MM(23, 16, n, m, 15, 12, d, 2, 0, s##_to_mm_mux), \ |
| 2316 | .ctl_val = CC(6, n), \ |
| 2317 | .mnd_en_mask = BIT(5) * !!n, \ |
| 2318 | .sys_vdd = v, \ |
| 2319 | } |
| 2320 | static struct clk_freq_tbl clk_tbl_ijpeg[] = { |
| 2321 | F_IJPEG( 0, gnd, 1, 0, 0, NONE), |
| 2322 | F_IJPEG( 27000000, pxo, 1, 0, 0, LOW), |
| 2323 | F_IJPEG( 36570000, pll8, 1, 2, 21, LOW), |
| 2324 | F_IJPEG( 54860000, pll8, 7, 0, 0, LOW), |
| 2325 | F_IJPEG( 96000000, pll8, 4, 0, 0, LOW), |
| 2326 | F_IJPEG(109710000, pll8, 1, 2, 7, LOW), |
| 2327 | F_IJPEG(128000000, pll8, 3, 0, 0, NOMINAL), |
| 2328 | F_IJPEG(153600000, pll8, 1, 2, 5, NOMINAL), |
| 2329 | F_IJPEG(200000000, pll2, 4, 0, 0, NOMINAL), |
| 2330 | F_IJPEG(228571000, pll2, 1, 2, 7, NOMINAL), |
| 2331 | F_END |
| 2332 | }; |
| 2333 | |
| 2334 | static struct rcg_clk ijpeg_clk = { |
| 2335 | .b = { |
| 2336 | .ctl_reg = IJPEG_CC_REG, |
| 2337 | .en_mask = BIT(0), |
| 2338 | .reset_reg = SW_RESET_CORE_REG, |
| 2339 | .reset_mask = BIT(9), |
| 2340 | .halt_reg = DBG_BUS_VEC_A_REG, |
| 2341 | .halt_bit = 24, |
| 2342 | }, |
| 2343 | .ns_reg = IJPEG_NS_REG, |
| 2344 | .md_reg = IJPEG_MD_REG, |
| 2345 | .root_en_mask = BIT(2), |
| 2346 | .ns_mask = (BM(23, 16) | BM(15, 12) | BM(2, 0)), |
| 2347 | .ctl_mask = BM(7, 6), |
| 2348 | .set_rate = set_rate_mnd, |
| 2349 | .freq_tbl = clk_tbl_ijpeg, |
| 2350 | .depends = &ijpeg_axi_clk.c, |
| 2351 | .current_freq = &local_dummy_freq, |
| 2352 | .c = { |
| 2353 | .dbg_name = "ijpeg_clk", |
| 2354 | .ops = &soc_clk_ops_8x60, |
| 2355 | CLK_INIT(ijpeg_clk.c), |
| 2356 | }, |
| 2357 | }; |
| 2358 | |
| 2359 | #define F_JPEGD(f, s, d, v) \ |
| 2360 | { \ |
| 2361 | .freq_hz = f, \ |
| 2362 | .src_clk = &s##_clk.c, \ |
| 2363 | .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \ |
| 2364 | .sys_vdd = v, \ |
| 2365 | } |
| 2366 | static struct clk_freq_tbl clk_tbl_jpegd[] = { |
| 2367 | F_JPEGD( 0, gnd, 1, NONE), |
| 2368 | F_JPEGD( 64000000, pll8, 6, LOW), |
| 2369 | F_JPEGD( 76800000, pll8, 5, LOW), |
| 2370 | F_JPEGD( 96000000, pll8, 4, LOW), |
| 2371 | F_JPEGD(160000000, pll2, 5, NOMINAL), |
| 2372 | F_JPEGD(200000000, pll2, 4, NOMINAL), |
| 2373 | F_END |
| 2374 | }; |
| 2375 | |
| 2376 | static struct rcg_clk jpegd_clk = { |
| 2377 | .b = { |
| 2378 | .ctl_reg = JPEGD_CC_REG, |
| 2379 | .en_mask = BIT(0), |
| 2380 | .reset_reg = SW_RESET_CORE_REG, |
| 2381 | .reset_mask = BIT(19), |
| 2382 | .halt_reg = DBG_BUS_VEC_A_REG, |
| 2383 | .halt_bit = 19, |
| 2384 | }, |
| 2385 | .ns_reg = JPEGD_NS_REG, |
| 2386 | .root_en_mask = BIT(2), |
| 2387 | .ns_mask = (BM(15, 12) | BM(2, 0)), |
| 2388 | .set_rate = set_rate_nop, |
| 2389 | .freq_tbl = clk_tbl_jpegd, |
| 2390 | .depends = &jpegd_axi_clk.c, |
| 2391 | .current_freq = &local_dummy_freq, |
| 2392 | .c = { |
| 2393 | .dbg_name = "jpegd_clk", |
| 2394 | .ops = &soc_clk_ops_8x60, |
| 2395 | CLK_INIT(jpegd_clk.c), |
| 2396 | }, |
| 2397 | }; |
| 2398 | |
| 2399 | #define F_MDP(f, s, m, n, v) \ |
| 2400 | { \ |
| 2401 | .freq_hz = f, \ |
| 2402 | .src_clk = &s##_clk.c, \ |
| 2403 | .md_val = MD8(8, m, 0, n), \ |
| 2404 | .ns_val = NS_MND_BANKED8(22, 14, n, m, 3, 0, s##_to_mm_mux), \ |
| 2405 | .ctl_val = CC_BANKED(9, 6, n), \ |
| 2406 | .mnd_en_mask = (BIT(8) | BIT(5)) * !!(n), \ |
| 2407 | .sys_vdd = v, \ |
| 2408 | } |
| 2409 | static struct clk_freq_tbl clk_tbl_mdp[] = { |
| 2410 | F_MDP( 0, gnd, 0, 0, NONE), |
| 2411 | F_MDP( 9600000, pll8, 1, 40, LOW), |
| 2412 | F_MDP( 13710000, pll8, 1, 28, LOW), |
| 2413 | F_MDP( 27000000, pxo, 0, 0, LOW), |
| 2414 | F_MDP( 29540000, pll8, 1, 13, LOW), |
| 2415 | F_MDP( 34910000, pll8, 1, 11, LOW), |
| 2416 | F_MDP( 38400000, pll8, 1, 10, LOW), |
| 2417 | F_MDP( 59080000, pll8, 2, 13, LOW), |
| 2418 | F_MDP( 76800000, pll8, 1, 5, LOW), |
| 2419 | F_MDP( 85330000, pll8, 2, 9, LOW), |
| 2420 | F_MDP( 96000000, pll8, 1, 4, NOMINAL), |
| 2421 | F_MDP(128000000, pll8, 1, 3, NOMINAL), |
| 2422 | F_MDP(160000000, pll2, 1, 5, NOMINAL), |
| 2423 | F_MDP(177780000, pll2, 2, 9, NOMINAL), |
| 2424 | F_MDP(200000000, pll2, 1, 4, NOMINAL), |
| 2425 | F_END |
| 2426 | }; |
| 2427 | |
| 2428 | static struct bank_masks bmnd_info_mdp = { |
| 2429 | .bank_sel_mask = BIT(11), |
| 2430 | .bank0_mask = { |
| 2431 | .md_reg = MDP_MD0_REG, |
| 2432 | .ns_mask = BM(29, 22) | BM(5, 3), |
| 2433 | .rst_mask = BIT(31), |
| 2434 | .mnd_en_mask = BIT(8), |
| 2435 | .mode_mask = BM(10, 9), |
| 2436 | }, |
| 2437 | .bank1_mask = { |
| 2438 | .md_reg = MDP_MD1_REG, |
| 2439 | .ns_mask = BM(21, 14) | BM(2, 0), |
| 2440 | .rst_mask = BIT(30), |
| 2441 | .mnd_en_mask = BIT(5), |
| 2442 | .mode_mask = BM(7, 6), |
| 2443 | }, |
| 2444 | }; |
| 2445 | |
| 2446 | static struct rcg_clk mdp_clk = { |
| 2447 | .b = { |
| 2448 | .ctl_reg = MDP_CC_REG, |
| 2449 | .en_mask = BIT(0), |
| 2450 | .reset_reg = SW_RESET_CORE_REG, |
| 2451 | .reset_mask = BIT(21), |
| 2452 | .halt_reg = DBG_BUS_VEC_C_REG, |
| 2453 | .halt_bit = 10, |
| 2454 | }, |
| 2455 | .ns_reg = MDP_NS_REG, |
| 2456 | .root_en_mask = BIT(2), |
| 2457 | .set_rate = set_rate_mnd_banked, |
| 2458 | .freq_tbl = clk_tbl_mdp, |
| 2459 | .bank_masks = &bmnd_info_mdp, |
| 2460 | .depends = &mdp_axi_clk.c, |
| 2461 | .current_freq = &local_dummy_freq, |
| 2462 | .c = { |
| 2463 | .dbg_name = "mdp_clk", |
| 2464 | .ops = &soc_clk_ops_8x60, |
| 2465 | CLK_INIT(mdp_clk.c), |
| 2466 | }, |
| 2467 | }; |
| 2468 | |
| 2469 | #define F_MDP_VSYNC(f, s, v) \ |
| 2470 | { \ |
| 2471 | .freq_hz = f, \ |
| 2472 | .src_clk = &s##_clk.c, \ |
| 2473 | .ns_val = NS_SRC_SEL(13, 13, s##_to_bb_mux), \ |
| 2474 | .sys_vdd = v, \ |
| 2475 | } |
| 2476 | static struct clk_freq_tbl clk_tbl_mdp_vsync[] = { |
| 2477 | F_MDP_VSYNC(27000000, pxo, LOW), |
| 2478 | F_END |
| 2479 | }; |
| 2480 | |
| 2481 | static struct rcg_clk mdp_vsync_clk = { |
| 2482 | .b = { |
| 2483 | .ctl_reg = MISC_CC_REG, |
| 2484 | .en_mask = BIT(6), |
| 2485 | .reset_reg = SW_RESET_CORE_REG, |
| 2486 | .reset_mask = BIT(3), |
| 2487 | .halt_reg = DBG_BUS_VEC_B_REG, |
| 2488 | .halt_bit = 22, |
| 2489 | }, |
| 2490 | .ns_reg = MISC_CC2_REG, |
| 2491 | .ns_mask = BIT(13), |
| 2492 | .set_rate = set_rate_nop, |
| 2493 | .freq_tbl = clk_tbl_mdp_vsync, |
| 2494 | .current_freq = &local_dummy_freq, |
| 2495 | .c = { |
| 2496 | .dbg_name = "mdp_vsync_clk", |
| 2497 | .ops = &soc_clk_ops_8x60, |
| 2498 | CLK_INIT(mdp_vsync_clk.c), |
| 2499 | }, |
| 2500 | }; |
| 2501 | |
| 2502 | #define F_PIXEL_MDP(f, s, d, m, n, v) \ |
| 2503 | { \ |
| 2504 | .freq_hz = f, \ |
| 2505 | .src_clk = &s##_clk.c, \ |
| 2506 | .md_val = MD16(m, n), \ |
| 2507 | .ns_val = NS_MM(31, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \ |
| 2508 | .ctl_val = CC(6, n), \ |
| 2509 | .mnd_en_mask = BIT(5) * !!(n), \ |
| 2510 | .sys_vdd = v, \ |
| 2511 | } |
| 2512 | static struct clk_freq_tbl clk_tbl_pixel_mdp[] = { |
| 2513 | F_PIXEL_MDP( 0, gnd, 1, 0, 0, NONE), |
| 2514 | F_PIXEL_MDP( 25600000, pll8, 3, 1, 5, LOW), |
| 2515 | F_PIXEL_MDP( 42667000, pll8, 1, 1, 9, LOW), |
| 2516 | F_PIXEL_MDP( 43192000, pll8, 1, 64, 569, LOW), |
| 2517 | F_PIXEL_MDP( 48000000, pll8, 4, 1, 2, LOW), |
| 2518 | F_PIXEL_MDP( 53990000, pll8, 2, 169, 601, LOW), |
| 2519 | F_PIXEL_MDP( 64000000, pll8, 2, 1, 3, LOW), |
| 2520 | F_PIXEL_MDP( 69300000, pll8, 1, 231, 1280, LOW), |
| 2521 | F_PIXEL_MDP( 76800000, pll8, 1, 1, 5, LOW), |
| 2522 | F_PIXEL_MDP( 85333000, pll8, 1, 2, 9, LOW), |
| 2523 | F_PIXEL_MDP(106500000, pll8, 1, 71, 256, NOMINAL), |
| 2524 | F_PIXEL_MDP(109714000, pll8, 1, 2, 7, NOMINAL), |
| 2525 | F_END |
| 2526 | }; |
| 2527 | |
| 2528 | static struct rcg_clk pixel_mdp_clk = { |
| 2529 | .ns_reg = PIXEL_NS_REG, |
| 2530 | .md_reg = PIXEL_MD_REG, |
| 2531 | .b = { |
| 2532 | .ctl_reg = PIXEL_CC_REG, |
| 2533 | .en_mask = BIT(0), |
| 2534 | .reset_reg = SW_RESET_CORE_REG, |
| 2535 | .reset_mask = BIT(5), |
| 2536 | .halt_reg = DBG_BUS_VEC_C_REG, |
| 2537 | .halt_bit = 23, |
| 2538 | }, |
| 2539 | .root_en_mask = BIT(2), |
| 2540 | .ns_mask = (BM(31, 16) | BM(15, 14) | BM(2, 0)), |
| 2541 | .ctl_mask = BM(7, 6), |
| 2542 | .set_rate = set_rate_mnd, |
| 2543 | .freq_tbl = clk_tbl_pixel_mdp, |
| 2544 | .current_freq = &local_dummy_freq, |
| 2545 | .c = { |
| 2546 | .dbg_name = "pixel_mdp_clk", |
| 2547 | .ops = &soc_clk_ops_8x60, |
| 2548 | CLK_INIT(pixel_mdp_clk.c), |
| 2549 | }, |
| 2550 | }; |
| 2551 | |
| 2552 | static struct branch_clk pixel_lcdc_clk = { |
| 2553 | .b = { |
| 2554 | .ctl_reg = PIXEL_CC_REG, |
| 2555 | .en_mask = BIT(8), |
| 2556 | .halt_reg = DBG_BUS_VEC_C_REG, |
| 2557 | .halt_bit = 21, |
| 2558 | }, |
| 2559 | .parent = &pixel_mdp_clk.c, |
| 2560 | .c = { |
| 2561 | .dbg_name = "pixel_lcdc_clk", |
| 2562 | .ops = &clk_ops_branch, |
| 2563 | CLK_INIT(pixel_lcdc_clk.c), |
| 2564 | }, |
| 2565 | }; |
| 2566 | |
| 2567 | #define F_ROT(f, s, d, v) \ |
| 2568 | { \ |
| 2569 | .freq_hz = f, \ |
| 2570 | .src_clk = &s##_clk.c, \ |
| 2571 | .ns_val = NS_DIVSRC_BANKED(29, 26, 25, 22, d, \ |
| 2572 | 21, 19, 18, 16, s##_to_mm_mux), \ |
| 2573 | .sys_vdd = v, \ |
| 2574 | } |
| 2575 | static struct clk_freq_tbl clk_tbl_rot[] = { |
| 2576 | F_ROT( 0, gnd, 1, NONE), |
| 2577 | F_ROT( 27000000, pxo, 1, LOW), |
| 2578 | F_ROT( 29540000, pll8, 13, LOW), |
| 2579 | F_ROT( 32000000, pll8, 12, LOW), |
| 2580 | F_ROT( 38400000, pll8, 10, LOW), |
| 2581 | F_ROT( 48000000, pll8, 8, LOW), |
| 2582 | F_ROT( 54860000, pll8, 7, LOW), |
| 2583 | F_ROT( 64000000, pll8, 6, LOW), |
| 2584 | F_ROT( 76800000, pll8, 5, LOW), |
| 2585 | F_ROT( 96000000, pll8, 4, NOMINAL), |
| 2586 | F_ROT(100000000, pll2, 8, NOMINAL), |
| 2587 | F_ROT(114290000, pll2, 7, NOMINAL), |
| 2588 | F_ROT(133330000, pll2, 6, NOMINAL), |
| 2589 | F_ROT(160000000, pll2, 5, NOMINAL), |
| 2590 | F_END |
| 2591 | }; |
| 2592 | |
| 2593 | static struct bank_masks bdiv_info_rot = { |
| 2594 | .bank_sel_mask = BIT(30), |
| 2595 | .bank0_mask = { |
| 2596 | .ns_mask = BM(25, 22) | BM(18, 16), |
| 2597 | }, |
| 2598 | .bank1_mask = { |
| 2599 | .ns_mask = BM(29, 26) | BM(21, 19), |
| 2600 | }, |
| 2601 | }; |
| 2602 | |
| 2603 | static struct rcg_clk rot_clk = { |
| 2604 | .b = { |
| 2605 | .ctl_reg = ROT_CC_REG, |
| 2606 | .en_mask = BIT(0), |
| 2607 | .reset_reg = SW_RESET_CORE_REG, |
| 2608 | .reset_mask = BIT(2), |
| 2609 | .halt_reg = DBG_BUS_VEC_C_REG, |
| 2610 | .halt_bit = 15, |
| 2611 | }, |
| 2612 | .ns_reg = ROT_NS_REG, |
| 2613 | .root_en_mask = BIT(2), |
| 2614 | .set_rate = set_rate_div_banked, |
| 2615 | .freq_tbl = clk_tbl_rot, |
| 2616 | .bank_masks = &bdiv_info_rot, |
Matt Wagantall | f63a889 | 2011-06-15 16:44:46 -0700 | [diff] [blame] | 2617 | .depends = &rot_axi_clk.c, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2618 | .current_freq = &local_dummy_freq, |
| 2619 | .c = { |
| 2620 | .dbg_name = "rot_clk", |
| 2621 | .ops = &soc_clk_ops_8x60, |
| 2622 | CLK_INIT(rot_clk.c), |
| 2623 | }, |
| 2624 | }; |
| 2625 | |
| 2626 | #define F_TV(f, s, p_r, d, m, n, v) \ |
| 2627 | { \ |
| 2628 | .freq_hz = f, \ |
| 2629 | .src_clk = &s##_clk.c, \ |
| 2630 | .md_val = MD8(8, m, 0, n), \ |
| 2631 | .ns_val = NS_MM(23, 16, n, m, 15, 14, d, 2, 0, s##_to_mm_mux), \ |
| 2632 | .ctl_val = CC(6, n), \ |
| 2633 | .mnd_en_mask = BIT(5) * !!(n), \ |
| 2634 | .sys_vdd = v, \ |
| 2635 | .extra_freq_data = p_r, \ |
| 2636 | } |
| 2637 | /* Switching TV freqs requires PLL reconfiguration. */ |
| 2638 | static struct pll_rate mm_pll2_rate[] = { |
| 2639 | [0] = PLL_RATE( 7, 6301, 13500, 0, 4, 0x4248B), /* 50400500 Hz */ |
| 2640 | [1] = PLL_RATE( 8, 0, 0, 0, 4, 0x4248B), /* 54000000 Hz */ |
| 2641 | [2] = PLL_RATE(16, 2, 125, 0, 4, 0x5248F), /* 108108000 Hz */ |
| 2642 | [3] = PLL_RATE(22, 0, 0, 2, 4, 0x6248B), /* 148500000 Hz */ |
| 2643 | [4] = PLL_RATE(44, 0, 0, 2, 4, 0x6248F), /* 297000000 Hz */ |
| 2644 | }; |
| 2645 | static struct clk_freq_tbl clk_tbl_tv[] = { |
| 2646 | F_TV( 0, gnd, &mm_pll2_rate[0], 1, 0, 0, NONE), |
| 2647 | F_TV( 25200000, pll3, &mm_pll2_rate[0], 2, 0, 0, LOW), |
| 2648 | F_TV( 27000000, pll3, &mm_pll2_rate[1], 2, 0, 0, LOW), |
| 2649 | F_TV( 27030000, pll3, &mm_pll2_rate[2], 4, 0, 0, LOW), |
| 2650 | F_TV( 74250000, pll3, &mm_pll2_rate[3], 2, 0, 0, NOMINAL), |
| 2651 | F_TV(148500000, pll3, &mm_pll2_rate[4], 2, 0, 0, NOMINAL), |
| 2652 | F_END |
| 2653 | }; |
| 2654 | |
| 2655 | static struct rcg_clk tv_src_clk = { |
| 2656 | .ns_reg = TV_NS_REG, |
| 2657 | .b = { |
| 2658 | .ctl_reg = TV_CC_REG, |
| 2659 | .halt_check = NOCHECK, |
| 2660 | }, |
| 2661 | .md_reg = TV_MD_REG, |
| 2662 | .root_en_mask = BIT(2), |
| 2663 | .ns_mask = (BM(23, 16) | BM(15, 14) | BM(2, 0)), |
| 2664 | .ctl_mask = BM(7, 6), |
| 2665 | .set_rate = set_rate_tv, |
| 2666 | .freq_tbl = clk_tbl_tv, |
| 2667 | .current_freq = &local_dummy_freq, |
| 2668 | .c = { |
| 2669 | .dbg_name = "tv_src_clk", |
| 2670 | .ops = &soc_clk_ops_8x60, |
| 2671 | CLK_INIT(tv_src_clk.c), |
| 2672 | }, |
| 2673 | }; |
| 2674 | |
| 2675 | static struct branch_clk tv_enc_clk = { |
| 2676 | .b = { |
| 2677 | .ctl_reg = TV_CC_REG, |
| 2678 | .en_mask = BIT(8), |
| 2679 | .reset_reg = SW_RESET_CORE_REG, |
| 2680 | .reset_mask = BIT(0), |
| 2681 | .halt_reg = DBG_BUS_VEC_D_REG, |
| 2682 | .halt_bit = 8, |
| 2683 | }, |
| 2684 | .parent = &tv_src_clk.c, |
| 2685 | .c = { |
| 2686 | .dbg_name = "tv_enc_clk", |
| 2687 | .ops = &clk_ops_branch, |
| 2688 | CLK_INIT(tv_enc_clk.c), |
| 2689 | }, |
| 2690 | }; |
| 2691 | |
| 2692 | static struct branch_clk tv_dac_clk = { |
| 2693 | .b = { |
| 2694 | .ctl_reg = TV_CC_REG, |
| 2695 | .en_mask = BIT(10), |
| 2696 | .halt_reg = DBG_BUS_VEC_D_REG, |
| 2697 | .halt_bit = 9, |
| 2698 | }, |
| 2699 | .parent = &tv_src_clk.c, |
| 2700 | .c = { |
| 2701 | .dbg_name = "tv_dac_clk", |
| 2702 | .ops = &clk_ops_branch, |
| 2703 | CLK_INIT(tv_dac_clk.c), |
| 2704 | }, |
| 2705 | }; |
| 2706 | |
| 2707 | static struct branch_clk mdp_tv_clk = { |
| 2708 | .b = { |
| 2709 | .ctl_reg = TV_CC_REG, |
| 2710 | .en_mask = BIT(0), |
| 2711 | .reset_reg = SW_RESET_CORE_REG, |
| 2712 | .reset_mask = BIT(4), |
| 2713 | .halt_reg = DBG_BUS_VEC_D_REG, |
| 2714 | .halt_bit = 11, |
| 2715 | }, |
| 2716 | .parent = &tv_src_clk.c, |
| 2717 | .c = { |
| 2718 | .dbg_name = "mdp_tv_clk", |
| 2719 | .ops = &clk_ops_branch, |
| 2720 | CLK_INIT(mdp_tv_clk.c), |
| 2721 | }, |
| 2722 | }; |
| 2723 | |
| 2724 | static struct branch_clk hdmi_tv_clk = { |
| 2725 | .b = { |
| 2726 | .ctl_reg = TV_CC_REG, |
| 2727 | .en_mask = BIT(12), |
| 2728 | .reset_reg = SW_RESET_CORE_REG, |
| 2729 | .reset_mask = BIT(1), |
| 2730 | .halt_reg = DBG_BUS_VEC_D_REG, |
| 2731 | .halt_bit = 10, |
| 2732 | }, |
| 2733 | .parent = &tv_src_clk.c, |
| 2734 | .c = { |
| 2735 | .dbg_name = "hdmi_tv_clk", |
| 2736 | .ops = &clk_ops_branch, |
| 2737 | CLK_INIT(hdmi_tv_clk.c), |
| 2738 | }, |
| 2739 | }; |
| 2740 | |
| 2741 | static struct branch_clk hdmi_app_clk = { |
| 2742 | .b = { |
| 2743 | .ctl_reg = MISC_CC2_REG, |
| 2744 | .en_mask = BIT(11), |
| 2745 | .reset_reg = SW_RESET_CORE_REG, |
| 2746 | .reset_mask = BIT(11), |
| 2747 | .halt_reg = DBG_BUS_VEC_B_REG, |
| 2748 | .halt_bit = 25, |
| 2749 | }, |
| 2750 | .c = { |
| 2751 | .dbg_name = "hdmi_app_clk", |
| 2752 | .ops = &clk_ops_branch, |
| 2753 | CLK_INIT(hdmi_app_clk.c), |
| 2754 | }, |
| 2755 | }; |
| 2756 | |
| 2757 | #define F_VCODEC(f, s, m, n, v) \ |
| 2758 | { \ |
| 2759 | .freq_hz = f, \ |
| 2760 | .src_clk = &s##_clk.c, \ |
| 2761 | .md_val = MD8(8, m, 0, n), \ |
| 2762 | .ns_val = NS_MM(18, 11, n, m, 0, 0, 1, 2, 0, s##_to_mm_mux), \ |
| 2763 | .ctl_val = CC(6, n), \ |
| 2764 | .mnd_en_mask = BIT(5) * !!(n), \ |
| 2765 | .sys_vdd = v, \ |
| 2766 | } |
| 2767 | static struct clk_freq_tbl clk_tbl_vcodec[] = { |
| 2768 | F_VCODEC( 0, gnd, 0, 0, NONE), |
| 2769 | F_VCODEC( 27000000, pxo, 0, 0, LOW), |
| 2770 | F_VCODEC( 32000000, pll8, 1, 12, LOW), |
| 2771 | F_VCODEC( 48000000, pll8, 1, 8, LOW), |
| 2772 | F_VCODEC( 54860000, pll8, 1, 7, LOW), |
| 2773 | F_VCODEC( 96000000, pll8, 1, 4, LOW), |
| 2774 | F_VCODEC(133330000, pll2, 1, 6, NOMINAL), |
| 2775 | F_VCODEC(200000000, pll2, 1, 4, NOMINAL), |
| 2776 | F_VCODEC(228570000, pll2, 2, 7, HIGH), |
| 2777 | F_END |
| 2778 | }; |
| 2779 | |
| 2780 | static struct rcg_clk vcodec_clk = { |
| 2781 | .b = { |
| 2782 | .ctl_reg = VCODEC_CC_REG, |
| 2783 | .en_mask = BIT(0), |
| 2784 | .reset_reg = SW_RESET_CORE_REG, |
| 2785 | .reset_mask = BIT(6), |
| 2786 | .halt_reg = DBG_BUS_VEC_C_REG, |
| 2787 | .halt_bit = 29, |
| 2788 | }, |
| 2789 | .ns_reg = VCODEC_NS_REG, |
| 2790 | .md_reg = VCODEC_MD0_REG, |
| 2791 | .root_en_mask = BIT(2), |
| 2792 | .ns_mask = (BM(18, 11) | BM(2, 0)), |
| 2793 | .ctl_mask = BM(7, 6), |
| 2794 | .set_rate = set_rate_mnd, |
| 2795 | .freq_tbl = clk_tbl_vcodec, |
| 2796 | .depends = &vcodec_axi_clk.c, |
| 2797 | .current_freq = &local_dummy_freq, |
| 2798 | .c = { |
| 2799 | .dbg_name = "vcodec_clk", |
| 2800 | .ops = &soc_clk_ops_8x60, |
| 2801 | CLK_INIT(vcodec_clk.c), |
| 2802 | }, |
| 2803 | }; |
| 2804 | |
| 2805 | #define F_VPE(f, s, d, v) \ |
| 2806 | { \ |
| 2807 | .freq_hz = f, \ |
| 2808 | .src_clk = &s##_clk.c, \ |
| 2809 | .ns_val = NS_DIVSRC(15, 12, d, 2, 0, s##_to_mm_mux), \ |
| 2810 | .sys_vdd = v, \ |
| 2811 | } |
| 2812 | static struct clk_freq_tbl clk_tbl_vpe[] = { |
| 2813 | F_VPE( 0, gnd, 1, NONE), |
| 2814 | F_VPE( 27000000, pxo, 1, LOW), |
| 2815 | F_VPE( 34909000, pll8, 11, LOW), |
| 2816 | F_VPE( 38400000, pll8, 10, LOW), |
| 2817 | F_VPE( 64000000, pll8, 6, LOW), |
| 2818 | F_VPE( 76800000, pll8, 5, LOW), |
| 2819 | F_VPE( 96000000, pll8, 4, NOMINAL), |
| 2820 | F_VPE(100000000, pll2, 8, NOMINAL), |
| 2821 | F_VPE(160000000, pll2, 5, NOMINAL), |
| 2822 | F_VPE(200000000, pll2, 4, HIGH), |
| 2823 | F_END |
| 2824 | }; |
| 2825 | |
| 2826 | static struct rcg_clk vpe_clk = { |
| 2827 | .b = { |
| 2828 | .ctl_reg = VPE_CC_REG, |
| 2829 | .en_mask = BIT(0), |
| 2830 | .reset_reg = SW_RESET_CORE_REG, |
| 2831 | .reset_mask = BIT(17), |
| 2832 | .halt_reg = DBG_BUS_VEC_A_REG, |
| 2833 | .halt_bit = 28, |
| 2834 | }, |
| 2835 | .ns_reg = VPE_NS_REG, |
| 2836 | .root_en_mask = BIT(2), |
| 2837 | .ns_mask = (BM(15, 12) | BM(2, 0)), |
| 2838 | .set_rate = set_rate_nop, |
| 2839 | .freq_tbl = clk_tbl_vpe, |
Matt Wagantall | f63a889 | 2011-06-15 16:44:46 -0700 | [diff] [blame] | 2840 | .depends = &vpe_axi_clk.c, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2841 | .current_freq = &local_dummy_freq, |
| 2842 | .c = { |
| 2843 | .dbg_name = "vpe_clk", |
| 2844 | .ops = &soc_clk_ops_8x60, |
| 2845 | CLK_INIT(vpe_clk.c), |
| 2846 | }, |
| 2847 | }; |
| 2848 | |
| 2849 | #define F_VFE(f, s, d, m, n, v) \ |
| 2850 | { \ |
| 2851 | .freq_hz = f, \ |
| 2852 | .src_clk = &s##_clk.c, \ |
| 2853 | .md_val = MD8(8, m, 0, n), \ |
| 2854 | .ns_val = NS_MM(23, 16, n, m, 11, 10, d, 2, 0, s##_to_mm_mux), \ |
| 2855 | .ctl_val = CC(6, n), \ |
| 2856 | .mnd_en_mask = BIT(5) * !!(n), \ |
| 2857 | .sys_vdd = v, \ |
| 2858 | } |
| 2859 | static struct clk_freq_tbl clk_tbl_vfe[] = { |
| 2860 | F_VFE( 0, gnd, 1, 0, 0, NONE), |
| 2861 | F_VFE( 13960000, pll8, 1, 2, 55, LOW), |
| 2862 | F_VFE( 27000000, pxo, 1, 0, 0, LOW), |
| 2863 | F_VFE( 36570000, pll8, 1, 2, 21, LOW), |
| 2864 | F_VFE( 38400000, pll8, 2, 1, 5, LOW), |
| 2865 | F_VFE( 45180000, pll8, 1, 2, 17, LOW), |
| 2866 | F_VFE( 48000000, pll8, 2, 1, 4, LOW), |
| 2867 | F_VFE( 54860000, pll8, 1, 1, 7, LOW), |
| 2868 | F_VFE( 64000000, pll8, 2, 1, 3, LOW), |
| 2869 | F_VFE( 76800000, pll8, 1, 1, 5, LOW), |
| 2870 | F_VFE( 96000000, pll8, 2, 1, 2, LOW), |
| 2871 | F_VFE(109710000, pll8, 1, 2, 7, LOW), |
| 2872 | F_VFE(128000000, pll8, 1, 1, 3, NOMINAL), |
| 2873 | F_VFE(153600000, pll8, 1, 2, 5, NOMINAL), |
| 2874 | F_VFE(200000000, pll2, 2, 1, 2, NOMINAL), |
| 2875 | F_VFE(228570000, pll2, 1, 2, 7, NOMINAL), |
| 2876 | F_VFE(266667000, pll2, 1, 1, 3, HIGH), |
| 2877 | F_END |
| 2878 | }; |
| 2879 | |
| 2880 | static struct rcg_clk vfe_clk = { |
| 2881 | .b = { |
| 2882 | .ctl_reg = VFE_CC_REG, |
| 2883 | .reset_reg = SW_RESET_CORE_REG, |
| 2884 | .reset_mask = BIT(15), |
| 2885 | .halt_reg = DBG_BUS_VEC_B_REG, |
| 2886 | .halt_bit = 6, |
| 2887 | .en_mask = BIT(0), |
| 2888 | }, |
| 2889 | .ns_reg = VFE_NS_REG, |
| 2890 | .md_reg = VFE_MD_REG, |
| 2891 | .root_en_mask = BIT(2), |
| 2892 | .ns_mask = (BM(23, 16) | BM(11, 10) | BM(2, 0)), |
| 2893 | .ctl_mask = BM(7, 6), |
| 2894 | .set_rate = set_rate_mnd, |
| 2895 | .freq_tbl = clk_tbl_vfe, |
| 2896 | .depends = &vfe_axi_clk.c, |
| 2897 | .current_freq = &local_dummy_freq, |
| 2898 | .c = { |
| 2899 | .dbg_name = "vfe_clk", |
| 2900 | .ops = &soc_clk_ops_8x60, |
| 2901 | CLK_INIT(vfe_clk.c), |
| 2902 | }, |
| 2903 | }; |
| 2904 | |
| 2905 | static struct branch_clk csi0_vfe_clk = { |
| 2906 | .b = { |
| 2907 | .ctl_reg = VFE_CC_REG, |
| 2908 | .en_mask = BIT(12), |
| 2909 | .reset_reg = SW_RESET_CORE_REG, |
| 2910 | .reset_mask = BIT(24), |
| 2911 | .halt_reg = DBG_BUS_VEC_B_REG, |
| 2912 | .halt_bit = 7, |
| 2913 | }, |
| 2914 | .parent = &vfe_clk.c, |
| 2915 | .c = { |
| 2916 | .dbg_name = "csi0_vfe_clk", |
| 2917 | .ops = &clk_ops_branch, |
| 2918 | CLK_INIT(csi0_vfe_clk.c), |
| 2919 | }, |
| 2920 | }; |
| 2921 | |
| 2922 | static struct branch_clk csi1_vfe_clk = { |
| 2923 | .b = { |
| 2924 | .ctl_reg = VFE_CC_REG, |
| 2925 | .en_mask = BIT(10), |
| 2926 | .reset_reg = SW_RESET_CORE_REG, |
| 2927 | .reset_mask = BIT(23), |
| 2928 | .halt_reg = DBG_BUS_VEC_B_REG, |
| 2929 | .halt_bit = 8, |
| 2930 | }, |
| 2931 | .parent = &vfe_clk.c, |
| 2932 | .c = { |
| 2933 | .dbg_name = "csi1_vfe_clk", |
| 2934 | .ops = &clk_ops_branch, |
| 2935 | CLK_INIT(csi1_vfe_clk.c), |
| 2936 | }, |
| 2937 | }; |
| 2938 | |
| 2939 | /* |
| 2940 | * Low Power Audio Clocks |
| 2941 | */ |
| 2942 | #define F_AIF_OSR(f, s, d, m, n, v) \ |
| 2943 | { \ |
| 2944 | .freq_hz = f, \ |
| 2945 | .src_clk = &s##_clk.c, \ |
| 2946 | .md_val = MD8(8, m, 0, n), \ |
| 2947 | .ns_val = NS(31, 24, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \ |
| 2948 | .mnd_en_mask = BIT(8) * !!(n), \ |
| 2949 | .sys_vdd = v, \ |
| 2950 | } |
| 2951 | static struct clk_freq_tbl clk_tbl_aif_osr[] = { |
| 2952 | F_AIF_OSR( 0, gnd, 1, 0, 0, NONE), |
| 2953 | F_AIF_OSR( 768000, pll4, 4, 1, 176, LOW), |
| 2954 | F_AIF_OSR( 1024000, pll4, 4, 1, 132, LOW), |
| 2955 | F_AIF_OSR( 1536000, pll4, 4, 1, 88, LOW), |
| 2956 | F_AIF_OSR( 2048000, pll4, 4, 1, 66, LOW), |
| 2957 | F_AIF_OSR( 3072000, pll4, 4, 1, 44, LOW), |
| 2958 | F_AIF_OSR( 4096000, pll4, 4, 1, 33, LOW), |
| 2959 | F_AIF_OSR( 6144000, pll4, 4, 1, 22, LOW), |
| 2960 | F_AIF_OSR( 8192000, pll4, 2, 1, 33, LOW), |
| 2961 | F_AIF_OSR(12288000, pll4, 4, 1, 11, LOW), |
| 2962 | F_AIF_OSR(24576000, pll4, 2, 1, 11, LOW), |
| 2963 | F_END |
| 2964 | }; |
| 2965 | |
| 2966 | #define CLK_AIF_OSR(i, ns, md, h_r) \ |
| 2967 | struct rcg_clk i##_clk = { \ |
| 2968 | .b = { \ |
| 2969 | .ctl_reg = ns, \ |
| 2970 | .en_mask = BIT(17), \ |
| 2971 | .reset_reg = ns, \ |
| 2972 | .reset_mask = BIT(19), \ |
| 2973 | .halt_reg = h_r, \ |
| 2974 | .halt_check = ENABLE, \ |
| 2975 | .halt_bit = 1, \ |
| 2976 | }, \ |
| 2977 | .ns_reg = ns, \ |
| 2978 | .md_reg = md, \ |
| 2979 | .root_en_mask = BIT(9), \ |
| 2980 | .ns_mask = (BM(31, 24) | BM(6, 0)), \ |
| 2981 | .set_rate = set_rate_mnd, \ |
| 2982 | .freq_tbl = clk_tbl_aif_osr, \ |
| 2983 | .current_freq = &local_dummy_freq, \ |
| 2984 | .c = { \ |
| 2985 | .dbg_name = #i "_clk", \ |
| 2986 | .ops = &soc_clk_ops_8x60, \ |
| 2987 | CLK_INIT(i##_clk.c), \ |
| 2988 | }, \ |
| 2989 | } |
| 2990 | |
| 2991 | #define F_AIF_BIT(d, s) \ |
| 2992 | { \ |
| 2993 | .freq_hz = d, \ |
| 2994 | .ns_val = (BVAL(14, 14, s) | BVAL(13, 10, (d-1))) \ |
| 2995 | } |
| 2996 | static struct clk_freq_tbl clk_tbl_aif_bit[] = { |
| 2997 | F_AIF_BIT(0, 1), /* Use external clock. */ |
| 2998 | F_AIF_BIT(1, 0), F_AIF_BIT(2, 0), F_AIF_BIT(3, 0), F_AIF_BIT(4, 0), |
| 2999 | F_AIF_BIT(5, 0), F_AIF_BIT(6, 0), F_AIF_BIT(7, 0), F_AIF_BIT(8, 0), |
| 3000 | F_AIF_BIT(9, 0), F_AIF_BIT(10, 0), F_AIF_BIT(11, 0), F_AIF_BIT(12, 0), |
| 3001 | F_AIF_BIT(13, 0), F_AIF_BIT(14, 0), F_AIF_BIT(15, 0), F_AIF_BIT(16, 0), |
| 3002 | F_END |
| 3003 | }; |
| 3004 | |
| 3005 | #define CLK_AIF_BIT(i, ns, h_r) \ |
| 3006 | struct rcg_clk i##_clk = { \ |
| 3007 | .b = { \ |
| 3008 | .ctl_reg = ns, \ |
| 3009 | .en_mask = BIT(15), \ |
| 3010 | .halt_reg = h_r, \ |
| 3011 | .halt_check = DELAY, \ |
| 3012 | }, \ |
| 3013 | .ns_reg = ns, \ |
| 3014 | .ns_mask = BM(14, 10), \ |
| 3015 | .set_rate = set_rate_nop, \ |
| 3016 | .freq_tbl = clk_tbl_aif_bit, \ |
| 3017 | .current_freq = &local_dummy_freq, \ |
| 3018 | .c = { \ |
| 3019 | .dbg_name = #i "_clk", \ |
| 3020 | .ops = &soc_clk_ops_8x60, \ |
| 3021 | CLK_INIT(i##_clk.c), \ |
| 3022 | }, \ |
| 3023 | } |
| 3024 | |
| 3025 | static CLK_AIF_OSR(mi2s_osr, LCC_MI2S_NS_REG, LCC_MI2S_MD_REG, |
| 3026 | LCC_MI2S_STATUS_REG); |
| 3027 | static CLK_AIF_BIT(mi2s_bit, LCC_MI2S_NS_REG, LCC_MI2S_STATUS_REG); |
| 3028 | |
| 3029 | static CLK_AIF_OSR(codec_i2s_mic_osr, LCC_CODEC_I2S_MIC_NS_REG, |
| 3030 | LCC_CODEC_I2S_MIC_MD_REG, LCC_CODEC_I2S_MIC_STATUS_REG); |
| 3031 | static CLK_AIF_BIT(codec_i2s_mic_bit, LCC_CODEC_I2S_MIC_NS_REG, |
| 3032 | LCC_CODEC_I2S_MIC_STATUS_REG); |
| 3033 | |
| 3034 | static CLK_AIF_OSR(spare_i2s_mic_osr, LCC_SPARE_I2S_MIC_NS_REG, |
| 3035 | LCC_SPARE_I2S_MIC_MD_REG, LCC_SPARE_I2S_MIC_STATUS_REG); |
| 3036 | static CLK_AIF_BIT(spare_i2s_mic_bit, LCC_SPARE_I2S_MIC_NS_REG, |
| 3037 | LCC_SPARE_I2S_MIC_STATUS_REG); |
| 3038 | |
| 3039 | static CLK_AIF_OSR(codec_i2s_spkr_osr, LCC_CODEC_I2S_SPKR_NS_REG, |
| 3040 | LCC_CODEC_I2S_SPKR_MD_REG, LCC_CODEC_I2S_SPKR_STATUS_REG); |
| 3041 | static CLK_AIF_BIT(codec_i2s_spkr_bit, LCC_CODEC_I2S_SPKR_NS_REG, |
| 3042 | LCC_CODEC_I2S_SPKR_STATUS_REG); |
| 3043 | |
| 3044 | static CLK_AIF_OSR(spare_i2s_spkr_osr, LCC_SPARE_I2S_SPKR_NS_REG, |
| 3045 | LCC_SPARE_I2S_SPKR_MD_REG, LCC_SPARE_I2S_SPKR_STATUS_REG); |
| 3046 | static CLK_AIF_BIT(spare_i2s_spkr_bit, LCC_SPARE_I2S_SPKR_NS_REG, |
| 3047 | LCC_SPARE_I2S_SPKR_STATUS_REG); |
| 3048 | |
| 3049 | #define F_PCM(f, s, d, m, n, v) \ |
| 3050 | { \ |
| 3051 | .freq_hz = f, \ |
| 3052 | .src_clk = &s##_clk.c, \ |
| 3053 | .md_val = MD16(m, n), \ |
| 3054 | .ns_val = NS(31, 16, n, m, 5, 4, 3, d, 2, 0, s##_to_lpa_mux), \ |
| 3055 | .mnd_en_mask = BIT(8) * !!(n), \ |
| 3056 | .sys_vdd = v, \ |
| 3057 | } |
| 3058 | static struct clk_freq_tbl clk_tbl_pcm[] = { |
| 3059 | F_PCM( 0, gnd, 1, 0, 0, NONE), |
| 3060 | F_PCM( 512000, pll4, 4, 1, 264, LOW), |
| 3061 | F_PCM( 768000, pll4, 4, 1, 176, LOW), |
| 3062 | F_PCM( 1024000, pll4, 4, 1, 132, LOW), |
| 3063 | F_PCM( 1536000, pll4, 4, 1, 88, LOW), |
| 3064 | F_PCM( 2048000, pll4, 4, 1, 66, LOW), |
| 3065 | F_PCM( 3072000, pll4, 4, 1, 44, LOW), |
| 3066 | F_PCM( 4096000, pll4, 4, 1, 33, LOW), |
| 3067 | F_PCM( 6144000, pll4, 4, 1, 22, LOW), |
| 3068 | F_PCM( 8192000, pll4, 2, 1, 33, LOW), |
| 3069 | F_PCM(12288000, pll4, 4, 1, 11, LOW), |
| 3070 | F_PCM(24580000, pll4, 2, 1, 11, LOW), |
| 3071 | F_END |
| 3072 | }; |
| 3073 | |
| 3074 | static struct rcg_clk pcm_clk = { |
| 3075 | .b = { |
| 3076 | .ctl_reg = LCC_PCM_NS_REG, |
| 3077 | .en_mask = BIT(11), |
| 3078 | .reset_reg = LCC_PCM_NS_REG, |
| 3079 | .reset_mask = BIT(13), |
| 3080 | .halt_reg = LCC_PCM_STATUS_REG, |
| 3081 | .halt_check = ENABLE, |
| 3082 | .halt_bit = 0, |
| 3083 | }, |
| 3084 | .ns_reg = LCC_PCM_NS_REG, |
| 3085 | .md_reg = LCC_PCM_MD_REG, |
| 3086 | .root_en_mask = BIT(9), |
| 3087 | .ns_mask = (BM(31, 16) | BM(6, 0)), |
| 3088 | .set_rate = set_rate_mnd, |
| 3089 | .freq_tbl = clk_tbl_pcm, |
| 3090 | .current_freq = &local_dummy_freq, |
| 3091 | .c = { |
| 3092 | .dbg_name = "pcm_clk", |
| 3093 | .ops = &soc_clk_ops_8x60, |
| 3094 | CLK_INIT(pcm_clk.c), |
| 3095 | }, |
| 3096 | }; |
| 3097 | |
| 3098 | DEFINE_CLK_RPM(afab_clk, afab_a_clk, APPS_FABRIC); |
| 3099 | DEFINE_CLK_RPM(cfpb_clk, cfpb_a_clk, CFPB); |
| 3100 | DEFINE_CLK_RPM(dfab_clk, dfab_a_clk, DAYTONA_FABRIC); |
| 3101 | DEFINE_CLK_RPM(ebi1_clk, ebi1_a_clk, EBI1); |
| 3102 | DEFINE_CLK_RPM(mmfab_clk, mmfab_a_clk, MM_FABRIC); |
| 3103 | DEFINE_CLK_RPM(mmfpb_clk, mmfpb_a_clk, MMFPB); |
| 3104 | DEFINE_CLK_RPM(sfab_clk, sfab_a_clk, SYSTEM_FABRIC); |
| 3105 | DEFINE_CLK_RPM(sfpb_clk, sfpb_a_clk, SFPB); |
| 3106 | DEFINE_CLK_RPM(smi_clk, smi_a_clk, SMI); |
| 3107 | |
| 3108 | static DEFINE_CLK_VOTER(dfab_dsps_clk, &dfab_clk.c); |
| 3109 | static DEFINE_CLK_VOTER(dfab_usb_hs_clk, &dfab_clk.c); |
| 3110 | static DEFINE_CLK_VOTER(dfab_sdc1_clk, &dfab_clk.c); |
| 3111 | static DEFINE_CLK_VOTER(dfab_sdc2_clk, &dfab_clk.c); |
| 3112 | static DEFINE_CLK_VOTER(dfab_sdc3_clk, &dfab_clk.c); |
| 3113 | static DEFINE_CLK_VOTER(dfab_sdc4_clk, &dfab_clk.c); |
| 3114 | static DEFINE_CLK_VOTER(dfab_sdc5_clk, &dfab_clk.c); |
| 3115 | |
| 3116 | static DEFINE_CLK_VOTER(ebi1_msmbus_clk, &ebi1_clk.c); |
| 3117 | static DEFINE_CLK_VOTER(ebi1_adm0_clk, &ebi1_clk.c); |
| 3118 | static DEFINE_CLK_VOTER(ebi1_adm1_clk, &ebi1_clk.c); |
| 3119 | |
| 3120 | static DEFINE_CLK_MEASURE(sc0_m_clk); |
| 3121 | static DEFINE_CLK_MEASURE(sc1_m_clk); |
| 3122 | static DEFINE_CLK_MEASURE(l2_m_clk); |
| 3123 | |
| 3124 | #ifdef CONFIG_DEBUG_FS |
| 3125 | struct measure_sel { |
| 3126 | u32 test_vector; |
| 3127 | struct clk *clk; |
| 3128 | }; |
| 3129 | |
| 3130 | static struct measure_sel measure_mux[] = { |
| 3131 | { TEST_PER_LS(0x08), &modem_ahb1_p_clk.c }, |
| 3132 | { TEST_PER_LS(0x09), &modem_ahb2_p_clk.c }, |
| 3133 | { TEST_PER_LS(0x12), &sdc1_p_clk.c }, |
| 3134 | { TEST_PER_LS(0x13), &sdc1_clk.c }, |
| 3135 | { TEST_PER_LS(0x14), &sdc2_p_clk.c }, |
| 3136 | { TEST_PER_LS(0x15), &sdc2_clk.c }, |
| 3137 | { TEST_PER_LS(0x16), &sdc3_p_clk.c }, |
| 3138 | { TEST_PER_LS(0x17), &sdc3_clk.c }, |
| 3139 | { TEST_PER_LS(0x18), &sdc4_p_clk.c }, |
| 3140 | { TEST_PER_LS(0x19), &sdc4_clk.c }, |
| 3141 | { TEST_PER_LS(0x1A), &sdc5_p_clk.c }, |
| 3142 | { TEST_PER_LS(0x1B), &sdc5_clk.c }, |
| 3143 | { TEST_PER_LS(0x25), &dfab_clk.c }, |
| 3144 | { TEST_PER_LS(0x25), &dfab_a_clk.c }, |
| 3145 | { TEST_PER_LS(0x26), &pmem_clk.c }, |
| 3146 | { TEST_PER_LS(0x2B), &ppss_p_clk.c }, |
| 3147 | { TEST_PER_LS(0x33), &cfpb_clk.c }, |
| 3148 | { TEST_PER_LS(0x33), &cfpb_a_clk.c }, |
| 3149 | { TEST_PER_LS(0x3D), &gsbi1_p_clk.c }, |
| 3150 | { TEST_PER_LS(0x3E), &gsbi1_uart_clk.c }, |
| 3151 | { TEST_PER_LS(0x3F), &gsbi1_qup_clk.c }, |
| 3152 | { TEST_PER_LS(0x41), &gsbi2_p_clk.c }, |
| 3153 | { TEST_PER_LS(0x42), &gsbi2_uart_clk.c }, |
| 3154 | { TEST_PER_LS(0x44), &gsbi2_qup_clk.c }, |
| 3155 | { TEST_PER_LS(0x45), &gsbi3_p_clk.c }, |
| 3156 | { TEST_PER_LS(0x46), &gsbi3_uart_clk.c }, |
| 3157 | { TEST_PER_LS(0x48), &gsbi3_qup_clk.c }, |
| 3158 | { TEST_PER_LS(0x49), &gsbi4_p_clk.c }, |
| 3159 | { TEST_PER_LS(0x4A), &gsbi4_uart_clk.c }, |
| 3160 | { TEST_PER_LS(0x4C), &gsbi4_qup_clk.c }, |
| 3161 | { TEST_PER_LS(0x4D), &gsbi5_p_clk.c }, |
| 3162 | { TEST_PER_LS(0x4E), &gsbi5_uart_clk.c }, |
| 3163 | { TEST_PER_LS(0x50), &gsbi5_qup_clk.c }, |
| 3164 | { TEST_PER_LS(0x51), &gsbi6_p_clk.c }, |
| 3165 | { TEST_PER_LS(0x52), &gsbi6_uart_clk.c }, |
| 3166 | { TEST_PER_LS(0x54), &gsbi6_qup_clk.c }, |
| 3167 | { TEST_PER_LS(0x55), &gsbi7_p_clk.c }, |
| 3168 | { TEST_PER_LS(0x56), &gsbi7_uart_clk.c }, |
| 3169 | { TEST_PER_LS(0x58), &gsbi7_qup_clk.c }, |
| 3170 | { TEST_PER_LS(0x59), &gsbi8_p_clk.c }, |
| 3171 | { TEST_PER_LS(0x5A), &gsbi8_uart_clk.c }, |
| 3172 | { TEST_PER_LS(0x5C), &gsbi8_qup_clk.c }, |
| 3173 | { TEST_PER_LS(0x5D), &gsbi9_p_clk.c }, |
| 3174 | { TEST_PER_LS(0x5E), &gsbi9_uart_clk.c }, |
| 3175 | { TEST_PER_LS(0x60), &gsbi9_qup_clk.c }, |
| 3176 | { TEST_PER_LS(0x61), &gsbi10_p_clk.c }, |
| 3177 | { TEST_PER_LS(0x62), &gsbi10_uart_clk.c }, |
| 3178 | { TEST_PER_LS(0x64), &gsbi10_qup_clk.c }, |
| 3179 | { TEST_PER_LS(0x65), &gsbi11_p_clk.c }, |
| 3180 | { TEST_PER_LS(0x66), &gsbi11_uart_clk.c }, |
| 3181 | { TEST_PER_LS(0x68), &gsbi11_qup_clk.c }, |
| 3182 | { TEST_PER_LS(0x69), &gsbi12_p_clk.c }, |
| 3183 | { TEST_PER_LS(0x6A), &gsbi12_uart_clk.c }, |
| 3184 | { TEST_PER_LS(0x6C), &gsbi12_qup_clk.c }, |
| 3185 | { TEST_PER_LS(0x78), &sfpb_clk.c }, |
| 3186 | { TEST_PER_LS(0x78), &sfpb_a_clk.c }, |
| 3187 | { TEST_PER_LS(0x7A), &pmic_ssbi2_clk.c }, |
| 3188 | { TEST_PER_LS(0x7B), &pmic_arb0_p_clk.c }, |
| 3189 | { TEST_PER_LS(0x7C), &pmic_arb1_p_clk.c }, |
| 3190 | { TEST_PER_LS(0x7D), &prng_clk.c }, |
| 3191 | { TEST_PER_LS(0x7F), &rpm_msg_ram_p_clk.c }, |
| 3192 | { TEST_PER_LS(0x80), &adm0_p_clk.c }, |
| 3193 | { TEST_PER_LS(0x81), &adm1_p_clk.c }, |
| 3194 | { TEST_PER_LS(0x84), &usb_hs1_p_clk.c }, |
| 3195 | { TEST_PER_LS(0x85), &usb_hs1_xcvr_clk.c }, |
| 3196 | { TEST_PER_LS(0x89), &usb_fs1_p_clk.c }, |
| 3197 | { TEST_PER_LS(0x8A), &usb_fs1_sys_clk.c }, |
| 3198 | { TEST_PER_LS(0x8B), &usb_fs1_xcvr_clk.c }, |
| 3199 | { TEST_PER_LS(0x8C), &usb_fs2_p_clk.c }, |
| 3200 | { TEST_PER_LS(0x8D), &usb_fs2_sys_clk.c }, |
| 3201 | { TEST_PER_LS(0x8E), &usb_fs2_xcvr_clk.c }, |
| 3202 | { TEST_PER_LS(0x8F), &tsif_p_clk.c }, |
| 3203 | { TEST_PER_LS(0x91), &tsif_ref_clk.c }, |
| 3204 | { TEST_PER_LS(0x93), &ce2_p_clk.c }, |
| 3205 | { TEST_PER_LS(0x94), &tssc_clk.c }, |
| 3206 | |
| 3207 | { TEST_PER_HS(0x07), &afab_clk.c }, |
| 3208 | { TEST_PER_HS(0x07), &afab_a_clk.c }, |
| 3209 | { TEST_PER_HS(0x18), &sfab_clk.c }, |
| 3210 | { TEST_PER_HS(0x18), &sfab_a_clk.c }, |
| 3211 | { TEST_PER_HS(0x2A), &adm0_clk.c }, |
| 3212 | { TEST_PER_HS(0x2B), &adm1_clk.c }, |
| 3213 | { TEST_PER_HS(0x34), &ebi1_clk.c }, |
| 3214 | { TEST_PER_HS(0x34), &ebi1_a_clk.c }, |
| 3215 | |
| 3216 | { TEST_MM_LS(0x00), &dsi_byte_clk.c }, |
| 3217 | { TEST_MM_LS(0x01), &pixel_lcdc_clk.c }, |
| 3218 | { TEST_MM_LS(0x04), &pixel_mdp_clk.c }, |
| 3219 | { TEST_MM_LS(0x06), &_p_clk.c }, |
| 3220 | { TEST_MM_LS(0x07), &csi0_p_clk.c }, |
| 3221 | { TEST_MM_LS(0x08), &csi1_p_clk.c }, |
| 3222 | { TEST_MM_LS(0x09), &dsi_m_p_clk.c }, |
| 3223 | { TEST_MM_LS(0x0A), &dsi_s_p_clk.c }, |
| 3224 | { TEST_MM_LS(0x0C), &gfx2d0_p_clk.c }, |
| 3225 | { TEST_MM_LS(0x0D), &gfx2d1_p_clk.c }, |
| 3226 | { TEST_MM_LS(0x0E), &gfx3d_p_clk.c }, |
| 3227 | { TEST_MM_LS(0x0F), &hdmi_m_p_clk.c }, |
| 3228 | { TEST_MM_LS(0x10), &hdmi_s_p_clk.c }, |
| 3229 | { TEST_MM_LS(0x11), &ijpeg_p_clk.c }, |
| 3230 | { TEST_MM_LS(0x12), &imem_p_clk.c }, |
| 3231 | { TEST_MM_LS(0x13), &jpegd_p_clk.c }, |
| 3232 | { TEST_MM_LS(0x14), &mdp_p_clk.c }, |
| 3233 | { TEST_MM_LS(0x16), &rot_p_clk.c }, |
| 3234 | { TEST_MM_LS(0x18), &smmu_p_clk.c }, |
| 3235 | { TEST_MM_LS(0x19), &tv_enc_p_clk.c }, |
| 3236 | { TEST_MM_LS(0x1A), &vcodec_p_clk.c }, |
| 3237 | { TEST_MM_LS(0x1B), &vfe_p_clk.c }, |
| 3238 | { TEST_MM_LS(0x1C), &vpe_p_clk.c }, |
| 3239 | { TEST_MM_LS(0x1D), &cam_clk.c }, |
| 3240 | { TEST_MM_LS(0x1F), &hdmi_app_clk.c }, |
| 3241 | { TEST_MM_LS(0x20), &mdp_vsync_clk.c }, |
| 3242 | { TEST_MM_LS(0x21), &tv_dac_clk.c }, |
| 3243 | { TEST_MM_LS(0x22), &tv_enc_clk.c }, |
| 3244 | { TEST_MM_LS(0x23), &dsi_esc_clk.c }, |
| 3245 | { TEST_MM_LS(0x25), &mmfpb_clk.c }, |
| 3246 | { TEST_MM_LS(0x25), &mmfpb_a_clk.c }, |
| 3247 | |
| 3248 | { TEST_MM_HS(0x00), &csi0_clk.c }, |
| 3249 | { TEST_MM_HS(0x01), &csi1_clk.c }, |
| 3250 | { TEST_MM_HS(0x03), &csi0_vfe_clk.c }, |
| 3251 | { TEST_MM_HS(0x04), &csi1_vfe_clk.c }, |
| 3252 | { TEST_MM_HS(0x05), &ijpeg_clk.c }, |
| 3253 | { TEST_MM_HS(0x06), &vfe_clk.c }, |
| 3254 | { TEST_MM_HS(0x07), &gfx2d0_clk.c }, |
| 3255 | { TEST_MM_HS(0x08), &gfx2d1_clk.c }, |
| 3256 | { TEST_MM_HS(0x09), &gfx3d_clk.c }, |
| 3257 | { TEST_MM_HS(0x0A), &jpegd_clk.c }, |
| 3258 | { TEST_MM_HS(0x0B), &vcodec_clk.c }, |
| 3259 | { TEST_MM_HS(0x0F), &mmfab_clk.c }, |
| 3260 | { TEST_MM_HS(0x0F), &mmfab_a_clk.c }, |
| 3261 | { TEST_MM_HS(0x11), &gmem_axi_clk.c }, |
| 3262 | { TEST_MM_HS(0x12), &ijpeg_axi_clk.c }, |
| 3263 | { TEST_MM_HS(0x13), &imem_axi_clk.c }, |
| 3264 | { TEST_MM_HS(0x14), &jpegd_axi_clk.c }, |
| 3265 | { TEST_MM_HS(0x15), &mdp_axi_clk.c }, |
Matt Wagantall | f63a889 | 2011-06-15 16:44:46 -0700 | [diff] [blame] | 3266 | { TEST_MM_HS(0x16), &rot_axi_clk.c }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3267 | { TEST_MM_HS(0x17), &vcodec_axi_clk.c }, |
| 3268 | { TEST_MM_HS(0x18), &vfe_axi_clk.c }, |
Matt Wagantall | f63a889 | 2011-06-15 16:44:46 -0700 | [diff] [blame] | 3269 | { TEST_MM_HS(0x19), &vpe_axi_clk.c }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3270 | { TEST_MM_HS(0x1A), &mdp_clk.c }, |
| 3271 | { TEST_MM_HS(0x1B), &rot_clk.c }, |
| 3272 | { TEST_MM_HS(0x1C), &vpe_clk.c }, |
| 3273 | { TEST_MM_HS(0x1E), &hdmi_tv_clk.c }, |
| 3274 | { TEST_MM_HS(0x1F), &mdp_tv_clk.c }, |
| 3275 | |
| 3276 | { TEST_MM_HS2X(0x24), &smi_clk.c }, |
| 3277 | { TEST_MM_HS2X(0x24), &smi_a_clk.c }, |
| 3278 | |
| 3279 | { TEST_LPA(0x0A), &mi2s_osr_clk.c }, |
| 3280 | { TEST_LPA(0x0B), &mi2s_bit_clk.c }, |
| 3281 | { TEST_LPA(0x0C), &codec_i2s_mic_osr_clk.c }, |
| 3282 | { TEST_LPA(0x0D), &codec_i2s_mic_bit_clk.c }, |
| 3283 | { TEST_LPA(0x0E), &codec_i2s_spkr_osr_clk.c }, |
| 3284 | { TEST_LPA(0x0F), &codec_i2s_spkr_bit_clk.c }, |
| 3285 | { TEST_LPA(0x10), &spare_i2s_mic_osr_clk.c }, |
| 3286 | { TEST_LPA(0x11), &spare_i2s_mic_bit_clk.c }, |
| 3287 | { TEST_LPA(0x12), &spare_i2s_spkr_osr_clk.c }, |
| 3288 | { TEST_LPA(0x13), &spare_i2s_spkr_bit_clk.c }, |
| 3289 | { TEST_LPA(0x14), &pcm_clk.c }, |
| 3290 | |
| 3291 | { TEST_SC(0x40), &sc0_m_clk }, |
| 3292 | { TEST_SC(0x41), &sc1_m_clk }, |
| 3293 | { TEST_SC(0x42), &l2_m_clk }, |
| 3294 | }; |
| 3295 | |
| 3296 | static struct measure_sel *find_measure_sel(struct clk *clk) |
| 3297 | { |
| 3298 | int i; |
| 3299 | |
| 3300 | for (i = 0; i < ARRAY_SIZE(measure_mux); i++) |
| 3301 | if (measure_mux[i].clk == clk) |
| 3302 | return &measure_mux[i]; |
| 3303 | return NULL; |
| 3304 | } |
| 3305 | |
| 3306 | static int measure_clk_set_parent(struct clk *c, struct clk *parent) |
| 3307 | { |
| 3308 | int ret = 0; |
| 3309 | u32 clk_sel; |
| 3310 | struct measure_sel *p; |
| 3311 | struct measure_clk *clk = to_measure_clk(c); |
| 3312 | unsigned long flags; |
| 3313 | |
| 3314 | if (!parent) |
| 3315 | return -EINVAL; |
| 3316 | |
| 3317 | p = find_measure_sel(parent); |
| 3318 | if (!p) |
| 3319 | return -EINVAL; |
| 3320 | |
| 3321 | spin_lock_irqsave(&local_clock_reg_lock, flags); |
| 3322 | |
| 3323 | /* |
| 3324 | * Program the test vector, measurement period (sample_ticks) |
| 3325 | * and scaling factors (multiplier, divider). |
| 3326 | */ |
| 3327 | clk_sel = p->test_vector & TEST_CLK_SEL_MASK; |
| 3328 | clk->sample_ticks = 0x10000; |
| 3329 | clk->multiplier = 1; |
| 3330 | clk->divider = 1; |
| 3331 | switch (p->test_vector >> TEST_TYPE_SHIFT) { |
| 3332 | case TEST_TYPE_PER_LS: |
| 3333 | writel_relaxed(0x4030D00|BVAL(7, 0, clk_sel), CLK_TEST_REG); |
| 3334 | break; |
| 3335 | case TEST_TYPE_PER_HS: |
| 3336 | writel_relaxed(0x4020000|BVAL(16, 10, clk_sel), CLK_TEST_REG); |
| 3337 | break; |
| 3338 | case TEST_TYPE_MM_LS: |
| 3339 | writel_relaxed(0x4030D97, CLK_TEST_REG); |
| 3340 | writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_LS_REG); |
| 3341 | break; |
| 3342 | case TEST_TYPE_MM_HS2X: |
| 3343 | clk->divider = 2; |
| 3344 | case TEST_TYPE_MM_HS: |
| 3345 | writel_relaxed(0x402B800, CLK_TEST_REG); |
| 3346 | writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), DBG_CFG_REG_HS_REG); |
| 3347 | break; |
| 3348 | case TEST_TYPE_LPA: |
| 3349 | writel_relaxed(0x4030D98, CLK_TEST_REG); |
| 3350 | writel_relaxed(BVAL(6, 1, clk_sel)|BIT(0), |
| 3351 | LCC_CLK_LS_DEBUG_CFG_REG); |
| 3352 | break; |
| 3353 | case TEST_TYPE_SC: |
| 3354 | writel_relaxed(0x5020000|BVAL(16, 10, clk_sel), CLK_TEST_REG); |
| 3355 | clk->sample_ticks = 0x4000; |
| 3356 | clk->multiplier = 2; |
| 3357 | break; |
| 3358 | default: |
| 3359 | ret = -EPERM; |
| 3360 | } |
| 3361 | /* Make sure test vector is set before starting measurements. */ |
| 3362 | mb(); |
| 3363 | |
| 3364 | spin_unlock_irqrestore(&local_clock_reg_lock, flags); |
| 3365 | |
| 3366 | return ret; |
| 3367 | } |
| 3368 | |
| 3369 | /* Sample clock for 'ticks' reference clock ticks. */ |
| 3370 | static u32 run_measurement(unsigned ticks) |
| 3371 | { |
| 3372 | /* Stop counters and set the XO4 counter start value. */ |
| 3373 | writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG); |
| 3374 | writel_relaxed(ticks, RINGOSC_TCXO_CTL_REG); |
| 3375 | |
| 3376 | /* Wait for timer to become ready. */ |
| 3377 | while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) != 0) |
| 3378 | cpu_relax(); |
| 3379 | |
| 3380 | /* Run measurement and wait for completion. */ |
| 3381 | writel_relaxed(BIT(20)|ticks, RINGOSC_TCXO_CTL_REG); |
| 3382 | while ((readl_relaxed(RINGOSC_STATUS_REG) & BIT(25)) == 0) |
| 3383 | cpu_relax(); |
| 3384 | |
| 3385 | /* Stop counters. */ |
| 3386 | writel_relaxed(0x0, RINGOSC_TCXO_CTL_REG); |
| 3387 | |
| 3388 | /* Return measured ticks. */ |
| 3389 | return readl_relaxed(RINGOSC_STATUS_REG) & BM(24, 0); |
| 3390 | } |
| 3391 | |
| 3392 | /* Perform a hardware rate measurement for a given clock. |
| 3393 | FOR DEBUG USE ONLY: Measurements take ~15 ms! */ |
| 3394 | static unsigned measure_clk_get_rate(struct clk *c) |
| 3395 | { |
| 3396 | unsigned long flags; |
| 3397 | u32 pdm_reg_backup, ringosc_reg_backup; |
| 3398 | u64 raw_count_short, raw_count_full; |
| 3399 | struct measure_clk *clk = to_measure_clk(c); |
| 3400 | unsigned ret; |
| 3401 | |
| 3402 | spin_lock_irqsave(&local_clock_reg_lock, flags); |
| 3403 | |
| 3404 | /* Enable CXO/4 and RINGOSC branch and root. */ |
| 3405 | pdm_reg_backup = readl_relaxed(PDM_CLK_NS_REG); |
| 3406 | ringosc_reg_backup = readl_relaxed(RINGOSC_NS_REG); |
| 3407 | writel_relaxed(0x2898, PDM_CLK_NS_REG); |
| 3408 | writel_relaxed(0xA00, RINGOSC_NS_REG); |
| 3409 | |
| 3410 | /* |
| 3411 | * The ring oscillator counter will not reset if the measured clock |
| 3412 | * is not running. To detect this, run a short measurement before |
| 3413 | * the full measurement. If the raw results of the two are the same |
| 3414 | * then the clock must be off. |
| 3415 | */ |
| 3416 | |
| 3417 | /* Run a short measurement. (~1 ms) */ |
| 3418 | raw_count_short = run_measurement(0x1000); |
| 3419 | /* Run a full measurement. (~14 ms) */ |
| 3420 | raw_count_full = run_measurement(clk->sample_ticks); |
| 3421 | |
| 3422 | writel_relaxed(ringosc_reg_backup, RINGOSC_NS_REG); |
| 3423 | writel_relaxed(pdm_reg_backup, PDM_CLK_NS_REG); |
| 3424 | |
| 3425 | /* Return 0 if the clock is off. */ |
| 3426 | if (raw_count_full == raw_count_short) |
| 3427 | ret = 0; |
| 3428 | else { |
| 3429 | /* Compute rate in Hz. */ |
| 3430 | raw_count_full = ((raw_count_full * 10) + 15) * 4800000; |
| 3431 | do_div(raw_count_full, |
| 3432 | (((clk->sample_ticks * 10) + 35) * clk->divider)); |
| 3433 | ret = (raw_count_full * clk->multiplier); |
| 3434 | } |
| 3435 | |
| 3436 | /* Route dbg_hs_clk to PLLTEST. 300mV single-ended amplitude. */ |
| 3437 | writel_relaxed(0x3CF8, PLLTEST_PAD_CFG_REG); |
| 3438 | spin_unlock_irqrestore(&local_clock_reg_lock, flags); |
| 3439 | |
| 3440 | return ret; |
| 3441 | } |
| 3442 | #else /* !CONFIG_DEBUG_FS */ |
| 3443 | static int measure_clk_set_parent(struct clk *clk, struct clk *parent) |
| 3444 | { |
| 3445 | return -EINVAL; |
| 3446 | } |
| 3447 | |
| 3448 | static unsigned measure_clk_get_rate(struct clk *clk) |
| 3449 | { |
| 3450 | return 0; |
| 3451 | } |
| 3452 | #endif /* CONFIG_DEBUG_FS */ |
| 3453 | |
| 3454 | static struct clk_ops measure_clk_ops = { |
| 3455 | .set_parent = measure_clk_set_parent, |
| 3456 | .get_rate = measure_clk_get_rate, |
| 3457 | .is_local = local_clk_is_local, |
| 3458 | }; |
| 3459 | |
| 3460 | static struct measure_clk measure_clk = { |
| 3461 | .c = { |
| 3462 | .dbg_name = "measure_clk", |
| 3463 | .ops = &measure_clk_ops, |
| 3464 | CLK_INIT(measure_clk.c), |
| 3465 | }, |
| 3466 | .multiplier = 1, |
| 3467 | .divider = 1, |
| 3468 | }; |
| 3469 | |
| 3470 | static struct clk_lookup msm_clocks_8x60[] = { |
| 3471 | CLK_LOOKUP("cxo", cxo_clk.c, NULL), |
| 3472 | CLK_LOOKUP("pll4", pll4_clk.c, NULL), |
| 3473 | CLK_LOOKUP("pll4", pll4_clk.c, "peripheral-reset"), |
| 3474 | CLK_LOOKUP("measure", measure_clk.c, "debug"), |
| 3475 | |
| 3476 | CLK_LOOKUP("afab_clk", afab_clk.c, NULL), |
| 3477 | CLK_LOOKUP("afab_a_clk", afab_a_clk.c, NULL), |
| 3478 | CLK_LOOKUP("cfpb_clk", cfpb_clk.c, NULL), |
| 3479 | CLK_LOOKUP("cfpb_a_clk", cfpb_a_clk.c, NULL), |
| 3480 | CLK_LOOKUP("dfab_clk", dfab_clk.c, NULL), |
| 3481 | CLK_LOOKUP("dfab_a_clk", dfab_a_clk.c, NULL), |
| 3482 | CLK_LOOKUP("ebi1_clk", ebi1_clk.c, NULL), |
| 3483 | CLK_LOOKUP("ebi1_a_clk", ebi1_a_clk.c, NULL), |
| 3484 | CLK_LOOKUP("mmfab_clk", mmfab_clk.c, NULL), |
| 3485 | CLK_LOOKUP("mmfab_a_clk", mmfab_a_clk.c, NULL), |
| 3486 | CLK_LOOKUP("mmfpb_clk", mmfpb_clk.c, NULL), |
| 3487 | CLK_LOOKUP("mmfpb_a_clk", mmfpb_a_clk.c, NULL), |
| 3488 | CLK_LOOKUP("sfab_clk", sfab_clk.c, NULL), |
| 3489 | CLK_LOOKUP("sfab_a_clk", sfab_a_clk.c, NULL), |
| 3490 | CLK_LOOKUP("sfpb_clk", sfpb_clk.c, NULL), |
| 3491 | CLK_LOOKUP("sfpb_a_clk", sfpb_a_clk.c, NULL), |
| 3492 | CLK_LOOKUP("smi_clk", smi_clk.c, NULL), |
| 3493 | CLK_LOOKUP("smi_a_clk", smi_a_clk.c, NULL), |
| 3494 | |
| 3495 | CLK_LOOKUP("gsbi_uart_clk", gsbi1_uart_clk.c, NULL), |
| 3496 | CLK_LOOKUP("gsbi_uart_clk", gsbi2_uart_clk.c, NULL), |
| 3497 | CLK_LOOKUP("gsbi_uart_clk", gsbi3_uart_clk.c, "msm_serial_hsl.2"), |
| 3498 | CLK_LOOKUP("gsbi_uart_clk", gsbi4_uart_clk.c, NULL), |
| 3499 | CLK_LOOKUP("gsbi_uart_clk", gsbi5_uart_clk.c, NULL), |
| 3500 | CLK_LOOKUP("uartdm_clk", gsbi6_uart_clk.c, "msm_serial_hs.0"), |
| 3501 | CLK_LOOKUP("gsbi_uart_clk", gsbi7_uart_clk.c, NULL), |
| 3502 | CLK_LOOKUP("gsbi_uart_clk", gsbi8_uart_clk.c, NULL), |
| 3503 | CLK_LOOKUP("gsbi_uart_clk", gsbi9_uart_clk.c, "msm_serial_hsl.1"), |
| 3504 | CLK_LOOKUP("gsbi_uart_clk", gsbi10_uart_clk.c, NULL), |
| 3505 | CLK_LOOKUP("gsbi_uart_clk", gsbi11_uart_clk.c, NULL), |
| 3506 | CLK_LOOKUP("gsbi_uart_clk", gsbi12_uart_clk.c, "msm_serial_hsl.0"), |
| 3507 | CLK_LOOKUP("spi_clk", gsbi1_qup_clk.c, "spi_qsd.0"), |
| 3508 | CLK_LOOKUP("gsbi_qup_clk", gsbi2_qup_clk.c, NULL), |
| 3509 | CLK_LOOKUP("gsbi_qup_clk", gsbi3_qup_clk.c, "qup_i2c.0"), |
| 3510 | CLK_LOOKUP("gsbi_qup_clk", gsbi4_qup_clk.c, "qup_i2c.1"), |
| 3511 | CLK_LOOKUP("gsbi_qup_clk", gsbi5_qup_clk.c, NULL), |
| 3512 | CLK_LOOKUP("gsbi_qup_clk", gsbi6_qup_clk.c, NULL), |
| 3513 | CLK_LOOKUP("gsbi_qup_clk", gsbi7_qup_clk.c, "qup_i2c.4"), |
| 3514 | CLK_LOOKUP("gsbi_qup_clk", gsbi8_qup_clk.c, "qup_i2c.3"), |
| 3515 | CLK_LOOKUP("gsbi_qup_clk", gsbi9_qup_clk.c, "qup_i2c.2"), |
| 3516 | CLK_LOOKUP("spi_clk", gsbi10_qup_clk.c, "spi_qsd.1"), |
| 3517 | CLK_LOOKUP("gsbi_qup_clk", gsbi11_qup_clk.c, NULL), |
| 3518 | CLK_LOOKUP("gsbi_qup_clk", gsbi12_qup_clk.c, "msm_dsps.0"), |
| 3519 | CLK_LOOKUP("gsbi_qup_clk", gsbi12_qup_clk.c, "qup_i2c.5"), |
| 3520 | CLK_LOOKUP("pdm_clk", pdm_clk.c, NULL), |
| 3521 | CLK_LOOKUP("pmem_clk", pmem_clk.c, NULL), |
| 3522 | CLK_LOOKUP("prng_clk", prng_clk.c, NULL), |
| 3523 | CLK_LOOKUP("sdc_clk", sdc1_clk.c, "msm_sdcc.1"), |
| 3524 | CLK_LOOKUP("sdc_clk", sdc2_clk.c, "msm_sdcc.2"), |
| 3525 | CLK_LOOKUP("sdc_clk", sdc3_clk.c, "msm_sdcc.3"), |
| 3526 | CLK_LOOKUP("sdc_clk", sdc4_clk.c, "msm_sdcc.4"), |
| 3527 | CLK_LOOKUP("sdc_clk", sdc5_clk.c, "msm_sdcc.5"), |
| 3528 | CLK_LOOKUP("tsif_ref_clk", tsif_ref_clk.c, NULL), |
| 3529 | CLK_LOOKUP("tssc_clk", tssc_clk.c, NULL), |
| 3530 | CLK_LOOKUP("usb_hs_clk", usb_hs1_xcvr_clk.c, NULL), |
| 3531 | CLK_LOOKUP("usb_phy_clk", usb_phy0_clk.c, NULL), |
| 3532 | CLK_LOOKUP("usb_fs_clk", usb_fs1_xcvr_clk.c, NULL), |
| 3533 | CLK_LOOKUP("usb_fs_sys_clk", usb_fs1_sys_clk.c, NULL), |
| 3534 | CLK_LOOKUP("usb_fs_src_clk", usb_fs1_src_clk.c, NULL), |
| 3535 | CLK_LOOKUP("usb_fs_clk", usb_fs2_xcvr_clk.c, NULL), |
| 3536 | CLK_LOOKUP("usb_fs_sys_clk", usb_fs2_sys_clk.c, NULL), |
| 3537 | CLK_LOOKUP("usb_fs_src_clk", usb_fs2_src_clk.c, NULL), |
| 3538 | CLK_LOOKUP("ce_clk", ce2_p_clk.c, NULL), |
| 3539 | CLK_LOOKUP("spi_pclk", gsbi1_p_clk.c, "spi_qsd.0"), |
| 3540 | CLK_LOOKUP("gsbi_pclk", gsbi2_p_clk.c, NULL), |
| 3541 | CLK_LOOKUP("gsbi_pclk", gsbi3_p_clk.c, "msm_serial_hsl.2"), |
| 3542 | CLK_LOOKUP("gsbi_pclk", gsbi3_p_clk.c, "qup_i2c.0"), |
| 3543 | CLK_LOOKUP("gsbi_pclk", gsbi4_p_clk.c, "qup_i2c.1"), |
| 3544 | CLK_LOOKUP("gsbi_pclk", gsbi5_p_clk.c, NULL), |
| 3545 | CLK_LOOKUP("uartdm_pclk", gsbi6_p_clk.c, "msm_serial_hs.0"), |
| 3546 | CLK_LOOKUP("gsbi_pclk", gsbi7_p_clk.c, "qup_i2c.4"), |
| 3547 | CLK_LOOKUP("gsbi_pclk", gsbi8_p_clk.c, "qup_i2c.3"), |
| 3548 | CLK_LOOKUP("gsbi_pclk", gsbi9_p_clk.c, "msm_serial_hsl.1"), |
| 3549 | CLK_LOOKUP("gsbi_pclk", gsbi9_p_clk.c, "qup_i2c.2"), |
| 3550 | CLK_LOOKUP("spi_pclk", gsbi10_p_clk.c, "spi_qsd.1"), |
| 3551 | CLK_LOOKUP("gsbi_pclk", gsbi11_p_clk.c, NULL), |
| 3552 | CLK_LOOKUP("gsbi_pclk", gsbi12_p_clk.c, "msm_dsps.0"), |
| 3553 | CLK_LOOKUP("gsbi_pclk", gsbi12_p_clk.c, "msm_serial_hsl.0"), |
| 3554 | CLK_LOOKUP("gsbi_pclk", gsbi12_p_clk.c, "qup_i2c.5"), |
| 3555 | CLK_LOOKUP("ppss_pclk", ppss_p_clk.c, NULL), |
| 3556 | CLK_LOOKUP("tsif_pclk", tsif_p_clk.c, NULL), |
| 3557 | CLK_LOOKUP("usb_fs_pclk", usb_fs1_p_clk.c, NULL), |
| 3558 | CLK_LOOKUP("usb_fs_pclk", usb_fs2_p_clk.c, NULL), |
| 3559 | CLK_LOOKUP("usb_hs_pclk", usb_hs1_p_clk.c, NULL), |
| 3560 | CLK_LOOKUP("sdc_pclk", sdc1_p_clk.c, "msm_sdcc.1"), |
| 3561 | CLK_LOOKUP("sdc_pclk", sdc2_p_clk.c, "msm_sdcc.2"), |
| 3562 | CLK_LOOKUP("sdc_pclk", sdc3_p_clk.c, "msm_sdcc.3"), |
| 3563 | CLK_LOOKUP("sdc_pclk", sdc4_p_clk.c, "msm_sdcc.4"), |
| 3564 | CLK_LOOKUP("sdc_pclk", sdc5_p_clk.c, "msm_sdcc.5"), |
| 3565 | CLK_LOOKUP("adm_clk", adm0_clk.c, "msm_dmov.0"), |
| 3566 | CLK_LOOKUP("adm_pclk", adm0_p_clk.c, "msm_dmov.0"), |
| 3567 | CLK_LOOKUP("adm_clk", adm1_clk.c, "msm_dmov.1"), |
| 3568 | CLK_LOOKUP("adm_pclk", adm1_p_clk.c, "msm_dmov.1"), |
| 3569 | CLK_LOOKUP("modem_ahb1_pclk", modem_ahb1_p_clk.c, NULL), |
| 3570 | CLK_LOOKUP("modem_ahb2_pclk", modem_ahb2_p_clk.c, NULL), |
| 3571 | CLK_LOOKUP("pmic_arb_pclk", pmic_arb0_p_clk.c, NULL), |
| 3572 | CLK_LOOKUP("pmic_arb_pclk", pmic_arb1_p_clk.c, NULL), |
| 3573 | CLK_LOOKUP("pmic_ssbi2", pmic_ssbi2_clk.c, NULL), |
| 3574 | CLK_LOOKUP("rpm_msg_ram_pclk", rpm_msg_ram_p_clk.c, NULL), |
| 3575 | CLK_LOOKUP("amp_clk", amp_clk.c, NULL), |
| 3576 | CLK_LOOKUP("cam_clk", cam_clk.c, NULL), |
| 3577 | CLK_LOOKUP("csi_clk", csi0_clk.c, NULL), |
| 3578 | CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_camera_ov7692.0"), |
| 3579 | CLK_LOOKUP("csi_clk", csi1_clk.c, "msm_camera_ov9726.0"), |
| 3580 | CLK_LOOKUP("csi_src_clk", csi_src_clk.c, NULL), |
| 3581 | CLK_LOOKUP("dsi_byte_div_clk", dsi_byte_clk.c, NULL), |
| 3582 | CLK_LOOKUP("dsi_esc_clk", dsi_esc_clk.c, NULL), |
| 3583 | CLK_LOOKUP("gfx2d0_clk", gfx2d0_clk.c, NULL), |
| 3584 | CLK_LOOKUP("gfx2d1_clk", gfx2d1_clk.c, NULL), |
| 3585 | CLK_LOOKUP("gfx3d_clk", gfx3d_clk.c, NULL), |
| 3586 | CLK_LOOKUP("ijpeg_clk", ijpeg_clk.c, NULL), |
| 3587 | CLK_LOOKUP("jpegd_clk", jpegd_clk.c, NULL), |
| 3588 | CLK_LOOKUP("mdp_clk", mdp_clk.c, NULL), |
| 3589 | CLK_LOOKUP("mdp_vsync_clk", mdp_vsync_clk.c, NULL), |
| 3590 | CLK_LOOKUP("pixel_lcdc_clk", pixel_lcdc_clk.c, NULL), |
| 3591 | CLK_LOOKUP("pixel_mdp_clk", pixel_mdp_clk.c, NULL), |
| 3592 | CLK_LOOKUP("rot_clk", rot_clk.c, NULL), |
| 3593 | CLK_LOOKUP("tv_enc_clk", tv_enc_clk.c, NULL), |
| 3594 | CLK_LOOKUP("tv_dac_clk", tv_dac_clk.c, NULL), |
| 3595 | CLK_LOOKUP("vcodec_clk", vcodec_clk.c, NULL), |
| 3596 | CLK_LOOKUP("mdp_tv_clk", mdp_tv_clk.c, NULL), |
| 3597 | CLK_LOOKUP("hdmi_clk", hdmi_tv_clk.c, NULL), |
| 3598 | CLK_LOOKUP("tv_src_clk", tv_src_clk.c, NULL), |
| 3599 | CLK_LOOKUP("hdmi_app_clk", hdmi_app_clk.c, NULL), |
| 3600 | CLK_LOOKUP("vpe_clk", vpe_clk.c, NULL), |
| 3601 | CLK_LOOKUP("csi_vfe_clk", csi0_vfe_clk.c, NULL), |
| 3602 | CLK_LOOKUP("csi_vfe_clk", csi1_vfe_clk.c, "msm_camera_ov7692.0"), |
| 3603 | CLK_LOOKUP("csi_vfe_clk", csi1_vfe_clk.c, "msm_camera_ov9726.0"), |
| 3604 | CLK_LOOKUP("vfe_clk", vfe_clk.c, NULL), |
| 3605 | CLK_LOOKUP("smmu_jpegd_clk", jpegd_axi_clk.c, NULL), |
| 3606 | CLK_LOOKUP("smmu_vfe_clk", vfe_axi_clk.c, NULL), |
| 3607 | CLK_LOOKUP("vfe_axi_clk", vfe_axi_clk.c, NULL), |
| 3608 | CLK_LOOKUP("ijpeg_axi_clk", ijpeg_axi_clk.c, NULL), |
| 3609 | CLK_LOOKUP("imem_axi_clk", imem_axi_clk.c, NULL), |
| 3610 | CLK_LOOKUP("mdp_axi_clk", mdp_axi_clk.c, NULL), |
| 3611 | CLK_LOOKUP("rot_axi_clk", rot_axi_clk.c, NULL), |
| 3612 | CLK_LOOKUP("vcodec_axi_clk", vcodec_axi_clk.c, NULL), |
| 3613 | CLK_LOOKUP("vpe_axi_clk", vpe_axi_clk.c, NULL), |
| 3614 | CLK_LOOKUP("amp_pclk", amp_p_clk.c, NULL), |
| 3615 | CLK_LOOKUP("csi_pclk", csi0_p_clk.c, NULL), |
| 3616 | CLK_LOOKUP("csi_pclk", csi1_p_clk.c, "msm_camera_ov7692.0"), |
| 3617 | CLK_LOOKUP("csi_pclk", csi1_p_clk.c, "msm_camera_ov9726.0"), |
| 3618 | CLK_LOOKUP("dsi_m_pclk", dsi_m_p_clk.c, NULL), |
| 3619 | CLK_LOOKUP("dsi_s_pclk", dsi_s_p_clk.c, NULL), |
| 3620 | CLK_LOOKUP("gfx2d0_pclk", gfx2d0_p_clk.c, NULL), |
| 3621 | CLK_LOOKUP("gfx2d1_pclk", gfx2d1_p_clk.c, NULL), |
| 3622 | CLK_LOOKUP("gfx3d_pclk", gfx3d_p_clk.c, NULL), |
| 3623 | CLK_LOOKUP("hdmi_m_pclk", hdmi_m_p_clk.c, NULL), |
| 3624 | CLK_LOOKUP("hdmi_s_pclk", hdmi_s_p_clk.c, NULL), |
| 3625 | CLK_LOOKUP("ijpeg_pclk", ijpeg_p_clk.c, NULL), |
| 3626 | CLK_LOOKUP("jpegd_pclk", jpegd_p_clk.c, NULL), |
| 3627 | CLK_LOOKUP("imem_pclk", imem_p_clk.c, NULL), |
| 3628 | CLK_LOOKUP("mdp_pclk", mdp_p_clk.c, NULL), |
| 3629 | CLK_LOOKUP("smmu_pclk", smmu_p_clk.c, NULL), |
| 3630 | CLK_LOOKUP("rotator_pclk", rot_p_clk.c, NULL), |
| 3631 | CLK_LOOKUP("tv_enc_pclk", tv_enc_p_clk.c, NULL), |
| 3632 | CLK_LOOKUP("vcodec_pclk", vcodec_p_clk.c, NULL), |
| 3633 | CLK_LOOKUP("vfe_pclk", vfe_p_clk.c, NULL), |
| 3634 | CLK_LOOKUP("vpe_pclk", vpe_p_clk.c, NULL), |
| 3635 | CLK_LOOKUP("mi2s_osr_clk", mi2s_osr_clk.c, NULL), |
| 3636 | CLK_LOOKUP("mi2s_bit_clk", mi2s_bit_clk.c, NULL), |
| 3637 | CLK_LOOKUP("i2s_mic_osr_clk", codec_i2s_mic_osr_clk.c, NULL), |
| 3638 | CLK_LOOKUP("i2s_mic_bit_clk", codec_i2s_mic_bit_clk.c, NULL), |
| 3639 | CLK_LOOKUP("i2s_mic_osr_clk", spare_i2s_mic_osr_clk.c, NULL), |
| 3640 | CLK_LOOKUP("i2s_mic_bit_clk", spare_i2s_mic_bit_clk.c, NULL), |
| 3641 | CLK_LOOKUP("i2s_spkr_osr_clk", codec_i2s_spkr_osr_clk.c, NULL), |
| 3642 | CLK_LOOKUP("i2s_spkr_bit_clk", codec_i2s_spkr_bit_clk.c, NULL), |
| 3643 | CLK_LOOKUP("i2s_spkr_osr_clk", spare_i2s_spkr_osr_clk.c, NULL), |
| 3644 | CLK_LOOKUP("i2s_spkr_bit_clk", spare_i2s_spkr_bit_clk.c, NULL), |
| 3645 | CLK_LOOKUP("pcm_clk", pcm_clk.c, NULL), |
| 3646 | CLK_LOOKUP("iommu_clk", jpegd_axi_clk.c, "msm_iommu.0"), |
| 3647 | CLK_LOOKUP("iommu_clk", mdp_axi_clk.c, "msm_iommu.2"), |
| 3648 | CLK_LOOKUP("iommu_clk", mdp_axi_clk.c, "msm_iommu.3"), |
| 3649 | CLK_LOOKUP("iommu_clk", ijpeg_axi_clk.c, "msm_iommu.5"), |
| 3650 | CLK_LOOKUP("iommu_clk", vfe_axi_clk.c, "msm_iommu.6"), |
| 3651 | CLK_LOOKUP("iommu_clk", vcodec_axi_clk.c, "msm_iommu.7"), |
| 3652 | CLK_LOOKUP("iommu_clk", vcodec_axi_clk.c, "msm_iommu.8"), |
| 3653 | CLK_LOOKUP("iommu_clk", gfx3d_clk.c, "msm_iommu.9"), |
| 3654 | CLK_LOOKUP("iommu_clk", gfx2d0_clk.c, "msm_iommu.10"), |
| 3655 | CLK_LOOKUP("iommu_clk", gfx2d1_clk.c, "msm_iommu.11"), |
| 3656 | |
| 3657 | CLK_LOOKUP("dfab_dsps_clk", dfab_dsps_clk.c, NULL), |
| 3658 | CLK_LOOKUP("dfab_usb_hs_clk", dfab_usb_hs_clk.c, NULL), |
| 3659 | CLK_LOOKUP("dfab_sdc_clk", dfab_sdc1_clk.c, "msm_sdcc.1"), |
| 3660 | CLK_LOOKUP("dfab_sdc_clk", dfab_sdc2_clk.c, "msm_sdcc.2"), |
| 3661 | CLK_LOOKUP("dfab_sdc_clk", dfab_sdc3_clk.c, "msm_sdcc.3"), |
| 3662 | CLK_LOOKUP("dfab_sdc_clk", dfab_sdc4_clk.c, "msm_sdcc.4"), |
| 3663 | CLK_LOOKUP("dfab_sdc_clk", dfab_sdc5_clk.c, "msm_sdcc.5"), |
| 3664 | |
| 3665 | CLK_LOOKUP("ebi1_msmbus_clk", ebi1_msmbus_clk.c, NULL), |
| 3666 | CLK_LOOKUP("ebi1_clk", ebi1_adm0_clk.c, "msm_dmov.0"), |
| 3667 | CLK_LOOKUP("ebi1_clk", ebi1_adm1_clk.c, "msm_dmov.1"), |
| 3668 | |
| 3669 | CLK_LOOKUP("sc0_mclk", sc0_m_clk, NULL), |
| 3670 | CLK_LOOKUP("sc1_mclk", sc1_m_clk, NULL), |
| 3671 | CLK_LOOKUP("l2_mclk", l2_m_clk, NULL), |
| 3672 | }; |
| 3673 | |
| 3674 | /* |
| 3675 | * Miscellaneous clock register initializations |
| 3676 | */ |
| 3677 | |
| 3678 | /* Read, modify, then write-back a register. */ |
| 3679 | static void __init rmwreg(uint32_t val, void *reg, uint32_t mask) |
| 3680 | { |
| 3681 | uint32_t regval = readl_relaxed(reg); |
| 3682 | regval &= ~mask; |
| 3683 | regval |= val; |
| 3684 | writel_relaxed(regval, reg); |
| 3685 | } |
| 3686 | |
| 3687 | static void __init reg_init(void) |
| 3688 | { |
| 3689 | /* Setup MM_PLL2 (PLL3), but turn it off. Rate set by set_rate_tv(). */ |
| 3690 | rmwreg(0, MM_PLL2_MODE_REG, BIT(0)); /* Disable output */ |
| 3691 | /* Set ref, bypass, assert reset, disable output, disable test mode */ |
| 3692 | writel_relaxed(0, MM_PLL2_MODE_REG); /* PXO */ |
| 3693 | writel_relaxed(0x00800000, MM_PLL2_CONFIG_REG); /* Enable main out. */ |
| 3694 | |
| 3695 | /* The clock driver doesn't use SC1's voting register to control |
| 3696 | * HW-voteable clocks. Clear its bits so that disabling bits in the |
| 3697 | * SC0 register will cause the corresponding clocks to be disabled. */ |
| 3698 | rmwreg(BIT(12)|BIT(11), SC0_U_CLK_BRANCH_ENA_VOTE_REG, BM(12, 11)); |
| 3699 | writel_relaxed(BIT(12)|BIT(11), SC1_U_CLK_BRANCH_ENA_VOTE_REG); |
| 3700 | /* Let sc_aclk and sc_clk halt when both Scorpions are collapsed. */ |
| 3701 | writel_relaxed(BIT(12)|BIT(11), SC0_U_CLK_SLEEP_ENA_VOTE_REG); |
| 3702 | writel_relaxed(BIT(12)|BIT(11), SC1_U_CLK_SLEEP_ENA_VOTE_REG); |
| 3703 | |
| 3704 | /* Deassert MM SW_RESET_ALL signal. */ |
| 3705 | writel_relaxed(0, SW_RESET_ALL_REG); |
| 3706 | |
| 3707 | /* Initialize MM AHB registers: Enable the FPB clock and disable HW |
| 3708 | * gating for all clocks. Also set VFE_AHB's FORCE_CORE_ON bit to |
| 3709 | * prevent its memory from being collapsed when the clock is halted. |
| 3710 | * The sleep and wake-up delays are set to safe values. */ |
| 3711 | rmwreg(0x00000003, AHB_EN_REG, 0x0F7FFFFF); |
| 3712 | rmwreg(0x000007F9, AHB_EN2_REG, 0x7FFFBFFF); |
| 3713 | |
| 3714 | /* Deassert all locally-owned MM AHB resets. */ |
| 3715 | rmwreg(0, SW_RESET_AHB_REG, 0xFFF7DFFF); |
| 3716 | |
| 3717 | /* Initialize MM AXI registers: Enable HW gating for all clocks that |
| 3718 | * support it. Also set FORCE_CORE_ON bits, and any sleep and wake-up |
| 3719 | * delays to safe values. */ |
| 3720 | rmwreg(0x000207F9, MAXI_EN_REG, 0x0FFFFFFF); |
Matt Wagantall | f63a889 | 2011-06-15 16:44:46 -0700 | [diff] [blame] | 3721 | writel_relaxed(0x7027FCFF, MAXI_EN2_REG); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3722 | writel_relaxed(0x3FE7FCFF, MAXI_EN3_REG); |
| 3723 | writel_relaxed(0x000001D8, SAXI_EN_REG); |
| 3724 | |
| 3725 | /* Initialize MM CC registers: Set MM FORCE_CORE_ON bits so that core |
| 3726 | * memories retain state even when not clocked. Also, set sleep and |
| 3727 | * wake-up delays to safe values. */ |
| 3728 | writel_relaxed(0x00000000, CSI_CC_REG); |
| 3729 | rmwreg(0x00000000, MISC_CC_REG, 0xFEFFF3FF); |
| 3730 | rmwreg(0x000007FD, MISC_CC2_REG, 0xFFFF7FFF); |
| 3731 | writel_relaxed(0x80FF0000, GFX2D0_CC_REG); |
| 3732 | writel_relaxed(0x80FF0000, GFX2D1_CC_REG); |
| 3733 | writel_relaxed(0x80FF0000, GFX3D_CC_REG); |
| 3734 | writel_relaxed(0x80FF0000, IJPEG_CC_REG); |
| 3735 | writel_relaxed(0x80FF0000, JPEGD_CC_REG); |
| 3736 | /* MDP and PIXEL clocks may be running at boot, don't turn them off. */ |
| 3737 | rmwreg(0x80FF0000, MDP_CC_REG, BM(31, 29) | BM(23, 16)); |
| 3738 | rmwreg(0x80FF0000, PIXEL_CC_REG, BM(31, 29) | BM(23, 16)); |
| 3739 | writel_relaxed(0x000004FF, PIXEL_CC2_REG); |
| 3740 | writel_relaxed(0x80FF0000, ROT_CC_REG); |
| 3741 | writel_relaxed(0x80FF0000, TV_CC_REG); |
| 3742 | writel_relaxed(0x000004FF, TV_CC2_REG); |
| 3743 | writel_relaxed(0xC0FF0000, VCODEC_CC_REG); |
| 3744 | writel_relaxed(0x80FF0000, VFE_CC_REG); |
| 3745 | writel_relaxed(0x80FF0000, VPE_CC_REG); |
| 3746 | |
| 3747 | /* De-assert MM AXI resets to all hardware blocks. */ |
| 3748 | writel_relaxed(0, SW_RESET_AXI_REG); |
| 3749 | |
| 3750 | /* Deassert all MM core resets. */ |
| 3751 | writel_relaxed(0, SW_RESET_CORE_REG); |
| 3752 | |
| 3753 | /* Reset 3D core once more, with its clock enabled. This can |
| 3754 | * eventually be done as part of the GDFS footswitch driver. */ |
| 3755 | clk_set_rate(&gfx3d_clk.c, 27000000); |
| 3756 | clk_enable(&gfx3d_clk.c); |
| 3757 | writel_relaxed(BIT(12), SW_RESET_CORE_REG); |
| 3758 | mb(); |
| 3759 | udelay(5); |
| 3760 | writel_relaxed(0, SW_RESET_CORE_REG); |
| 3761 | /* Make sure reset is de-asserted before clock is disabled. */ |
| 3762 | mb(); |
| 3763 | clk_disable(&gfx3d_clk.c); |
| 3764 | |
| 3765 | /* Enable TSSC and PDM PXO sources. */ |
| 3766 | writel_relaxed(BIT(11), TSSC_CLK_CTL_REG); |
| 3767 | writel_relaxed(BIT(15), PDM_CLK_NS_REG); |
| 3768 | /* Set the dsi_byte_clk src to the DSI PHY PLL, |
| 3769 | * dsi_esc_clk to PXO/2, and the hdmi_app_clk src to PXO */ |
| 3770 | rmwreg(0x400001, MISC_CC2_REG, 0x424003); |
| 3771 | } |
| 3772 | |
| 3773 | /* Local clock driver initialization. */ |
| 3774 | void __init msm8660_clock_init(void) |
| 3775 | { |
| 3776 | soc_update_sys_vdd = msm8660_update_sys_vdd; |
| 3777 | xo_pxo = msm_xo_get(MSM_XO_PXO, "clock-8x60"); |
| 3778 | if (IS_ERR(xo_pxo)) { |
| 3779 | pr_err("%s: msm_xo_get(PXO) failed.\n", __func__); |
| 3780 | BUG(); |
| 3781 | } |
| 3782 | xo_cxo = msm_xo_get(MSM_XO_TCXO_D1, "clock-8x60"); |
| 3783 | if (IS_ERR(xo_cxo)) { |
| 3784 | pr_err("%s: msm_xo_get(CXO) failed.\n", __func__); |
| 3785 | BUG(); |
| 3786 | } |
| 3787 | |
| 3788 | local_vote_sys_vdd(HIGH); |
| 3789 | /* Initialize clock registers. */ |
| 3790 | reg_init(); |
| 3791 | |
| 3792 | /* Initialize rates for clocks that only support one. */ |
| 3793 | clk_set_rate(&pdm_clk.c, 27000000); |
| 3794 | clk_set_rate(&prng_clk.c, 64000000); |
| 3795 | clk_set_rate(&mdp_vsync_clk.c, 27000000); |
| 3796 | clk_set_rate(&tsif_ref_clk.c, 105000); |
| 3797 | clk_set_rate(&tssc_clk.c, 27000000); |
| 3798 | clk_set_rate(&usb_hs1_xcvr_clk.c, 60000000); |
| 3799 | clk_set_rate(&usb_fs1_src_clk.c, 60000000); |
| 3800 | clk_set_rate(&usb_fs2_src_clk.c, 60000000); |
| 3801 | |
| 3802 | /* The halt status bits for PDM and TSSC may be incorrect at boot. |
| 3803 | * Toggle these clocks on and off to refresh them. */ |
Matt Wagantall | 0625ea0 | 2011-07-13 18:51:56 -0700 | [diff] [blame] | 3804 | rcg_clk_enable(&pdm_clk.c); |
| 3805 | rcg_clk_disable(&pdm_clk.c); |
| 3806 | rcg_clk_enable(&tssc_clk.c); |
| 3807 | rcg_clk_disable(&tssc_clk.c); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3808 | |
| 3809 | msm_clock_init(msm_clocks_8x60, ARRAY_SIZE(msm_clocks_8x60)); |
| 3810 | } |
| 3811 | |
| 3812 | static int __init msm_clk_soc_late_init(void) |
| 3813 | { |
| 3814 | int rc; |
| 3815 | |
| 3816 | /* Vote for MMFPB to be at least 64MHz when an Apps CPU is active. */ |
| 3817 | struct clk *mmfpb_a_clk = clk_get(NULL, "mmfpb_a_clk"); |
| 3818 | if (WARN(IS_ERR(mmfpb_a_clk), "mmfpb_a_clk not found (%ld)\n", |
| 3819 | PTR_ERR(mmfpb_a_clk))) |
| 3820 | return PTR_ERR(mmfpb_a_clk); |
| 3821 | rc = clk_set_min_rate(mmfpb_a_clk, 64000000); |
| 3822 | if (WARN(rc, "mmfpb_a_clk rate was not set (%d)\n", rc)) |
| 3823 | return rc; |
| 3824 | rc = clk_enable(mmfpb_a_clk); |
| 3825 | if (WARN(rc, "mmfpb_a_clk not enabled (%d)\n", rc)) |
| 3826 | return rc; |
| 3827 | |
| 3828 | /* Remove temporary vote for HIGH vdd_dig. */ |
| 3829 | rc = local_unvote_sys_vdd(HIGH); |
| 3830 | WARN(rc, "local_unvote_sys_vdd(HIGH) failed (%d)\n", rc); |
| 3831 | |
| 3832 | return rc; |
| 3833 | } |
| 3834 | late_initcall(msm_clk_soc_late_init); |