Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010-2011 Freescale Semiconductor, Inc. |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Christian Gmeiner | e584814 | 2014-01-08 08:24:25 +0100 | [diff] [blame] | 8 | #include <div64.h> |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 9 | #include <asm/io.h> |
| 10 | #include <asm/errno.h> |
| 11 | #include <asm/arch/imx-regs.h> |
Fabio Estevam | 6479f51 | 2012-04-29 08:11:13 +0000 | [diff] [blame] | 12 | #include <asm/arch/crm_regs.h> |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 13 | #include <asm/arch/clock.h> |
Fabio Estevam | 6479f51 | 2012-04-29 08:11:13 +0000 | [diff] [blame] | 14 | #include <asm/arch/sys_proto.h> |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 15 | |
| 16 | enum pll_clocks { |
| 17 | PLL_SYS, /* System PLL */ |
| 18 | PLL_BUS, /* System Bus PLL*/ |
| 19 | PLL_USBOTG, /* OTG USB PLL */ |
| 20 | PLL_ENET, /* ENET PLL */ |
| 21 | }; |
| 22 | |
Fabio Estevam | 6479f51 | 2012-04-29 08:11:13 +0000 | [diff] [blame] | 23 | struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 24 | |
Benoît Thébaudeau | 20db631 | 2013-04-23 10:17:44 +0000 | [diff] [blame] | 25 | #ifdef CONFIG_MXC_OCOTP |
| 26 | void enable_ocotp_clk(unsigned char enable) |
| 27 | { |
| 28 | u32 reg; |
| 29 | |
| 30 | reg = __raw_readl(&imx_ccm->CCGR2); |
| 31 | if (enable) |
| 32 | reg |= MXC_CCM_CCGR2_OCOTP_CTRL_MASK; |
| 33 | else |
| 34 | reg &= ~MXC_CCM_CCGR2_OCOTP_CTRL_MASK; |
| 35 | __raw_writel(reg, &imx_ccm->CCGR2); |
| 36 | } |
| 37 | #endif |
| 38 | |
Nikita Kiryanov | 98b76b4 | 2014-08-20 15:08:49 +0300 | [diff] [blame^] | 39 | #ifdef CONFIG_NAND_MXS |
| 40 | void setup_gpmi_io_clk(u32 cfg) |
| 41 | { |
| 42 | /* Disable clocks per ERR007177 from MX6 errata */ |
| 43 | clrbits_le32(&imx_ccm->CCGR4, |
| 44 | MXC_CCM_CCGR4_RAWNAND_U_BCH_INPUT_APB_MASK | |
| 45 | MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_BCH_MASK | |
| 46 | MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_GPMI_IO_MASK | |
| 47 | MXC_CCM_CCGR4_RAWNAND_U_GPMI_INPUT_APB_MASK | |
| 48 | MXC_CCM_CCGR4_PL301_MX6QPER1_BCH_MASK); |
| 49 | |
| 50 | clrbits_le32(&imx_ccm->CCGR2, MXC_CCM_CCGR2_IOMUX_IPT_CLK_IO_MASK); |
| 51 | |
| 52 | clrsetbits_le32(&imx_ccm->cs2cdr, |
| 53 | MXC_CCM_CS2CDR_ENFC_CLK_PODF_MASK | |
| 54 | MXC_CCM_CS2CDR_ENFC_CLK_PRED_MASK | |
| 55 | MXC_CCM_CS2CDR_ENFC_CLK_SEL_MASK, |
| 56 | cfg); |
| 57 | |
| 58 | setbits_le32(&imx_ccm->CCGR2, MXC_CCM_CCGR2_IOMUX_IPT_CLK_IO_MASK); |
| 59 | setbits_le32(&imx_ccm->CCGR4, |
| 60 | MXC_CCM_CCGR4_RAWNAND_U_BCH_INPUT_APB_MASK | |
| 61 | MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_BCH_MASK | |
| 62 | MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_GPMI_IO_MASK | |
| 63 | MXC_CCM_CCGR4_RAWNAND_U_GPMI_INPUT_APB_MASK | |
| 64 | MXC_CCM_CCGR4_PL301_MX6QPER1_BCH_MASK); |
| 65 | } |
| 66 | #endif |
| 67 | |
Wolfgang Grandegger | 1859b70 | 2012-02-08 22:33:25 +0000 | [diff] [blame] | 68 | void enable_usboh3_clk(unsigned char enable) |
| 69 | { |
| 70 | u32 reg; |
| 71 | |
| 72 | reg = __raw_readl(&imx_ccm->CCGR6); |
| 73 | if (enable) |
Eric Nelson | e427954 | 2012-09-21 07:33:51 +0000 | [diff] [blame] | 74 | reg |= MXC_CCM_CCGR6_USBOH3_MASK; |
Wolfgang Grandegger | 1859b70 | 2012-02-08 22:33:25 +0000 | [diff] [blame] | 75 | else |
Eric Nelson | e427954 | 2012-09-21 07:33:51 +0000 | [diff] [blame] | 76 | reg &= ~(MXC_CCM_CCGR6_USBOH3_MASK); |
Wolfgang Grandegger | 1859b70 | 2012-02-08 22:33:25 +0000 | [diff] [blame] | 77 | __raw_writel(reg, &imx_ccm->CCGR6); |
| 78 | |
Nikita Kiryanov | 98b76b4 | 2014-08-20 15:08:49 +0300 | [diff] [blame^] | 79 | } |
| 80 | |
| 81 | #ifdef CONFIG_FEC_MXC |
| 82 | void enable_enet_clk(unsigned char enable) |
| 83 | { |
| 84 | u32 mask = MXC_CCM_CCGR1_ENET_CLK_ENABLE_MASK; |
| 85 | |
| 86 | if (enable) |
| 87 | setbits_le32(&imx_ccm->CCGR1, mask); |
| 88 | else |
| 89 | clrbits_le32(&imx_ccm->CCGR1, mask); |
| 90 | } |
| 91 | #endif |
| 92 | |
| 93 | #ifdef CONFIG_MXC_UART |
| 94 | void enable_uart_clk(unsigned char enable) |
| 95 | { |
| 96 | u32 mask = MXC_CCM_CCGR5_UART_MASK | MXC_CCM_CCGR5_UART_SERIAL_MASK; |
| 97 | |
| 98 | if (enable) |
| 99 | setbits_le32(&imx_ccm->CCGR5, mask); |
| 100 | else |
| 101 | clrbits_le32(&imx_ccm->CCGR5, mask); |
| 102 | } |
| 103 | #endif |
| 104 | |
| 105 | #ifdef CONFIG_SPI |
| 106 | /* spi_num can be from 0 - 4 */ |
| 107 | int enable_cspi_clock(unsigned char enable, unsigned spi_num) |
| 108 | { |
| 109 | u32 mask; |
| 110 | |
| 111 | if (spi_num > 4) |
| 112 | return -EINVAL; |
| 113 | |
| 114 | mask = MXC_CCM_CCGR_CG_MASK << (spi_num * 2); |
| 115 | if (enable) |
| 116 | setbits_le32(&imx_ccm->CCGR1, mask); |
| 117 | else |
| 118 | clrbits_le32(&imx_ccm->CCGR1, mask); |
| 119 | |
| 120 | return 0; |
| 121 | } |
| 122 | #endif |
| 123 | |
| 124 | #ifdef CONFIG_MMC |
| 125 | int enable_usdhc_clk(unsigned char enable, unsigned bus_num) |
| 126 | { |
| 127 | u32 mask; |
| 128 | |
| 129 | if (bus_num > 3) |
| 130 | return -EINVAL; |
| 131 | |
| 132 | mask = MXC_CCM_CCGR_CG_MASK << (bus_num * 2 + 2); |
| 133 | if (enable) |
| 134 | setbits_le32(&imx_ccm->CCGR6, mask); |
| 135 | else |
| 136 | clrbits_le32(&imx_ccm->CCGR6, mask); |
| 137 | |
| 138 | return 0; |
Wolfgang Grandegger | 1859b70 | 2012-02-08 22:33:25 +0000 | [diff] [blame] | 139 | } |
Nikita Kiryanov | 98b76b4 | 2014-08-20 15:08:49 +0300 | [diff] [blame^] | 140 | #endif |
Wolfgang Grandegger | 1859b70 | 2012-02-08 22:33:25 +0000 | [diff] [blame] | 141 | |
trem | a49f40a | 2013-09-21 18:13:35 +0200 | [diff] [blame] | 142 | #ifdef CONFIG_SYS_I2C_MXC |
Troy Kisky | d4fdc99 | 2012-07-19 08:18:25 +0000 | [diff] [blame] | 143 | /* i2c_num can be from 0 - 2 */ |
| 144 | int enable_i2c_clk(unsigned char enable, unsigned i2c_num) |
| 145 | { |
| 146 | u32 reg; |
| 147 | u32 mask; |
| 148 | |
| 149 | if (i2c_num > 2) |
| 150 | return -EINVAL; |
Eric Nelson | e427954 | 2012-09-21 07:33:51 +0000 | [diff] [blame] | 151 | |
| 152 | mask = MXC_CCM_CCGR_CG_MASK |
| 153 | << (MXC_CCM_CCGR2_I2C1_SERIAL_OFFSET + (i2c_num << 1)); |
Troy Kisky | d4fdc99 | 2012-07-19 08:18:25 +0000 | [diff] [blame] | 154 | reg = __raw_readl(&imx_ccm->CCGR2); |
| 155 | if (enable) |
| 156 | reg |= mask; |
| 157 | else |
| 158 | reg &= ~mask; |
| 159 | __raw_writel(reg, &imx_ccm->CCGR2); |
| 160 | return 0; |
| 161 | } |
| 162 | #endif |
| 163 | |
Heiko Schocher | 472a68f | 2014-07-18 06:07:20 +0200 | [diff] [blame] | 164 | /* spi_num can be from 0 - SPI_MAX_NUM */ |
| 165 | int enable_spi_clk(unsigned char enable, unsigned spi_num) |
| 166 | { |
| 167 | u32 reg; |
| 168 | u32 mask; |
| 169 | |
| 170 | if (spi_num > SPI_MAX_NUM) |
| 171 | return -EINVAL; |
| 172 | |
| 173 | mask = MXC_CCM_CCGR_CG_MASK << (spi_num << 1); |
| 174 | reg = __raw_readl(&imx_ccm->CCGR1); |
| 175 | if (enable) |
| 176 | reg |= mask; |
| 177 | else |
| 178 | reg &= ~mask; |
| 179 | __raw_writel(reg, &imx_ccm->CCGR1); |
| 180 | return 0; |
| 181 | } |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 182 | static u32 decode_pll(enum pll_clocks pll, u32 infreq) |
| 183 | { |
| 184 | u32 div; |
| 185 | |
| 186 | switch (pll) { |
| 187 | case PLL_SYS: |
| 188 | div = __raw_readl(&imx_ccm->analog_pll_sys); |
| 189 | div &= BM_ANADIG_PLL_SYS_DIV_SELECT; |
| 190 | |
Andre Renaud | b0be82e | 2014-06-10 08:47:13 +1200 | [diff] [blame] | 191 | return (infreq * div) >> 1; |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 192 | case PLL_BUS: |
| 193 | div = __raw_readl(&imx_ccm->analog_pll_528); |
| 194 | div &= BM_ANADIG_PLL_528_DIV_SELECT; |
| 195 | |
| 196 | return infreq * (20 + (div << 1)); |
| 197 | case PLL_USBOTG: |
| 198 | div = __raw_readl(&imx_ccm->analog_usb1_pll_480_ctrl); |
| 199 | div &= BM_ANADIG_USB1_PLL_480_CTRL_DIV_SELECT; |
| 200 | |
| 201 | return infreq * (20 + (div << 1)); |
| 202 | case PLL_ENET: |
| 203 | div = __raw_readl(&imx_ccm->analog_pll_enet); |
| 204 | div &= BM_ANADIG_PLL_ENET_DIV_SELECT; |
| 205 | |
Fabio Estevam | 93bc8ea | 2013-12-03 18:26:13 -0200 | [diff] [blame] | 206 | return 25000000 * (div + (div >> 1) + 1); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 207 | default: |
| 208 | return 0; |
| 209 | } |
| 210 | /* NOTREACHED */ |
| 211 | } |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 212 | static u32 mxc_get_pll_pfd(enum pll_clocks pll, int pfd_num) |
| 213 | { |
| 214 | u32 div; |
| 215 | u64 freq; |
| 216 | |
| 217 | switch (pll) { |
| 218 | case PLL_BUS: |
| 219 | if (pfd_num == 3) { |
| 220 | /* No PFD3 on PPL2 */ |
| 221 | return 0; |
| 222 | } |
| 223 | div = __raw_readl(&imx_ccm->analog_pfd_528); |
| 224 | freq = (u64)decode_pll(PLL_BUS, MXC_HCLK); |
| 225 | break; |
| 226 | case PLL_USBOTG: |
| 227 | div = __raw_readl(&imx_ccm->analog_pfd_480); |
| 228 | freq = (u64)decode_pll(PLL_USBOTG, MXC_HCLK); |
| 229 | break; |
| 230 | default: |
| 231 | /* No PFD on other PLL */ |
| 232 | return 0; |
| 233 | } |
| 234 | |
Christian Gmeiner | e584814 | 2014-01-08 08:24:25 +0100 | [diff] [blame] | 235 | return lldiv(freq * 18, (div & ANATOP_PFD_FRAC_MASK(pfd_num)) >> |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 236 | ANATOP_PFD_FRAC_SHIFT(pfd_num)); |
| 237 | } |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 238 | |
| 239 | static u32 get_mcu_main_clk(void) |
| 240 | { |
| 241 | u32 reg, freq; |
| 242 | |
| 243 | reg = __raw_readl(&imx_ccm->cacrr); |
| 244 | reg &= MXC_CCM_CACRR_ARM_PODF_MASK; |
| 245 | reg >>= MXC_CCM_CACRR_ARM_PODF_OFFSET; |
Benoît Thébaudeau | afac165 | 2012-09-27 10:19:58 +0000 | [diff] [blame] | 246 | freq = decode_pll(PLL_SYS, MXC_HCLK); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 247 | |
| 248 | return freq / (reg + 1); |
| 249 | } |
| 250 | |
Fabio Estevam | 6479f51 | 2012-04-29 08:11:13 +0000 | [diff] [blame] | 251 | u32 get_periph_clk(void) |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 252 | { |
| 253 | u32 reg, freq = 0; |
| 254 | |
| 255 | reg = __raw_readl(&imx_ccm->cbcdr); |
| 256 | if (reg & MXC_CCM_CBCDR_PERIPH_CLK_SEL) { |
| 257 | reg = __raw_readl(&imx_ccm->cbcmr); |
| 258 | reg &= MXC_CCM_CBCMR_PERIPH_CLK2_SEL_MASK; |
| 259 | reg >>= MXC_CCM_CBCMR_PERIPH_CLK2_SEL_OFFSET; |
| 260 | |
| 261 | switch (reg) { |
| 262 | case 0: |
Benoît Thébaudeau | afac165 | 2012-09-27 10:19:58 +0000 | [diff] [blame] | 263 | freq = decode_pll(PLL_USBOTG, MXC_HCLK); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 264 | break; |
| 265 | case 1: |
| 266 | case 2: |
Benoît Thébaudeau | afac165 | 2012-09-27 10:19:58 +0000 | [diff] [blame] | 267 | freq = MXC_HCLK; |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 268 | break; |
| 269 | default: |
| 270 | break; |
| 271 | } |
| 272 | } else { |
| 273 | reg = __raw_readl(&imx_ccm->cbcmr); |
| 274 | reg &= MXC_CCM_CBCMR_PRE_PERIPH_CLK_SEL_MASK; |
| 275 | reg >>= MXC_CCM_CBCMR_PRE_PERIPH_CLK_SEL_OFFSET; |
| 276 | |
| 277 | switch (reg) { |
| 278 | case 0: |
Benoît Thébaudeau | afac165 | 2012-09-27 10:19:58 +0000 | [diff] [blame] | 279 | freq = decode_pll(PLL_BUS, MXC_HCLK); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 280 | break; |
| 281 | case 1: |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 282 | freq = mxc_get_pll_pfd(PLL_BUS, 2); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 283 | break; |
| 284 | case 2: |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 285 | freq = mxc_get_pll_pfd(PLL_BUS, 0); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 286 | break; |
| 287 | case 3: |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 288 | /* static / 2 divider */ |
| 289 | freq = mxc_get_pll_pfd(PLL_BUS, 2) / 2; |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 290 | break; |
| 291 | default: |
| 292 | break; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | return freq; |
| 297 | } |
| 298 | |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 299 | static u32 get_ipg_clk(void) |
| 300 | { |
| 301 | u32 reg, ipg_podf; |
| 302 | |
| 303 | reg = __raw_readl(&imx_ccm->cbcdr); |
| 304 | reg &= MXC_CCM_CBCDR_IPG_PODF_MASK; |
| 305 | ipg_podf = reg >> MXC_CCM_CBCDR_IPG_PODF_OFFSET; |
| 306 | |
| 307 | return get_ahb_clk() / (ipg_podf + 1); |
| 308 | } |
| 309 | |
| 310 | static u32 get_ipg_per_clk(void) |
| 311 | { |
| 312 | u32 reg, perclk_podf; |
| 313 | |
| 314 | reg = __raw_readl(&imx_ccm->cscmr1); |
| 315 | perclk_podf = reg & MXC_CCM_CSCMR1_PERCLK_PODF_MASK; |
| 316 | |
| 317 | return get_ipg_clk() / (perclk_podf + 1); |
| 318 | } |
| 319 | |
| 320 | static u32 get_uart_clk(void) |
| 321 | { |
| 322 | u32 reg, uart_podf; |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 323 | u32 freq = decode_pll(PLL_USBOTG, MXC_HCLK) / 6; /* static divider */ |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 324 | reg = __raw_readl(&imx_ccm->cscdr1); |
Fabio Estevam | 712ab88 | 2014-06-24 17:40:58 -0300 | [diff] [blame] | 325 | #if (defined(CONFIG_MX6SL) || defined(CONFIG_MX6SX)) |
Fabio Estevam | f7b9ac2 | 2013-04-10 09:32:57 +0000 | [diff] [blame] | 326 | if (reg & MXC_CCM_CSCDR1_UART_CLK_SEL) |
| 327 | freq = MXC_HCLK; |
| 328 | #endif |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 329 | reg &= MXC_CCM_CSCDR1_UART_CLK_PODF_MASK; |
| 330 | uart_podf = reg >> MXC_CCM_CSCDR1_UART_CLK_PODF_OFFSET; |
| 331 | |
Fabio Estevam | f7b9ac2 | 2013-04-10 09:32:57 +0000 | [diff] [blame] | 332 | return freq / (uart_podf + 1); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | static u32 get_cspi_clk(void) |
| 336 | { |
| 337 | u32 reg, cspi_podf; |
| 338 | |
| 339 | reg = __raw_readl(&imx_ccm->cscdr2); |
| 340 | reg &= MXC_CCM_CSCDR2_ECSPI_CLK_PODF_MASK; |
| 341 | cspi_podf = reg >> MXC_CCM_CSCDR2_ECSPI_CLK_PODF_OFFSET; |
| 342 | |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 343 | return decode_pll(PLL_USBOTG, MXC_HCLK) / (8 * (cspi_podf + 1)); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | static u32 get_axi_clk(void) |
| 347 | { |
| 348 | u32 root_freq, axi_podf; |
| 349 | u32 cbcdr = __raw_readl(&imx_ccm->cbcdr); |
| 350 | |
| 351 | axi_podf = cbcdr & MXC_CCM_CBCDR_AXI_PODF_MASK; |
| 352 | axi_podf >>= MXC_CCM_CBCDR_AXI_PODF_OFFSET; |
| 353 | |
| 354 | if (cbcdr & MXC_CCM_CBCDR_AXI_SEL) { |
| 355 | if (cbcdr & MXC_CCM_CBCDR_AXI_ALT_SEL) |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 356 | root_freq = mxc_get_pll_pfd(PLL_BUS, 2); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 357 | else |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 358 | root_freq = mxc_get_pll_pfd(PLL_USBOTG, 1); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 359 | } else |
| 360 | root_freq = get_periph_clk(); |
| 361 | |
| 362 | return root_freq / (axi_podf + 1); |
| 363 | } |
| 364 | |
| 365 | static u32 get_emi_slow_clk(void) |
| 366 | { |
Andrew Gabbasov | 4740e24 | 2013-07-04 06:27:32 -0500 | [diff] [blame] | 367 | u32 emi_clk_sel, emi_slow_podf, cscmr1, root_freq = 0; |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 368 | |
| 369 | cscmr1 = __raw_readl(&imx_ccm->cscmr1); |
| 370 | emi_clk_sel = cscmr1 & MXC_CCM_CSCMR1_ACLK_EMI_SLOW_MASK; |
| 371 | emi_clk_sel >>= MXC_CCM_CSCMR1_ACLK_EMI_SLOW_OFFSET; |
Andrew Gabbasov | 4740e24 | 2013-07-04 06:27:32 -0500 | [diff] [blame] | 372 | emi_slow_podf = cscmr1 & MXC_CCM_CSCMR1_ACLK_EMI_SLOW_PODF_MASK; |
| 373 | emi_slow_podf >>= MXC_CCM_CSCMR1_ACLK_EMI_SLOW_PODF_OFFSET; |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 374 | |
| 375 | switch (emi_clk_sel) { |
| 376 | case 0: |
| 377 | root_freq = get_axi_clk(); |
| 378 | break; |
| 379 | case 1: |
Benoît Thébaudeau | afac165 | 2012-09-27 10:19:58 +0000 | [diff] [blame] | 380 | root_freq = decode_pll(PLL_USBOTG, MXC_HCLK); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 381 | break; |
| 382 | case 2: |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 383 | root_freq = mxc_get_pll_pfd(PLL_BUS, 2); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 384 | break; |
| 385 | case 3: |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 386 | root_freq = mxc_get_pll_pfd(PLL_BUS, 0); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 387 | break; |
| 388 | } |
| 389 | |
Andrew Gabbasov | 4740e24 | 2013-07-04 06:27:32 -0500 | [diff] [blame] | 390 | return root_freq / (emi_slow_podf + 1); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 391 | } |
| 392 | |
Fabio Estevam | 712ab88 | 2014-06-24 17:40:58 -0300 | [diff] [blame] | 393 | #if (defined(CONFIG_MX6SL) || defined(CONFIG_MX6SX)) |
Fabio Estevam | f7b9ac2 | 2013-04-10 09:32:57 +0000 | [diff] [blame] | 394 | static u32 get_mmdc_ch0_clk(void) |
| 395 | { |
| 396 | u32 cbcmr = __raw_readl(&imx_ccm->cbcmr); |
| 397 | u32 cbcdr = __raw_readl(&imx_ccm->cbcdr); |
| 398 | u32 freq, podf; |
| 399 | |
| 400 | podf = (cbcdr & MXC_CCM_CBCDR_MMDC_CH1_PODF_MASK) \ |
| 401 | >> MXC_CCM_CBCDR_MMDC_CH1_PODF_OFFSET; |
| 402 | |
| 403 | switch ((cbcmr & MXC_CCM_CBCMR_PRE_PERIPH2_CLK_SEL_MASK) >> |
| 404 | MXC_CCM_CBCMR_PRE_PERIPH2_CLK_SEL_OFFSET) { |
| 405 | case 0: |
| 406 | freq = decode_pll(PLL_BUS, MXC_HCLK); |
| 407 | break; |
| 408 | case 1: |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 409 | freq = mxc_get_pll_pfd(PLL_BUS, 2); |
Fabio Estevam | f7b9ac2 | 2013-04-10 09:32:57 +0000 | [diff] [blame] | 410 | break; |
| 411 | case 2: |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 412 | freq = mxc_get_pll_pfd(PLL_BUS, 0); |
Fabio Estevam | f7b9ac2 | 2013-04-10 09:32:57 +0000 | [diff] [blame] | 413 | break; |
| 414 | case 3: |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 415 | /* static / 2 divider */ |
| 416 | freq = mxc_get_pll_pfd(PLL_BUS, 2) / 2; |
Fabio Estevam | f7b9ac2 | 2013-04-10 09:32:57 +0000 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | return freq / (podf + 1); |
| 420 | |
| 421 | } |
Otavio Salvador | dc07443 | 2013-12-16 20:44:05 -0200 | [diff] [blame] | 422 | #else |
| 423 | static u32 get_mmdc_ch0_clk(void) |
| 424 | { |
| 425 | u32 cbcdr = __raw_readl(&imx_ccm->cbcdr); |
| 426 | u32 mmdc_ch0_podf = (cbcdr & MXC_CCM_CBCDR_MMDC_CH0_PODF_MASK) >> |
| 427 | MXC_CCM_CBCDR_MMDC_CH0_PODF_OFFSET; |
Fabio Estevam | 67b8b9d | 2013-09-13 00:36:28 -0300 | [diff] [blame] | 428 | |
Otavio Salvador | dc07443 | 2013-12-16 20:44:05 -0200 | [diff] [blame] | 429 | return get_periph_clk() / (mmdc_ch0_podf + 1); |
| 430 | } |
| 431 | #endif |
| 432 | |
| 433 | #ifdef CONFIG_FEC_MXC |
Fabio Estevam | b2903ae | 2014-01-03 15:55:57 -0200 | [diff] [blame] | 434 | int enable_fec_anatop_clock(enum enet_freq freq) |
Fabio Estevam | 67b8b9d | 2013-09-13 00:36:28 -0300 | [diff] [blame] | 435 | { |
| 436 | u32 reg = 0; |
| 437 | s32 timeout = 100000; |
| 438 | |
| 439 | struct anatop_regs __iomem *anatop = |
| 440 | (struct anatop_regs __iomem *)ANATOP_BASE_ADDR; |
| 441 | |
Fabio Estevam | b2903ae | 2014-01-03 15:55:57 -0200 | [diff] [blame] | 442 | if (freq < ENET_25MHz || freq > ENET_125MHz) |
| 443 | return -EINVAL; |
| 444 | |
Fabio Estevam | 67b8b9d | 2013-09-13 00:36:28 -0300 | [diff] [blame] | 445 | reg = readl(&anatop->pll_enet); |
Fabio Estevam | b2903ae | 2014-01-03 15:55:57 -0200 | [diff] [blame] | 446 | reg &= ~BM_ANADIG_PLL_ENET_DIV_SELECT; |
| 447 | reg |= freq; |
| 448 | |
Fabio Estevam | 67b8b9d | 2013-09-13 00:36:28 -0300 | [diff] [blame] | 449 | if ((reg & BM_ANADIG_PLL_ENET_POWERDOWN) || |
| 450 | (!(reg & BM_ANADIG_PLL_ENET_LOCK))) { |
| 451 | reg &= ~BM_ANADIG_PLL_ENET_POWERDOWN; |
| 452 | writel(reg, &anatop->pll_enet); |
| 453 | while (timeout--) { |
| 454 | if (readl(&anatop->pll_enet) & BM_ANADIG_PLL_ENET_LOCK) |
| 455 | break; |
| 456 | } |
| 457 | if (timeout < 0) |
| 458 | return -ETIMEDOUT; |
| 459 | } |
| 460 | |
| 461 | /* Enable FEC clock */ |
| 462 | reg |= BM_ANADIG_PLL_ENET_ENABLE; |
| 463 | reg &= ~BM_ANADIG_PLL_ENET_BYPASS; |
| 464 | writel(reg, &anatop->pll_enet); |
| 465 | |
Fabio Estevam | d4d6038 | 2014-08-15 00:24:30 -0300 | [diff] [blame] | 466 | #ifdef CONFIG_MX6SX |
| 467 | /* |
| 468 | * Set enet ahb clock to 200MHz |
| 469 | * pll2_pfd2_396m-> ENET_PODF-> ENET_AHB |
| 470 | */ |
| 471 | reg = readl(&imx_ccm->chsccdr); |
| 472 | reg &= ~(MXC_CCM_CHSCCDR_ENET_PRE_CLK_SEL_MASK |
| 473 | | MXC_CCM_CHSCCDR_ENET_PODF_MASK |
| 474 | | MXC_CCM_CHSCCDR_ENET_CLK_SEL_MASK); |
| 475 | /* PLL2 PFD2 */ |
| 476 | reg |= (4 << MXC_CCM_CHSCCDR_ENET_PRE_CLK_SEL_OFFSET); |
| 477 | /* Div = 2*/ |
| 478 | reg |= (1 << MXC_CCM_CHSCCDR_ENET_PODF_OFFSET); |
| 479 | reg |= (0 << MXC_CCM_CHSCCDR_ENET_CLK_SEL_OFFSET); |
| 480 | writel(reg, &imx_ccm->chsccdr); |
| 481 | |
| 482 | /* Enable enet system clock */ |
| 483 | reg = readl(&imx_ccm->CCGR3); |
| 484 | reg |= MXC_CCM_CCGR3_ENET_MASK; |
| 485 | writel(reg, &imx_ccm->CCGR3); |
| 486 | #endif |
Fabio Estevam | 67b8b9d | 2013-09-13 00:36:28 -0300 | [diff] [blame] | 487 | return 0; |
| 488 | } |
Fabio Estevam | f7b9ac2 | 2013-04-10 09:32:57 +0000 | [diff] [blame] | 489 | #endif |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 490 | |
| 491 | static u32 get_usdhc_clk(u32 port) |
| 492 | { |
| 493 | u32 root_freq = 0, usdhc_podf = 0, clk_sel = 0; |
| 494 | u32 cscmr1 = __raw_readl(&imx_ccm->cscmr1); |
| 495 | u32 cscdr1 = __raw_readl(&imx_ccm->cscdr1); |
| 496 | |
| 497 | switch (port) { |
| 498 | case 0: |
| 499 | usdhc_podf = (cscdr1 & MXC_CCM_CSCDR1_USDHC1_PODF_MASK) >> |
| 500 | MXC_CCM_CSCDR1_USDHC1_PODF_OFFSET; |
| 501 | clk_sel = cscmr1 & MXC_CCM_CSCMR1_USDHC1_CLK_SEL; |
| 502 | |
| 503 | break; |
| 504 | case 1: |
| 505 | usdhc_podf = (cscdr1 & MXC_CCM_CSCDR1_USDHC2_PODF_MASK) >> |
| 506 | MXC_CCM_CSCDR1_USDHC2_PODF_OFFSET; |
| 507 | clk_sel = cscmr1 & MXC_CCM_CSCMR1_USDHC2_CLK_SEL; |
| 508 | |
| 509 | break; |
| 510 | case 2: |
| 511 | usdhc_podf = (cscdr1 & MXC_CCM_CSCDR1_USDHC3_PODF_MASK) >> |
| 512 | MXC_CCM_CSCDR1_USDHC3_PODF_OFFSET; |
| 513 | clk_sel = cscmr1 & MXC_CCM_CSCMR1_USDHC3_CLK_SEL; |
| 514 | |
| 515 | break; |
| 516 | case 3: |
| 517 | usdhc_podf = (cscdr1 & MXC_CCM_CSCDR1_USDHC4_PODF_MASK) >> |
| 518 | MXC_CCM_CSCDR1_USDHC4_PODF_OFFSET; |
| 519 | clk_sel = cscmr1 & MXC_CCM_CSCMR1_USDHC4_CLK_SEL; |
| 520 | |
| 521 | break; |
| 522 | default: |
| 523 | break; |
| 524 | } |
| 525 | |
| 526 | if (clk_sel) |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 527 | root_freq = mxc_get_pll_pfd(PLL_BUS, 0); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 528 | else |
Pierre Aubert | e8e62a7 | 2013-09-19 17:48:59 +0200 | [diff] [blame] | 529 | root_freq = mxc_get_pll_pfd(PLL_BUS, 2); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 530 | |
| 531 | return root_freq / (usdhc_podf + 1); |
| 532 | } |
| 533 | |
| 534 | u32 imx_get_uartclk(void) |
| 535 | { |
| 536 | return get_uart_clk(); |
| 537 | } |
| 538 | |
Jason Liu | 92aa90b | 2011-12-16 05:17:06 +0000 | [diff] [blame] | 539 | u32 imx_get_fecclk(void) |
| 540 | { |
Markus Niebel | 6c109b8 | 2014-02-05 10:51:25 +0100 | [diff] [blame] | 541 | return mxc_get_clock(MXC_IPG_CLK); |
Jason Liu | 92aa90b | 2011-12-16 05:17:06 +0000 | [diff] [blame] | 542 | } |
| 543 | |
Marek Vasut | 563dfb2 | 2013-12-14 06:27:26 +0100 | [diff] [blame] | 544 | static int enable_enet_pll(uint32_t en) |
Eric Nelson | fdba076 | 2012-03-27 09:52:21 +0000 | [diff] [blame] | 545 | { |
Eric Nelson | fdba076 | 2012-03-27 09:52:21 +0000 | [diff] [blame] | 546 | struct mxc_ccm_reg *const imx_ccm |
| 547 | = (struct mxc_ccm_reg *) CCM_BASE_ADDR; |
Marek Vasut | 563dfb2 | 2013-12-14 06:27:26 +0100 | [diff] [blame] | 548 | s32 timeout = 100000; |
| 549 | u32 reg = 0; |
Eric Nelson | fdba076 | 2012-03-27 09:52:21 +0000 | [diff] [blame] | 550 | |
| 551 | /* Enable PLLs */ |
| 552 | reg = readl(&imx_ccm->analog_pll_enet); |
| 553 | reg &= ~BM_ANADIG_PLL_SYS_POWERDOWN; |
| 554 | writel(reg, &imx_ccm->analog_pll_enet); |
| 555 | reg |= BM_ANADIG_PLL_SYS_ENABLE; |
| 556 | while (timeout--) { |
| 557 | if (readl(&imx_ccm->analog_pll_enet) & BM_ANADIG_PLL_SYS_LOCK) |
| 558 | break; |
| 559 | } |
| 560 | if (timeout <= 0) |
| 561 | return -EIO; |
| 562 | reg &= ~BM_ANADIG_PLL_SYS_BYPASS; |
| 563 | writel(reg, &imx_ccm->analog_pll_enet); |
Marek Vasut | 563dfb2 | 2013-12-14 06:27:26 +0100 | [diff] [blame] | 564 | reg |= en; |
Eric Nelson | fdba076 | 2012-03-27 09:52:21 +0000 | [diff] [blame] | 565 | writel(reg, &imx_ccm->analog_pll_enet); |
Marek Vasut | 563dfb2 | 2013-12-14 06:27:26 +0100 | [diff] [blame] | 566 | return 0; |
| 567 | } |
| 568 | |
Fabio Estevam | 15af733 | 2014-06-24 17:41:00 -0300 | [diff] [blame] | 569 | #ifndef CONFIG_MX6SX |
Marek Vasut | 563dfb2 | 2013-12-14 06:27:26 +0100 | [diff] [blame] | 570 | static void ungate_sata_clock(void) |
| 571 | { |
| 572 | struct mxc_ccm_reg *const imx_ccm = |
| 573 | (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 574 | |
| 575 | /* Enable SATA clock. */ |
| 576 | setbits_le32(&imx_ccm->CCGR5, MXC_CCM_CCGR5_SATA_MASK); |
| 577 | } |
Fabio Estevam | 15af733 | 2014-06-24 17:41:00 -0300 | [diff] [blame] | 578 | #endif |
Marek Vasut | 563dfb2 | 2013-12-14 06:27:26 +0100 | [diff] [blame] | 579 | |
| 580 | static void ungate_pcie_clock(void) |
| 581 | { |
| 582 | struct mxc_ccm_reg *const imx_ccm = |
| 583 | (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 584 | |
| 585 | /* Enable PCIe clock. */ |
| 586 | setbits_le32(&imx_ccm->CCGR4, MXC_CCM_CCGR4_PCIE_MASK); |
| 587 | } |
| 588 | |
Fabio Estevam | 15af733 | 2014-06-24 17:41:00 -0300 | [diff] [blame] | 589 | #ifndef CONFIG_MX6SX |
Marek Vasut | 563dfb2 | 2013-12-14 06:27:26 +0100 | [diff] [blame] | 590 | int enable_sata_clock(void) |
| 591 | { |
| 592 | ungate_sata_clock(); |
| 593 | return enable_enet_pll(BM_ANADIG_PLL_ENET_ENABLE_SATA); |
| 594 | } |
Fabio Estevam | 15af733 | 2014-06-24 17:41:00 -0300 | [diff] [blame] | 595 | #endif |
Marek Vasut | 563dfb2 | 2013-12-14 06:27:26 +0100 | [diff] [blame] | 596 | |
| 597 | int enable_pcie_clock(void) |
| 598 | { |
| 599 | struct anatop_regs *anatop_regs = |
| 600 | (struct anatop_regs *)ANATOP_BASE_ADDR; |
| 601 | struct mxc_ccm_reg *ccm_regs = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 602 | |
| 603 | /* |
| 604 | * Here be dragons! |
| 605 | * |
| 606 | * The register ANATOP_MISC1 is not documented in the Freescale |
| 607 | * MX6RM. The register that is mapped in the ANATOP space and |
| 608 | * marked as ANATOP_MISC1 is actually documented in the PMU section |
| 609 | * of the datasheet as PMU_MISC1. |
| 610 | * |
| 611 | * Switch LVDS clock source to SATA (0xb), disable clock INPUT and |
| 612 | * enable clock OUTPUT. This is important for PCI express link that |
| 613 | * is clocked from the i.MX6. |
| 614 | */ |
| 615 | #define ANADIG_ANA_MISC1_LVDSCLK1_IBEN (1 << 12) |
| 616 | #define ANADIG_ANA_MISC1_LVDSCLK1_OBEN (1 << 10) |
| 617 | #define ANADIG_ANA_MISC1_LVDS1_CLK_SEL_MASK 0x0000001F |
| 618 | clrsetbits_le32(&anatop_regs->ana_misc1, |
| 619 | ANADIG_ANA_MISC1_LVDSCLK1_IBEN | |
| 620 | ANADIG_ANA_MISC1_LVDS1_CLK_SEL_MASK, |
| 621 | ANADIG_ANA_MISC1_LVDSCLK1_OBEN | 0xb); |
| 622 | |
| 623 | /* PCIe reference clock sourced from AXI. */ |
| 624 | clrbits_le32(&ccm_regs->cbcmr, MXC_CCM_CBCMR_PCIE_AXI_CLK_SEL); |
| 625 | |
| 626 | /* Party time! Ungate the clock to the PCIe. */ |
Fabio Estevam | 15af733 | 2014-06-24 17:41:00 -0300 | [diff] [blame] | 627 | #ifndef CONFIG_MX6SX |
Marek Vasut | 563dfb2 | 2013-12-14 06:27:26 +0100 | [diff] [blame] | 628 | ungate_sata_clock(); |
Fabio Estevam | 15af733 | 2014-06-24 17:41:00 -0300 | [diff] [blame] | 629 | #endif |
Marek Vasut | 563dfb2 | 2013-12-14 06:27:26 +0100 | [diff] [blame] | 630 | ungate_pcie_clock(); |
Eric Nelson | fdba076 | 2012-03-27 09:52:21 +0000 | [diff] [blame] | 631 | |
Marek Vasut | 563dfb2 | 2013-12-14 06:27:26 +0100 | [diff] [blame] | 632 | return enable_enet_pll(BM_ANADIG_PLL_ENET_ENABLE_SATA | |
| 633 | BM_ANADIG_PLL_ENET_ENABLE_PCIE); |
Eric Nelson | fdba076 | 2012-03-27 09:52:21 +0000 | [diff] [blame] | 634 | } |
| 635 | |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 636 | unsigned int mxc_get_clock(enum mxc_clock clk) |
| 637 | { |
| 638 | switch (clk) { |
| 639 | case MXC_ARM_CLK: |
| 640 | return get_mcu_main_clk(); |
| 641 | case MXC_PER_CLK: |
| 642 | return get_periph_clk(); |
| 643 | case MXC_AHB_CLK: |
| 644 | return get_ahb_clk(); |
| 645 | case MXC_IPG_CLK: |
| 646 | return get_ipg_clk(); |
| 647 | case MXC_IPG_PERCLK: |
Matthias Weisser | 99ba342 | 2012-09-24 02:46:53 +0000 | [diff] [blame] | 648 | case MXC_I2C_CLK: |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 649 | return get_ipg_per_clk(); |
| 650 | case MXC_UART_CLK: |
| 651 | return get_uart_clk(); |
| 652 | case MXC_CSPI_CLK: |
| 653 | return get_cspi_clk(); |
| 654 | case MXC_AXI_CLK: |
| 655 | return get_axi_clk(); |
| 656 | case MXC_EMI_SLOW_CLK: |
| 657 | return get_emi_slow_clk(); |
| 658 | case MXC_DDR_CLK: |
| 659 | return get_mmdc_ch0_clk(); |
| 660 | case MXC_ESDHC_CLK: |
| 661 | return get_usdhc_clk(0); |
| 662 | case MXC_ESDHC2_CLK: |
| 663 | return get_usdhc_clk(1); |
| 664 | case MXC_ESDHC3_CLK: |
| 665 | return get_usdhc_clk(2); |
| 666 | case MXC_ESDHC4_CLK: |
| 667 | return get_usdhc_clk(3); |
| 668 | case MXC_SATA_CLK: |
| 669 | return get_ahb_clk(); |
| 670 | default: |
| 671 | break; |
| 672 | } |
| 673 | |
| 674 | return -1; |
| 675 | } |
| 676 | |
| 677 | /* |
| 678 | * Dump some core clockes. |
| 679 | */ |
| 680 | int do_mx6_showclocks(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 681 | { |
| 682 | u32 freq; |
Benoît Thébaudeau | afac165 | 2012-09-27 10:19:58 +0000 | [diff] [blame] | 683 | freq = decode_pll(PLL_SYS, MXC_HCLK); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 684 | printf("PLL_SYS %8d MHz\n", freq / 1000000); |
Benoît Thébaudeau | afac165 | 2012-09-27 10:19:58 +0000 | [diff] [blame] | 685 | freq = decode_pll(PLL_BUS, MXC_HCLK); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 686 | printf("PLL_BUS %8d MHz\n", freq / 1000000); |
Benoît Thébaudeau | afac165 | 2012-09-27 10:19:58 +0000 | [diff] [blame] | 687 | freq = decode_pll(PLL_USBOTG, MXC_HCLK); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 688 | printf("PLL_OTG %8d MHz\n", freq / 1000000); |
Benoît Thébaudeau | afac165 | 2012-09-27 10:19:58 +0000 | [diff] [blame] | 689 | freq = decode_pll(PLL_ENET, MXC_HCLK); |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 690 | printf("PLL_NET %8d MHz\n", freq / 1000000); |
| 691 | |
| 692 | printf("\n"); |
| 693 | printf("IPG %8d kHz\n", mxc_get_clock(MXC_IPG_CLK) / 1000); |
| 694 | printf("UART %8d kHz\n", mxc_get_clock(MXC_UART_CLK) / 1000); |
Fabio Estevam | f6fde41 | 2012-11-16 01:30:10 +0000 | [diff] [blame] | 695 | #ifdef CONFIG_MXC_SPI |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 696 | printf("CSPI %8d kHz\n", mxc_get_clock(MXC_CSPI_CLK) / 1000); |
Fabio Estevam | f6fde41 | 2012-11-16 01:30:10 +0000 | [diff] [blame] | 697 | #endif |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 698 | printf("AHB %8d kHz\n", mxc_get_clock(MXC_AHB_CLK) / 1000); |
| 699 | printf("AXI %8d kHz\n", mxc_get_clock(MXC_AXI_CLK) / 1000); |
| 700 | printf("DDR %8d kHz\n", mxc_get_clock(MXC_DDR_CLK) / 1000); |
| 701 | printf("USDHC1 %8d kHz\n", mxc_get_clock(MXC_ESDHC_CLK) / 1000); |
| 702 | printf("USDHC2 %8d kHz\n", mxc_get_clock(MXC_ESDHC2_CLK) / 1000); |
| 703 | printf("USDHC3 %8d kHz\n", mxc_get_clock(MXC_ESDHC3_CLK) / 1000); |
| 704 | printf("USDHC4 %8d kHz\n", mxc_get_clock(MXC_ESDHC4_CLK) / 1000); |
| 705 | printf("EMI SLOW %8d kHz\n", mxc_get_clock(MXC_EMI_SLOW_CLK) / 1000); |
| 706 | printf("IPG PERCLK %8d kHz\n", mxc_get_clock(MXC_IPG_PERCLK) / 1000); |
| 707 | |
| 708 | return 0; |
| 709 | } |
| 710 | |
Fabio Estevam | 15af733 | 2014-06-24 17:41:00 -0300 | [diff] [blame] | 711 | #ifndef CONFIG_MX6SX |
Pardeep Kumar Singla | c1fa130 | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 712 | void enable_ipu_clock(void) |
| 713 | { |
| 714 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 715 | int reg; |
| 716 | reg = readl(&mxc_ccm->CCGR3); |
Pierre Aubert | 2cb5c38 | 2013-09-23 13:37:20 +0200 | [diff] [blame] | 717 | reg |= MXC_CCM_CCGR3_IPU1_IPU_MASK; |
Pardeep Kumar Singla | c1fa130 | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 718 | writel(reg, &mxc_ccm->CCGR3); |
| 719 | } |
Fabio Estevam | 15af733 | 2014-06-24 17:41:00 -0300 | [diff] [blame] | 720 | #endif |
Jason Liu | dec1112 | 2011-11-25 00:18:02 +0000 | [diff] [blame] | 721 | /***************************************************/ |
| 722 | |
| 723 | U_BOOT_CMD( |
| 724 | clocks, CONFIG_SYS_MAXARGS, 1, do_mx6_showclocks, |
| 725 | "display clocks", |
| 726 | "" |
| 727 | ); |