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