开发环境:win10 64位 + VMware12 + Ubuntu14.04 32位

工具链:linaro提供的gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi

要移植的u-boot版本:u-boot-2016-11

Tiny4412开发板硬件版本为

  底板:  Tiny4412SDK 1312B

  核心板:Tiny4412 - 1306

 

1、时钟体系

exynos4412芯片时钟体系的介绍在《Exynos 4412 SCP_Users Manual_Ver.0.10.00_Preliminary.pdf》的第七章节。

据P447介绍:其有三个时钟源:

  1. XRTCXTI:32.768KZH,用于RTC时钟的实时时钟源。有XRTCXTI、XRTCXTO两个引脚,且之间需要10mΩ的并联电阻
  2. XXTI:12MHZ--50MZH,APLL、MPLL、VPLL和EPLL可使用此时钟作为适当模块的电源。可以仅用于测试,不用时接地
  3. XUSBXTI:24MZH。因为IROM设计基于24兆赫输入时钟。有XUSBXTI、XUSBXTO两个引脚,且之间需要5mΩ的并联电阻

在友善之臂tiny4412的开发板中, XRTCXTI 上没有外接晶振,系统时钟来源是XUSBXTI引脚上接的24MH 晶振,如下图所示:

2、启动方式

 由P455页可看出XOM[0]接在FINPLL上,在结合第五章节内容

OM[5:1] 启动设备
5b’00010 SDMMC_CH2
5b’00100 eMMC44_CH4

可看出OM[0]=1;OM[1]=0;OM[4]=0;OM[5]=0;

OM[2]=1,OM[3]=0时,为SD卡启动;

OM[2]=0,OM[3]=1时,为eMMC启动;

而正是由于OM[1]=1;表明芯片选择XUSBXTI为时钟源

3、时钟代码

  1. diff --git a/arch/arm/mach-exynos/Makefile b/arch/arm/mach-exynos/Makefile
  2. index 5f8b6ba..
  3. --- a/arch/arm/mach-exynos/Makefile
  4. +++ b/arch/arm/mach-exynos/Makefile
  5. @@ -, +, @@ ifdef CONFIG_SPL_BUILD
  6. obj-$(CONFIG_EXYNOS5) += clock_init_exynos5.o
  7. obj-$(CONFIG_EXYNOS5) += dmc_common.o dmc_init_ddr3.o
  8. obj-$(CONFIG_EXYNOS4210)+= dmc_init_exynos4.o clock_init_exynos4.o
  9. -obj-$(CONFIG_EXYNOS4412)+= dmc_init_exynos4.o clock_init_exynos4.o
  10. +obj-$(CONFIG_EXYNOS4412)+= dmc_init_exynos4412.o clock_init_exynos4412.o
  11.  
  12. obj-y += spl_boot.o tzpc.o
  13. obj-y += lowlevel_init.o

在mach-exynos下,新建clock_init_exynos4412.c和exynos4412_setup.h

  1. clock
    /*
  2. * Clock Initialization for board based on EXYNOS4412
  3. *
  4. * 2016
  5. * Modified by AP0904225 <ap0904225@qq.com>
  6. *
  7. * Copyright (C) 2013 Samsung Electronics
  8. * Rajeshwari Shinde <rajeshwari.s@samsung.com>
  9. *
  10. * See file CREDITS for list of people who contributed to this
  11. * project.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation; either version 2 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  26. * MA 02111-1307 USA
  27. */
  28.  
  29. #include <common.h>
  30. #include <config.h>
  31. #include <asm/io.h>
  32. #include <asm/arch/cpu.h>
  33. #include <asm/arch/clk.h>
  34. #include <asm/arch/clock.h>
  35. #include "common_setup.h"
  36.  
  37. #include "exynos4412_setup.h"
  38.  
  39. /*
  40. * system_clock_init: Initialize core clock and bus clock.
  41. * void system_clock_init(void)
  42. */
  43. void system_clock_init(void)
  44. {
  45. unsigned int set, clr, clr_src_cpu, clr_pll_con0, clr_src_dmc;
  46. struct exynos4x12_clock *clk =(struct exynos4x12_clock *)
  47. samsung_get_base_clock();
  48.  
  49. /*
  50. * APLL= 1400 MHz
  51. * MPLL=800 MHz
  52. * EPLL=96 MHz
  53. * VPLL=108 MHz
  54. * freq (ARMCLK) = 1400 MHz at 1.3 V
  55. * freq (ACLK_COREM0) = 350 MHz at 1.3V
  56. * freq (ACLK_COREM1) = 188 MHz at 1.3 V
  57. * freq (PERIPHCLK) = 1400 MHz at 1.3 V
  58. * freq (ATCLK) = 214 MHz at 1.3 V
  59. * freq (PCLK_DBG) = 107 MHz at 1.3 V
  60. * freq (SCLK_DMC) = 400 MHz at 1.0 V
  61. * freq (ACLK_DMCD) = 200 MHz at 1.0 V
  62. * freq (ACLK_DMCP) = 100 MHz at 1.0 V
  63. * freq (ACLK_ACP) = 200 MHz at 1.0 V
  64. * freq (PCLK_ACP) = 100 MHz at 1.0 V
  65. * freq (SCLK_C2C) = 400 MHz at 1.0 V
  66. * freq (ACLK_C2C) = 200 MHz at 1.0 V
  67. * freq (ACLK_GDL) = 200 MHz at 1.0 V
  68. * freq (ACLK_GPL) = 100 MHz at 1.0 V
  69. * freq (ACLK_GDR) = 200 MHz at 1.0 V
  70. * freq (ACLK_GPR) = 100 MHz at 1.0 V
  71. * freq (ACLK_400_MCUISP) = 400 MHz at 1.0 V
  72. * freq (ACLK_200) = 160 MHz at 1.0 V
  73. * freq (ACLK_100) = 100 MHz at 1.0 V
  74. * freq (ACLK_160) = 160 MHz at 1.0 V
  75. * freq (ACLK_133) = 133 MHz at 1.0 V
  76. * freq (SCLK_ONENAND) = 160 MHz at 1.0 V
  77. */
  78.  
  79. /*
  80. *before set system clocks,we switch system clocks src to FINpll
  81. */
  82.  
  83. /*
  84. * Bit values: 0 ; 1
  85. * MUX_APLL_SEL: FIN_PLL ; FOUT_APLL
  86. * MUX_CORE_SEL: MOUT_APLL ; SCLK_MPLL
  87. * MUX_HPM_SEL: MOUT_APLL ; SCLK_MPLL_USER_C
  88. * MUX_MPLL_USER_SEL_C: FIN_PLL ; SCLK_MPLL
  89. */
  90. clr_src_cpu = MUX_APLL_SEL() | MUX_CORE_SEL() |
  91. MUX_HPM_SEL() | MUX_MPLL_USER_SEL_C();
  92. set = MUX_APLL_SEL() | MUX_CORE_SEL() | MUX_HPM_SEL() |
  93. MUX_MPLL_USER_SEL_C();
  94. clrsetbits_le32(&clk->src_cpu, clr_src_cpu, set);
  95. /* Wait for mux change */
  96. while (readl(&clk->mux_stat_cpu) & MUX_STAT_CPU_CHANGING)
  97. continue;
  98.  
  99. /*
  100. ******************************************************
  101. * Step 1: Set Clock divider
  102. ******************************************************
  103. */
  104.  
  105. /*=====================set APLL related dividers(CMU_CPU)==============================*/
  106. /*
  107. * Set dividers for MOUTcore
  108. * MOUTcore = MOUTapll = 1400 MHz
  109. * SCLKapll = MOUTapll / (APLL_RATIO 1) = 700 MHz (DIVapll:APLL_RATIO=1)
  110. * ARMCLK = MOUTcore / (ratio 1) = 1400 MHz (DIVcore:CORE_RATIO=0;DIVcore2:CORE2_RATIO=0)
  111. * ACLK_COREM0 = ARMCLK / (COREM0_RATIO 1) = 355 MHz (DIVcorem0:COREM0_RATIO=3)
  112. * ACLK_COREM1 = ARMCLK / (COREM1_RATIO 1) = 188 MHz (DIVcorem1:COREM1_RATIO=7)
  113. * PERIPHCLK = ARMCLK / (PERIPH_RATIO 1) = 1400 MHz (DIVperiph:PERIPH_RATIO=0)
  114. * OUTatb = MOUTcore / (ATB_RATIO 1) = 200 MHz (DIVatb:ATB_RATIO=6)
  115. * ATCLK = OUTatb = 200 MHz
  116. * PCLK_DBG = OUTatb / (PCLK_DBG_RATIO 1) = 100 MHz (PCLK_DBG_RATIO=1)
  117. */
  118. clr = APLL_RATIO() |CORE_RATIO()| CORE2_RATIO()|
  119. COREM0_RATIO() | COREM1_RATIO() |
  120. PERIPH_RATIO() | ATB_RATIO() | PCLK_DBG_RATIO() ;
  121. set = APLL_RATIO() |CORE_RATIO() | CORE2_RATIO() |
  122. COREM0_RATIO() | COREM1_RATIO()|
  123. PERIPH_RATIO() | ATB_RATIO() | PCLK_DBG_RATIO() ;
  124. clrsetbits_le32(&clk->div_cpu0, clr, set);
  125.  
  126. /* Wait for divider ready status */
  127. while (readl(&clk->div_stat_cpu0) & DIV_STAT_CPU0_CHANGING)
  128. continue;
  129.  
  130. /* Set dividers for MOUThpm
  131. * MOUThpm = MOUTapll = 1400 MHz
  132. * OUTcopy = MOUThpm / (COPY_RATIO 1) = 200 (DIVcopy:COPY_RATIO=6)
  133. * sclkhpm = OUTcopy / (HPM_RATIO 1) = 200 (DIVhpm:HPM_RATIO=0)
  134. * ACLK_CORES = ARMCLK / (CORES_RATIO 1) = 233 (DIVcores:CORES_RATIO=5)
  135. */
  136. clr = COPY_RATIO() | HPM_RATIO() | CORES_RATIO();
  137. set = COPY_RATIO() | HPM_RATIO() | CORES_RATIO();
  138. clrsetbits_le32(&clk->div_cpu1, clr, set);
  139.  
  140. /* Wait for divider ready status */
  141. while (readl(&clk->div_stat_cpu1) & DIV_STAT_CPU1_CHANGING)
  142. continue;
  143.  
  144. /*=====================set MPLL related dividers(CMU_DMC)==============================*/
  145.  
  146. /*
  147. * Set CLK_DIV_DMC0
  148. * MOUTmpll = SCLKmpll = 800 MHz
  149. * MOUTdmc_bus = SCLKmpll = 800 MHz
  150. * MOUTdphy = SCLKmpll = 800 MHz
  151. *
  152. * SCLK_DMC = MOUTdmc_bus / (DMC_RATIO 1) = 400MHz (DIVdmc:DMC_RATIO=1)
  153. * ACLK_DMCD = SCLK_DMC / (DMCD_RATIO 1) = 200MHz (DIVdmcd:DMCD_RATIO=1)
  154. * ACLK_DMCP = ACLK_DMCD / (DMCP_RATIO 1) = 100MHz (DIVdmcp:DMCP_RATIO=1)
  155. * ACLK_ACP = MOUTdmc_bus / (ACP_RATIO 1) = 200MHz (DIVacp:ACP_RATIO=3)
  156. * PCLK_ACP = ACLK_ACP / (ACP_PCLK_RATIO 1) = 100MHz (DIVacp_pclk:ACP_PCLK_RATIO=1)
  157. * SCLK_DPHY = MOUTdphy / (DPHY_RATIO 1) = 400MHz (DIVdphy:DPHY_RATIO=1)
  158. */
  159. clr = DMC_RATIO() | DMCD_RATIO() | DMCP_RATIO() |
  160. ACP_RATIO() | ACP_PCLK_RATIO() | DPHY_RATIO();
  161. set = DMC_RATIO() | DMCD_RATIO() | DMCP_RATIO() |
  162. ACP_RATIO() | ACP_PCLK_RATIO() | DPHY_RATIO();
  163. clrsetbits_le32(&clk->div_dmc0, clr, set);
  164.  
  165. /* Wait for divider ready status */
  166. while (readl(&clk->div_stat_dmc0) & DIV_STAT_DMC0_CHANGING)
  167. continue;
  168.  
  169. /*
  170. * Set CLK_DIV_DMC1
  171. * MOUTmpll = SCLKmpll = 800 MHz
  172. * MOUTc2c = SCLKmpll = 800 Mhz
  173. * MOUTpwi = SCLKmpll = 800 MHz
  174. * MOUTg2d_acp = SCLKmpll = 800 MHz
  175. *
  176. * SCLK_C2C = MOUTc2c / (C2C_RATIO 1) = 400MHz (DIVc2c:C2C_RATIO=1)
  177. * ACLK_C2C = SCLK_C2C / (C2C_ACLK_RATIO 1) = 200MHz (DIVc2c_aclk:C2C_ACLK_RATIO=1)
  178. * SCLK_PWI = MOUTpwi / (PWI_RATIO 1) = 100MHz (DIVpwi:PWI_RATIO=7)
  179. * SCLK_G2D_ACP = MOUTg2d_acp / (G2D_ACP_RATIO 1) = 200MHz (G2D_ACP_RATIO=3)
  180. * IECDPMCLKEN = ACLK_DMCP/( DPM_RATIO 1) = 50MHz(DIVdpm:DPM_RATIO=1)
  181. * IECDVSEMCLKEN = ACLK_DMCP/( DVSEM_RATIO 1) = 50MHz(DIVdvsem:DVSEM_RATIO=1)
  182. */
  183. clr = C2C_RATIO() | C2C_ACLK_RATIO() | PWI_RATIO() |
  184. G2D_ACP_RATIO() | DVSEM_RATIO() | DPM_RATIO();
  185. set = C2C_RATIO() | C2C_ACLK_RATIO() | PWI_RATIO() |
  186. G2D_ACP_RATIO() | DVSEM_RATIO() | DPM_RATIO();
  187. clrsetbits_le32(&clk->div_dmc1, clr, set);
  188.  
  189. /* Wait for divider ready status */
  190. while (readl(&clk->div_stat_dmc1) & DIV_STAT_DMC1_CHANGING)
  191. continue;
  192.  
  193. /*=====================set CMU_TOP related dividers==============================*/
  194. /*
  195. * Set CLK_DIV_TOP
  196. * SCLKmll_user_t = SCLKmpll = 800 MHz
  197. * MOUTACLK_400_MC = SCLKmpll = 800 MHz
  198. * MOUTACLK_400_MCUISP = MOUTACLK_400_MC/(ACLK_400_MCUISP_RATIO 1) = 400MHz (DIVaclk_400_mc:ACLK_400_MCUISP_RATIO=1)
  199. * MOUTACLK_200 = SCLKmpll = 800 MHz
  200. * ACLK_200 = MOUTACLK_200/(ACLK_200_RATIO 1) = 160MHz (DIVaclk_200:ACLK_200_RATIO=4)
  201. * MOUTACLK_266_gps = SCLKmpll = 800 MHz
  202. * ACLK_266_GPS = [MOUTACLK_266_GPS /(ACLK_266_GPS_RATIO 1)] = 266MHz (DIVaclk_266_gps:ACLK_266_GPS_RATIO=2)
  203. * MOUTACLK_100 = SCLKmpll = 800 MHz
  204. * ACLK_100 = [MOUTACLK_100/(ACLK_100_RATIO 1)] = 100MHz (DIVaclk_100:ACLK_100_RATIO=7)
  205. * MOUTACLK_160 = SCLKmpll = 800 MHz
  206. * ACLK_160 = [MOUTACLK_160 /(ACLK_160_RATIO 1)] = 160MHz (DIVaclk_160:ACLK_160_RATIO=4)
  207. * MOUTACLK_133 = SCLKmpll = 800 MHz
  208. * ACLK_133 = [MOUTACLK_133 /(ACLK_133_RATIO 1)] = 133MHz (DIVaclk_133:ACLK_133_RATIO=5)
  209. * MOUTonenand = MOUTonenand_1 = ACLK_133MHz
  210. * SCLK_ONENAND = [MOUTONENAND_1 /(ONENAND_RATIO 1)] = 66MHz (DIVonenand:ONENAND_RATIO=1)
  211. */
  212. clr = ACLK_400_MCUISP_RATIO() | ACLK_200_RATIO() | ACLK_266_GPS_RATIO() |
  213. ACLK_100_RATIO() | ACLK_160_RATIO() | ACLK_133_RATIO() |ONENAND_RATIO();
  214. set = ACLK_400_MCUISP_RATIO() | ACLK_200_RATIO() | ACLK_266_GPS_RATIO() |
  215. ACLK_100_RATIO() | ACLK_160_RATIO() | ACLK_133_RATIO() |ONENAND_RATIO();
  216. clrsetbits_le32(&clk->div_top, clr, set);
  217.  
  218. /* Wait for divider ready status */
  219. while (readl(&clk->div_stat_top) & DIV_STAT_TOP_CHANGING)
  220. continue;
  221.  
  222. /*=====================set CMU_LEFTBUS related dividers==============================*/
  223. /*
  224. * Set CLK_DIV_LEFTBUS
  225. * MOUTgdl = SCLKmpll = 800 MHz
  226. * ACLK_GDL = MOUTgdl/(GDL_RATIO 1) = 200MHz (DIVgdl:GDL_RATIO=3)
  227. * ACLK_GPL = ACLK_GDL/(GPL_RATIO 1) = 100MHz (DIVgpl:GPL_RATIO=1)
  228. */
  229. clr = GDL_RATIO() | GPL_RATIO() ;
  230. set = GDL_RATIO() | GPL_RATIO() ;
  231. clrsetbits_le32(&clk->div_leftbus, clr, set);
  232.  
  233. /* Wait for divider ready status */
  234. while (readl(&clk->div_stat_leftbus) & DIV_STAT_LEFTBUS_CHANGING)
  235. continue;
  236.  
  237. /*=====================set CMU_RIGHTBUS related dividers==============================*/
  238. /*
  239. * Set CLK_DIV_RIGHTBUS
  240. * MOUTgdr = SCLKmpll = 800 MHz
  241. * ACLK_GDR = MOUTgdr/(GDR_RATIO 1) = 200MHz (DIVgdl:GDR_RATIO=3)
  242. * ACLK_GPL = ACLK_GDL/(GPR_RATIO 1) = 100MHz (DIVgpl:GPR_RATIO=1)
  243. */
  244. clr = GDR_RATIO() | GPR_RATIO() ;
  245. set = GDR_RATIO() | GPR_RATIO() ;
  246. clrsetbits_le32(&clk->div_rightbus, clr, set);
  247.  
  248. /* Wait for divider ready status */
  249. while (readl(&clk->div_stat_rightbus) & DIV_STAT_LEFTBUS_CHANGING)
  250. continue;
  251.  
  252. /*=====================set other dividers==============================*/
  253.  
  254. /* CLK_DIV_PERIL0 (UART0-4 dividers ) */
  255. /*
  256. * MOUTuart0-4 = SCLKMPLL_USER_T =800MHz
  257. *
  258. * SCLK_UARTx = MOUTuartX / (UARTx_RATIO 1) = 100MHz (DIVuart0-4:UARTx_RATIO=7)
  259. */
  260. clr = UART0_RATIO() | UART1_RATIO() | UART2_RATIO() |
  261. UART3_RATIO() | UART4_RATIO();
  262. set = UART0_RATIO() | UART1_RATIO() | UART2_RATIO() |
  263. UART3_RATIO() | UART4_RATIO();
  264. clrsetbits_le32(&clk->div_peril0, clr, set);
  265.  
  266. while (readl(&clk->div_stat_peril0) & DIV_STAT_PERIL0_CHANGING)
  267. continue;
  268.  
  269. /* CLK_DIV_FSYS1 */
  270. clr = MMC0_RATIO() | MMC0_PRE_RATIO() | MMC1_RATIO() |
  271. MMC1_PRE_RATIO();
  272. /*
  273. * For MOUTmmc0-3 = 800 MHz (MPLL)
  274. *
  275. * DOUTmmc1 = MOUTmmc1 / (ratio 1) = 100 (7)
  276. * sclk_mmc1 = DOUTmmc1 / (ratio 1) = 50 (1)
  277. * DOUTmmc0 = MOUTmmc0 / (ratio 1) = 100 (7)
  278. * sclk_mmc0 = DOUTmmc0 / (ratio 1) = 50 (1)
  279. */
  280. set = MMC0_RATIO() | MMC0_PRE_RATIO() | MMC1_RATIO() |
  281. MMC1_PRE_RATIO();
  282.  
  283. clrsetbits_le32(&clk->div_fsys1, clr, set);
  284.  
  285. /* Wait for divider ready status */
  286. while (readl(&clk->div_stat_fsys1) & DIV_STAT_FSYS1_CHANGING)
  287. continue;
  288.  
  289. /* CLK_DIV_FSYS2 */
  290. clr = MMC2_RATIO() | MMC2_PRE_RATIO() | MMC3_RATIO() |
  291. MMC3_PRE_RATIO();
  292. /*
  293. * For MOUTmmc0-3 = 800 MHz (MPLL)
  294. *
  295. * DOUTmmc3 = MOUTmmc3 / (ratio 1) = 100 (7)
  296. * sclk_mmc3 = DOUTmmc3 / (ratio 1) = 50 (1)
  297. * DOUTmmc2 = MOUTmmc2 / (ratio 1) = 100 (7)
  298. * sclk_mmc2 = DOUTmmc2 / (ratio 1) = 50 (1)
  299. */
  300. set = MMC2_RATIO() | MMC2_PRE_RATIO() | MMC3_RATIO() |
  301. MMC3_PRE_RATIO();
  302.  
  303. clrsetbits_le32(&clk->div_fsys2, clr, set);
  304.  
  305. /* Wait for divider ready status */
  306. while (readl(&clk->div_stat_fsys2) & DIV_STAT_FSYS2_CHANGING)
  307. continue;
  308.  
  309. /* CLK_DIV_FSYS3 */
  310. clr = MMC4_RATIO() | MMC4_PRE_RATIO();
  311. /*
  312. * For MOUTmmc4 = 800 MHz (MPLL)
  313. *
  314. * DOUTmmc4 = MOUTmmc4 / (ratio 1) = 100 (7)
  315. * sclk_mmc4 = DOUTmmc4 / (ratio 1) = 100 (0)
  316. */
  317. set = MMC4_RATIO() | MMC4_PRE_RATIO();
  318.  
  319. clrsetbits_le32(&clk->div_fsys3, clr, set);
  320.  
  321. /* Wait for divider ready status */
  322. while (readl(&clk->div_stat_fsys3) & DIV_STAT_FSYS3_CHANGING)
  323. continue;
  324.  
  325. /*
  326. * Step 2: Set APLL, MPLL, EPLL, VPLL locktime
  327. */
  328. clr = PLL_LOCKTIME();
  329.  
  330. /*====== APLL locktime [APLL = 1400MHz : SDIV(0) , PDIV(3) , MDIV(175)] =====*/
  331. set = PLL_LOCKTIME( PDIV() * );
  332. clrsetbits_le32(&clk->apll_lock, clr, set);
  333.  
  334. /*====== MPLL locktime [MPLL = 800MHz : SDIV(0) , PDIV(3) , MDIV(100)] =====*/
  335. set = PLL_LOCKTIME( PDIV() * );
  336. clrsetbits_le32(&clk->mpll_lock, clr, set);
  337.  
  338. /*====== EPLL locktime [EPLL = 96MHz : SDIV(3) , PDIV(2) , MDIV(64)] =====*/
  339. set = PLL_LOCKTIME( PDIV() * );
  340. clrsetbits_le32(&clk->epll_lock, clr, set);
  341.  
  342. /*====== VPLL locktime [VPLL = 108MHz : SDIV(3) , PDIV(2) , MDIV(72)] =====*/
  343. set = PLL_LOCKTIME( PDIV() * );
  344. clrsetbits_le32(&clk->vpll_lock, clr, set);
  345.  
  346. /*
  347. * Step 3: Set PLL PMS values and enable PLL
  348. * 1.Set PDIV, MDIV, and SDIV values for APLL, MPLL, EPLL, VPLL
  349. * 2.Turn on APLL, MPLL, EPLL, VPLL
  350. */
  351.  
  352. /**************** Set APLL to 1400MHz ****************/
  353. /*APLL_CON1*/
  354. clr = AFC() | LOCK_CON_DLY() | LOCK_CON_IN() |
  355. LOCK_CON_OUT() |FEED_EN()| AFC_ENB() |
  356. DCC_ENB() | BYPASS() |RESV0() | RESV1();
  357. set = AFC() | LOCK_CON_DLY() | LOCK_CON_IN() |
  358. LOCK_CON_OUT() |FEED_EN()| AFC_ENB() |
  359. DCC_ENB() | BYPASS() |RESV0() | RESV1();
  360. clrsetbits_le32(&clk->apll_con1, clr, set);
  361.  
  362. /*APLL_CON0*/
  363. clr_pll_con0 = SDIV() | PDIV() | MDIV() | FSEL();
  364. set = SDIV() | PDIV() | MDIV() | FSEL() | PLL_ENABLE();
  365. clrsetbits_le32(&clk->apll_con0, clr_pll_con0, set);
  366.  
  367. /* Wait for PLL to be locked */
  368. while (!(readl(&clk->apll_con0) & PLL_LOCKED_BIT))
  369. continue;
  370.  
  371. /**************** Set MPLL to 800MHz ****************/
  372. /*MPLL_CON1*/
  373. clr = AFC() | LOCK_CON_DLY() | LOCK_CON_IN() |
  374. LOCK_CON_OUT() |FEED_EN()| AFC_ENB() |
  375. DCC_ENB() | BYPASS() |RESV0() | RESV1();
  376. set = AFC() | LOCK_CON_DLY() | LOCK_CON_IN() |
  377. LOCK_CON_OUT() |FEED_EN()| AFC_ENB() |
  378. DCC_ENB() | BYPASS() |RESV0() | RESV1();
  379. clrsetbits_le32(&clk->mpll_con1, clr, set);
  380.  
  381. /*MPLL_CON0*/
  382. set = SDIV() | PDIV() | MDIV() | FSEL() | PLL_ENABLE();
  383. clrsetbits_le32(&clk->mpll_con0, clr_pll_con0, set);
  384.  
  385. /* Wait for PLL to be locked */
  386. while (!(readl(&clk->mpll_con0) & PLL_LOCKED_BIT))
  387. continue;
  388.  
  389. /**************** Set EPLL to 96MHz ****************/
  390. /*EPLL_CON2*/
  391. clr = BYPASS_E_V() | SSCG_EN() |
  392. AFC_ENB_E_V() |DCC_ENB_E_V() ;
  393. set = BYPASS_E_V() | SSCG_EN() |
  394. AFC_ENB_E_V() |DCC_ENB_E_V() ;
  395. clrsetbits_le32(&clk->epll_con2, clr, set);
  396.  
  397. /*EPLL_CON1*/
  398. clr = K() | MFR() | MRR() | SEL_PF();
  399. set = K() | MFR() | MRR() | SEL_PF();
  400. clrsetbits_le32(&clk->epll_con1, clr, set);
  401.  
  402. /*EPLL_CON0*/
  403. set = SDIV() | PDIV() | MDIV() | PLL_ENABLE();
  404. clrsetbits_le32(&clk->epll_con0, clr_pll_con0, set);
  405.  
  406. /* Wait for PLL to be locked */
  407. while (!(readl(&clk->epll_con0) & PLL_LOCKED_BIT))
  408. continue;
  409.  
  410. /**************** Set VPLL to 108MHz ****************/
  411. /*VPLL_CON2*/
  412. clr = BYPASS_E_V() | SSCG_EN() |
  413. AFC_ENB_E_V() |DCC_ENB_E_V() ;
  414. set = BYPASS_E_V() | SSCG_EN() |
  415. AFC_ENB_E_V() |DCC_ENB_E_V() ;
  416. clrsetbits_le32(&clk->vpll_con2, clr, set);
  417.  
  418. /*VPLL_CON1*/
  419. clr = K() | MFR() | MRR() | SEL_PF();
  420. set = K() | MFR() | MRR() | SEL_PF();
  421. clrsetbits_le32(&clk->vpll_con1, clr, set);
  422.  
  423. /*VPLL_CON0*/
  424. set = SDIV() | PDIV() | MDIV() | PLL_ENABLE();
  425. clrsetbits_le32(&clk->vpll_con0, clr_pll_con0, set);
  426.  
  427. /* Wait for PLL to be locked */
  428. while (!(readl(&clk->vpll_con0) & PLL_LOCKED_BIT))
  429. continue;
  430.  
  431. /*
  432. * Step 4: Select the PLL(APLL, MPLL, EPLL, VPLL ...) output clock
  433. */
  434.  
  435. /*************** Set CMU_UART0-4 clocks src MUX ***************/
  436.  
  437. /* CLK_SRC_PERIL0 */
  438. clr = UART0_SEL() | UART1_SEL() | UART2_SEL() |
  439. UART3_SEL() | UART4_SEL();
  440. /*
  441. * Set CLK_SRC_PERIL0 clocks src to MPLL
  442. * src values: 0(XXTI); 1(XusbXTI); 2(SCLK_HDMI24M); 3(SCLK_USBPHY0);
  443. * 5(SCLK_HDMIPHY); 6(SCLK_MPLL_USER_T); 7(SCLK_EPLL);
  444. * 8(SCLK_VPLL)
  445. *
  446. * Set all to SCLK_MPLL_USER_T
  447. */
  448. set = UART0_SEL() | UART1_SEL() | UART2_SEL() | UART3_SEL() |
  449. UART4_SEL();
  450.  
  451. clrsetbits_le32(&clk->src_peril0, clr, set);
  452.  
  453. /*************** Set CMU_LEFTBUS clocks src MUX ***************/
  454. /* CLK_SRC_LEFTBUS */
  455. clr = MUX_GDL_SEL() | MUX_MPLL_USER_SEL_L();
  456. set = MUX_GDL_SEL() | MUX_MPLL_USER_SEL_L();
  457. clrsetbits_le32(&clk->src_leftbus, clr, set);
  458.  
  459. /* Wait for mux change */
  460. sdelay(0x30000);
  461.  
  462. /*************** Set CMU_RIGHTBUS clocks src MUX ***************/
  463. /* CLK_SRC_RIGHTBUS */
  464. clr = MUX_MPLL_USER_SEL_R() | MUX_GDR_SEL();
  465. set = MUX_MPLL_USER_SEL_R() | MUX_GDR_SEL();
  466. clrsetbits_le32(&clk->src_rightbus, clr, set);
  467.  
  468. /* Wait for mux change */
  469. sdelay(0x30000);
  470.  
  471. /*************** Set CMU_TOP clocks src MUX ***************/
  472. /* CLK_SRC_TOP0 */
  473. clr = MUX_EPLL_SEL() | MUX_VPLL_SEL() | MUX_ACLK_200_SEL() |
  474. MUX_ACLK_100_SEL() | MUX_ACLK_160_SEL() |
  475. MUX_ACLK_133_SEL() | MUX_ONENAND_SEL() | MUX_ONENAND_1_SEL();
  476. set = MUX_EPLL_SEL() | MUX_VPLL_SEL() | MUX_ACLK_200_SEL() |
  477. MUX_ACLK_100_SEL() | MUX_ACLK_160_SEL() |
  478. MUX_ACLK_133_SEL() | MUX_ONENAND_SEL() | MUX_ONENAND_1_SEL();
  479. clrsetbits_le32(&clk->src_top0, clr, set);
  480.  
  481. /* Wait for mux change */
  482. sdelay(0x30000);
  483.  
  484. /* CLK_SRC_TOP1 */
  485. clr = MUX_MPLL_USER_SEL_T() | MUX_ACLK_400_MCUISP_SEL() |
  486. MUX_ACLK_400_MCUISP_SUB_SEL() | MUX_ACLK_200_SUB_SEL() |
  487. MUX_ACLK_266_GPS_SEL() | MUX_ACLK_266_GPS_SUB_SEL();
  488.  
  489. set = MUX_MPLL_USER_SEL_T() | MUX_ACLK_400_MCUISP_SEL() |
  490. MUX_ACLK_400_MCUISP_SUB_SEL() | MUX_ACLK_200_SUB_SEL() |
  491. MUX_ACLK_266_GPS_SEL() | MUX_ACLK_266_GPS_SUB_SEL();
  492. clrsetbits_le32(&clk->src_top1, clr, set);
  493.  
  494. /* Wait for mux change */
  495. sdelay(0x30000);
  496.  
  497. /*************** Set CMU_DMC clocks src MUX ***************/
  498. /*
  499. * Set CMU_DMC clocks src to MPLL
  500. * Bit values: 0 ; 1
  501. * MUX_C2C_SEL: SCLKMPLL ; SCLKAPLL
  502. * MUX_DMC_BUS_SEL: SCLKMPLL ; SCLKAPLL
  503. * MUX_DPHY_SEL: SCLKMPLL ; SCLKAPLL
  504. * MUX_MPLL_SEL: FINPLL ; MOUT_MPLL_FOUT
  505. * MUX_PWI_SEL: 0110 (MPLL); 0111 (EPLL); 1000 (VPLL); 0(XXTI)
  506. * MUX_G2D_ACP0_SEL: SCLKMPLL ; SCLKAPLL
  507. * MUX_G2D_ACP1_SEL: SCLKEPLL ; SCLKVPLL
  508. * MUX_G2D_ACP_SEL: OUT_ACP0 ; OUT_ACP1
  509. */
  510. clr_src_dmc = MUX_C2C_SEL() | MUX_DMC_BUS_SEL() |
  511. MUX_DPHY_SEL() | MUX_MPLL_SEL() |
  512. MUX_PWI_SEL() | MUX_G2D_ACP0_SEL() |
  513. MUX_G2D_ACP1_SEL() | MUX_G2D_ACP_SEL();
  514. set = MUX_MPLL_SEL() | MUX_C2C_SEL() | MUX_DMC_BUS_SEL() |
  515. MUX_DPHY_SEL() | MUX_PWI_SEL() |
  516. MUX_G2D_ACP0_SEL() | MUX_G2D_ACP1_SEL() | MUX_G2D_ACP_SEL();
  517. clrsetbits_le32(&clk->src_dmc, clr_src_dmc, set);
  518.  
  519. /* Wait for mux change */
  520. while (readl(&clk->mux_stat_dmc) & MUX_STAT_DMC_CHANGING)
  521. continue;
  522.  
  523. /*************** Set CMU_CPU clocks src MUX ***************/
  524. /* Set CMU_CPU clocks src to APLL
  525. * Bit values: 0 ; 1
  526. * MUX_APLL_SEL: FIN_PLL ; FOUT_APLL
  527. * MUX_CORE_SEL: MOUT_APLL ; SCLK_MPLL
  528. * MUX_HPM_SEL: MOUT_APLL ; SCLK_MPLL_USER_C
  529. * MUX_MPLL_USER_SEL_C: FIN_PLL ; SCLK_MPLL
  530. */
  531. clr_src_cpu = MUX_APLL_SEL() | MUX_CORE_SEL() |
  532. MUX_HPM_SEL() | MUX_MPLL_USER_SEL_C();
  533. set = MUX_APLL_SEL() | MUX_CORE_SEL() | MUX_HPM_SEL() |
  534. MUX_MPLL_USER_SEL_C();
  535. clrsetbits_le32(&clk->src_cpu, clr_src_cpu, set);
  536.  
  537. /* Wait for mux change */
  538. while (readl(&clk->mux_stat_cpu) & MUX_STAT_CPU_CHANGING)
  539. continue;
  540. }
  1. /*
  2. * Copyright (C) 2014 Samsung Electronics
  3. * Przemyslaw Marczak <p.marczak@samsung.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0
  6. */
  7.  
  8. #ifndef __EXYNOS4412_SETUP__
  9. #define __EXYNOS4412_SETUP__
  10.  
  11. /* A/M/E/V PLL_CON0 */
  12. #define SDIV(x) ((x) & 0x7)
  13. #define PDIV(x) (((x) & 0x3f) << 8)
  14. #define MDIV(x) (((x) & 0x3ff) << 16)
  15. #define FSEL(x) (((x) & 0x1) << 27)
  16. #define PLL_LOCKED_BIT (0x1 << 29)
  17. #define PLL_ENABLE(x) (((x) & 0x1) << 31)
  18.  
  19. /* A/M PLL_CON1 */
  20. #define AFC(x) ((x) & 0xf)
  21. #define LOCK_CON_DLY(x) (((x) & 0xf) << 8)
  22. #define LOCK_CON_IN(x) (((x) & 0x3) << 12)
  23. #define LOCK_CON_OUT(x) (((x) & 0x3) << 14)
  24. #define FEED_EN(x) (((x) & 0x1) << 16)
  25. #define AFC_ENB(x) (((x) & 0x1) << 20)
  26. #define DCC_ENB(x) (((x) & 0x1) << 21)
  27. #define BYPASS(x) (((x) & 0x1) << 22)
  28. #define RESV0(x) (((x) & 0x1) << 23)
  29. #define RESV1(x) (((x) & 0x1) << 24)
  30.  
  31. /* E/V PLL_CON1 */
  32. #define K(x) ((x) & 0xffff)
  33. #define MFR(x) (((x) & 0xff) << 16)
  34. #define MRR(x) (((x) & 0x1f) << 24)
  35. #define SEL_PF(x) (((x) & 0x3) << 9)
  36.  
  37. /* E/V PLL_CON2 */
  38. #define ICP_BOOST(x) ((x) & 0x3)
  39. #define FSEL_E_V(x) (((x) & 0x1) << 2)
  40. #define FVCO_EN(x) (((x) & 0x1) << 3)
  41. #define BYPASS_E_V(x) (((x) & 0x1) << 4)
  42. #define SSCG_EN(x) (((x) & 0x1) << 5)
  43. #define AFC_ENB_E_V(x) (((x) & 0x1) << 6)
  44. #define DCC_ENB_E_V(x) (((x) & 0x1) << 7)
  45. #define EXTAFC(x) (((x) & 0x1f) << 8)
  46.  
  47. #define PLL_LOCKTIME(x) ((x) & 0xffff)
  48.  
  49. /* CLK_SRC_CPU */
  50. #define MUX_APLL_SEL(x) ((x) & 0x1)
  51. #define MUX_CORE_SEL(x) (((x) & 0x1) << 16)
  52. #define MUX_HPM_SEL(x) (((x) & 0x1) << 20)
  53. #define MUX_MPLL_USER_SEL_C(x) (((x) & 0x1) << 24)
  54.  
  55. #define MUX_STAT_CHANGING 0x100
  56.  
  57. /* CLK_MUX_STAT_CPU */
  58. #define APLL_SEL(x) ((x) & 0x7)
  59. #define CORE_SEL(x) (((x) & 0x7) << 16)
  60. #define HPM_SEL(x) (((x) & 0x7) << 20)
  61. #define MPLL_USER_SEL_C(x) (((x) & 0x7) << 24)
  62. #define MUX_STAT_CPU_CHANGING (APLL_SEL(MUX_STAT_CHANGING) | \
  63. CORE_SEL(MUX_STAT_CHANGING) | \
  64. HPM_SEL(MUX_STAT_CHANGING) | \
  65. MPLL_USER_SEL_C(MUX_STAT_CHANGING))
  66.  
  67. /* CLK_DIV_CPU0 */
  68. #define CORE_RATIO(x) ((x) & 0x7)
  69. #define COREM0_RATIO(x) (((x) & 0x7) << 4)
  70. #define COREM1_RATIO(x) (((x) & 0x7) << 8)
  71. #define PERIPH_RATIO(x) (((x) & 0x7) << 12)
  72. #define ATB_RATIO(x) (((x) & 0x7) << 16)
  73. #define PCLK_DBG_RATIO(x) (((x) & 0x7) << 20)
  74. #define APLL_RATIO(x) (((x) & 0x7) << 24)
  75. #define CORE2_RATIO(x) (((x) & 0x7) << 28)
  76.  
  77. /* CLK_DIV_STAT_CPU0 */
  78. #define DIV_CORE(x) ((x) & 0x1)
  79. #define DIV_COREM0(x) (((x) & 0x1) << 4)
  80. #define DIV_COREM1(x) (((x) & 0x1) << 8)
  81. #define DIV_PERIPH(x) (((x) & 0x1) << 12)
  82. #define DIV_ATB(x) (((x) & 0x1) << 16)
  83. #define DIV_PCLK_DBG(x) (((x) & 0x1) << 20)
  84. #define DIV_APLL(x) (((x) & 0x1) << 24)
  85. #define DIV_CORE2(x) (((x) & 0x1) << 28)
  86.  
  87. #define DIV_STAT_CHANGING 0x1
  88. #define DIV_STAT_CPU0_CHANGING (DIV_CORE(DIV_STAT_CHANGING) | \
  89. DIV_COREM0(DIV_STAT_CHANGING) | \
  90. DIV_COREM1(DIV_STAT_CHANGING) | \
  91. DIV_PERIPH(DIV_STAT_CHANGING) | \
  92. DIV_ATB(DIV_STAT_CHANGING) | \
  93. DIV_PCLK_DBG(DIV_STAT_CHANGING) | \
  94. DIV_APLL(DIV_STAT_CHANGING) | \
  95. DIV_CORE2(DIV_STAT_CHANGING))
  96.  
  97. /* CLK_DIV_CPU1 */
  98. #define COPY_RATIO(x) ((x) & 0x7)
  99. #define HPM_RATIO(x) (((x) & 0x7) << 4)
  100. #define CORES_RATIO(x) (((x) & 0x7) << 8)
  101.  
  102. /* CLK_DIV_STAT_CPU1 */
  103. #define DIV_COPY(x) ((x) & 0x7)
  104. #define DIV_HPM(x) (((x) & 0x1) << 4)
  105. #define DIV_CORES(x) (((x) & 0x1) << 8)
  106.  
  107. #define DIV_STAT_CPU1_CHANGING (DIV_COPY(DIV_STAT_CHANGING) | \
  108. DIV_HPM(DIV_STAT_CHANGING) | \
  109. DIV_CORES(DIV_STAT_CHANGING))
  110.  
  111. /* CLK_SRC_DMC */
  112. #define MUX_C2C_SEL(x) ((x) & 0x1)
  113. #define MUX_DMC_BUS_SEL(x) (((x) & 0x1) << 4)
  114. #define MUX_DPHY_SEL(x) (((x) & 0x1) << 8)
  115. #define MUX_MPLL_SEL(x) (((x) & 0x1) << 12)
  116. #define MUX_PWI_SEL(x) (((x) & 0xf) << 16)
  117. #define MUX_G2D_ACP0_SEL(x) (((x) & 0x1) << 20)
  118. #define MUX_G2D_ACP1_SEL(x) (((x) & 0x1) << 24)
  119. #define MUX_G2D_ACP_SEL(x) (((x) & 0x1) << 28)
  120.  
  121. /* CLK_MUX_STAT_DMC */
  122. #define C2C_SEL(x) (((x)) & 0x7)
  123. #define DMC_BUS_SEL(x) (((x) & 0x7) << 4)
  124. #define DPHY_SEL(x) (((x) & 0x7) << 8)
  125. #define MPLL_SEL(x) (((x) & 0x7) << 12)
  126. /* #define PWI_SEL(x) (((x) & 0xf) << 16) - Reserved */
  127. #define G2D_ACP0_SEL(x) (((x) & 0x7) << 20)
  128. #define G2D_ACP1_SEL(x) (((x) & 0x7) << 24)
  129. #define G2D_ACP_SEL(x) (((x) & 0x7) << 28)
  130.  
  131. #define MUX_STAT_DMC_CHANGING (C2C_SEL(MUX_STAT_CHANGING) | \
  132. DMC_BUS_SEL(MUX_STAT_CHANGING) | \
  133. DPHY_SEL(MUX_STAT_CHANGING) | \
  134. MPLL_SEL(MUX_STAT_CHANGING) |\
  135. G2D_ACP0_SEL(MUX_STAT_CHANGING) | \
  136. G2D_ACP1_SEL(MUX_STAT_CHANGING) | \
  137. G2D_ACP_SEL(MUX_STAT_CHANGING))
  138.  
  139. /* CLK_DIV_DMC0 */
  140. #define ACP_RATIO(x) ((x) & 0x7)
  141. #define ACP_PCLK_RATIO(x) (((x) & 0x7) << 4)
  142. #define DPHY_RATIO(x) (((x) & 0x7) << 8)
  143. #define DMC_RATIO(x) (((x) & 0x7) << 12)
  144. #define DMCD_RATIO(x) (((x) & 0x7) << 16)
  145. #define DMCP_RATIO(x) (((x) & 0x7) << 20)
  146.  
  147. /* CLK_DIV_STAT_DMC0 */
  148. #define DIV_ACP(x) ((x) & 0x1)
  149. #define DIV_ACP_PCLK(x) (((x) & 0x1) << 4)
  150. #define DIV_DPHY(x) (((x) & 0x1) << 8)
  151. #define DIV_DMC(x) (((x) & 0x1) << 12)
  152. #define DIV_DMCD(x) (((x) & 0x1) << 16)
  153. #define DIV_DMCP(x) (((x) & 0x1) << 20)
  154.  
  155. #define DIV_STAT_DMC0_CHANGING (DIV_ACP(DIV_STAT_CHANGING) | \
  156. DIV_ACP_PCLK(DIV_STAT_CHANGING) | \
  157. DIV_DPHY(DIV_STAT_CHANGING) | \
  158. DIV_DMC(DIV_STAT_CHANGING) | \
  159. DIV_DMCD(DIV_STAT_CHANGING) | \
  160. DIV_DMCP(DIV_STAT_CHANGING))
  161.  
  162. /* CLK_DIV_DMC1 */
  163. #define G2D_ACP_RATIO(x) ((x) & 0xf)
  164. #define C2C_RATIO(x) (((x) & 0x7) << 4)
  165. #define PWI_RATIO(x) (((x) & 0xf) << 8)
  166. #define C2C_ACLK_RATIO(x) (((x) & 0x7) << 12)
  167. #define DVSEM_RATIO(x) (((x) & 0x7f) << 16)
  168. #define DPM_RATIO(x) (((x) & 0x7f) << 24)
  169.  
  170. /* CLK_DIV_STAT_DMC1 */
  171. #define DIV_G2D_ACP(x) ((x) & 0x1)
  172. #define DIV_C2C(x) (((x) & 0x1) << 4)
  173. #define DIV_PWI(x) (((x) & 0x1) << 8)
  174. #define DIV_C2C_ACLK(x) (((x) & 0x1) << 12)
  175. #define DIV_DVSEM(x) (((x) & 0x1) << 16)
  176. #define DIV_DPM(x) (((x) & 0x1) << 24)
  177.  
  178. #define DIV_STAT_DMC1_CHANGING (DIV_G2D_ACP(DIV_STAT_CHANGING) | \
  179. DIV_C2C(DIV_STAT_CHANGING) | \
  180. DIV_PWI(DIV_STAT_CHANGING) | \
  181. DIV_C2C_ACLK(DIV_STAT_CHANGING) | \
  182. DIV_DVSEM(DIV_STAT_CHANGING) | \
  183. DIV_DPM(DIV_STAT_CHANGING))
  184.  
  185. /* CLK_DIV_TOP */
  186. #define ACLK_400_MCUISP_RATIO(x) (((x) & 0x7) << 24)
  187. #define ACLK_266_GPS_RATIO(x) (((x) & 0x7) << 20)
  188. #define ONENAND_RATIO(x) (((x) & 0x7) << 16)
  189. #define ACLK_133_RATIO(x) (((x) & 0x7) << 12)
  190. #define ACLK_160_RATIO(x) (((x) & 0x7) << 8)
  191. #define ACLK_100_RATIO(x) (((x) & 0xf) << 4)
  192. #define ACLK_200_RATIO(x) ((x) & 0x7)
  193.  
  194. #define DIV_STAT_TOP_CHANGING (ACLK_400_MCUISP_RATIO(DIV_STAT_CHANGING) | \
  195. ACLK_266_GPS_RATIO(DIV_STAT_CHANGING) | \
  196. ONENAND_RATIO(DIV_STAT_CHANGING) | \
  197. ACLK_133_RATIO(DIV_STAT_CHANGING) | \
  198. ACLK_160_RATIO(DIV_STAT_CHANGING) | \
  199. ACLK_100_RATIO(DIV_STAT_CHANGING) | \
  200. ACLK_200_RATIO(DIV_STAT_CHANGING))
  201.  
  202. /* CLK_SRC_TOP0 */
  203. #define MUX_ONENAND_SEL(x) (((x) & 0x1) << 28)
  204. #define MUX_ACLK_133_SEL(x) (((x) & 0x1) << 24)
  205. #define MUX_ACLK_160_SEL(x) (((x) & 0x1) << 20)
  206. #define MUX_ACLK_100_SEL(x) (((x) & 0x1) << 16)
  207. #define MUX_ACLK_200_SEL(x) (((x) & 0x1) << 12)
  208. #define MUX_VPLL_SEL(x) (((x) & 0x1) << 8)
  209. #define MUX_EPLL_SEL(x) (((x) & 0x1) << 4)
  210. #define MUX_ONENAND_1_SEL(x) ((x) & 0x1)
  211.  
  212. /* CLK_MUX_STAT_TOP */
  213. #define ONENAND_SEL(x) (((x) & 0x3) << 28)
  214. #define ACLK_133_SEL(x) (((x) & 0x3) << 24)
  215. #define ACLK_160_SEL(x) (((x) & 0x3) << 20)
  216. #define ACLK_100_SEL(x) (((x) & 0x3) << 16)
  217. #define ACLK_200_SEL(x) (((x) & 0x3) << 12)
  218. #define VPLL_SEL(x) (((x) & 0x3) << 8)
  219. #define EPLL_SEL(x) (((x) & 0x3) << 4)
  220. #define ONENAND_1_SEL(x) ((x) & 0x3)
  221.  
  222. /* CLK_SRC_TOP1 */
  223. #define MUX_ACLK_400_MCUISP_SUB_SEL(x) (((x) & 0x1) << 24)
  224. #define MUX_ACLK_200_SUB_SEL(x) (((x) & 0x1) << 20)
  225. #define MUX_ACLK_266_GPS_SUB_SEL(x) (((x) & 0x1) << 16)
  226. #define MUX_MPLL_USER_SEL_T(x) (((x) & 0x1) << 12)
  227. #define MUX_ACLK_400_MCUISP_SEL(x) (((x) & 0x1) << 8)
  228. #define MUX_ACLK_266_GPS_SEL(x) (((x) & 0x1) << 4)
  229.  
  230. /* CLK_MUX_STAT_TOP1 */
  231. #define ACLK_400_MCUISP_SUB_SEL(x) (((x) & 0x3) << 24)
  232. #define ACLK_200_SUB_SEL(x) (((x) & 0x3) << 20)
  233. #define ACLK_266_GPS_SUB_SEL(x) (((x) & 0x3) << 16)
  234. #define MPLL_USER_SEL_T(x) (((x) & 0x3) << 12)
  235. #define ACLK_400_MCUISP_SEL(x) (((x) & 0x3) << 8)
  236. #define ACLK_266_GPS_SEL(x) (((x) & 0x3) << 4)
  237.  
  238. /*CLK_DIV_LEFTBUS*/
  239. #define GDL_RATIO(x) ((x) & 0x7)
  240. #define GPL_RATIO(x) (((x) & 0x7) << 4)
  241.  
  242. #define DIV_STAT_LEFTBUS_CHANGING (GDL_RATIO(DIV_STAT_CHANGING) | \
  243. GPL_RATIO(DIV_STAT_CHANGING) )
  244. /* CLK_SRC_LEFTBUS */
  245. #define MUX_MPLL_USER_SEL_L(x) (((x) & 0x1) << 4)
  246. #define MUX_GDL_SEL(x) ((x) & 0x1)
  247.  
  248. /* CLK_MUX_STAT_LEFTBUS */
  249. #define MPLL_USER_SEL_L(x) (((x) & 0x3) << 4)
  250. #define GDL_SEL(x) ((x) & 0x3)
  251.  
  252. /*CLK_DIV_RIGHTBUS*/
  253. #define GDR_RATIO(x) ((x) & 0x7)
  254. #define GPR_RATIO(x) (((x) & 0x7) << 4)
  255.  
  256. #define DIV_STAT_RIGHTBUS_CHANGING (GDR_RATIO(DIV_STAT_CHANGING) | \
  257. GPR_RATIO(DIV_STAT_CHANGING) )
  258.  
  259. /* CLK_SRC_RIGHTBUS */
  260. #define MUX_MPLL_USER_SEL_R(x) (((x) & 0x1) << 4)
  261. #define MUX_GDR_SEL(x) ((x) & 0x1)
  262.  
  263. /* CLK_MUX_STAT_RIGHTBUS */
  264. #define MPLL_USER_SEL_R(x) (((x) & 0x3) << 4)
  265. #define GDR_SEL(x) ((x) & 0x3)
  266.  
  267. /* Set CLK_SRC_PERIL0 */
  268. #define UART4_SEL(x) (((x) & 0xf) << 16)
  269. #define UART3_SEL(x) (((x) & 0xf) << 12)
  270. #define UART2_SEL(x) (((x) & 0xf) << 8)
  271. #define UART1_SEL(x) (((x) & 0xf) << 4)
  272. #define UART0_SEL(x) ((x) & 0xf)
  273.  
  274. /* Set CLK_DIV_PERIL0 */
  275. #define UART4_RATIO(x) (((x) & 0xf) << 16)
  276. #define UART3_RATIO(x) (((x) & 0xf) << 12)
  277. #define UART2_RATIO(x) (((x) & 0xf) << 8)
  278. #define UART1_RATIO(x) (((x) & 0xf) << 4)
  279. #define UART0_RATIO(x) ((x) & 0xf)
  280.  
  281. /* Set CLK_DIV_STAT_PERIL0 */
  282. #define DIV_UART4(x) (((x) & 0x1) << 16)
  283. #define DIV_UART3(x) (((x) & 0x1) << 12)
  284. #define DIV_UART2(x) (((x) & 0x1) << 8)
  285. #define DIV_UART1(x) (((x) & 0x1) << 4)
  286. #define DIV_UART0(x) ((x) & 0x1)
  287.  
  288. #define DIV_STAT_PERIL0_CHANGING (DIV_UART4(DIV_STAT_CHANGING) | \
  289. DIV_UART3(DIV_STAT_CHANGING) | \
  290. DIV_UART2(DIV_STAT_CHANGING) | \
  291. DIV_UART1(DIV_STAT_CHANGING) | \
  292. DIV_UART0(DIV_STAT_CHANGING))
  293.  
  294. /* CLK_DIV_FSYS1 */
  295. #define MMC0_RATIO(x) ((x) & 0xf)
  296. #define MMC0_PRE_RATIO(x) (((x) & 0xff) << 8)
  297. #define MMC1_RATIO(x) (((x) & 0xf) << 16)
  298. #define MMC1_PRE_RATIO(x) (((x) & 0xff) << 24)
  299.  
  300. /* CLK_DIV_STAT_FSYS1 */
  301. #define DIV_MMC0(x) ((x) & 1)
  302. #define DIV_MMC0_PRE(x) (((x) & 1) << 8)
  303. #define DIV_MMC1(x) (((x) & 1) << 16)
  304. #define DIV_MMC1_PRE(x) (((x) & 1) << 24)
  305.  
  306. #define DIV_STAT_FSYS1_CHANGING (DIV_MMC0(DIV_STAT_CHANGING) | \
  307. DIV_MMC0_PRE(DIV_STAT_CHANGING) | \
  308. DIV_MMC1(DIV_STAT_CHANGING) | \
  309. DIV_MMC1_PRE(DIV_STAT_CHANGING))
  310.  
  311. /* CLK_DIV_FSYS2 */
  312. #define MMC2_RATIO(x) ((x) & 0xf)
  313. #define MMC2_PRE_RATIO(x) (((x) & 0xff) << 8)
  314. #define MMC3_RATIO(x) (((x) & 0xf) << 16)
  315. #define MMC3_PRE_RATIO(x) (((x) & 0xff) << 24)
  316.  
  317. /* CLK_DIV_STAT_FSYS2 */
  318. #define DIV_MMC2(x) ((x) & 0x1)
  319. #define DIV_MMC2_PRE(x) (((x) & 0x1) << 8)
  320. #define DIV_MMC3(x) (((x) & 0x1) << 16)
  321. #define DIV_MMC3_PRE(x) (((x) & 0x1) << 24)
  322.  
  323. #define DIV_STAT_FSYS2_CHANGING (DIV_MMC2(DIV_STAT_CHANGING) | \
  324. DIV_MMC2_PRE(DIV_STAT_CHANGING) | \
  325. DIV_MMC3(DIV_STAT_CHANGING) | \
  326. DIV_MMC3_PRE(DIV_STAT_CHANGING))
  327.  
  328. /* CLK_DIV_FSYS3 */
  329. #define MMC4_RATIO(x) ((x) & 0x7)
  330. #define MMC4_PRE_RATIO(x) (((x) & 0xff) << 8)
  331.  
  332. /* CLK_DIV_STAT_FSYS3 */
  333. #define DIV_MMC4(x) ((x) & 0x1)
  334. #define DIV_MMC4_PRE(x) (((x) & 0x1) << 8)
  335.  
  336. #define DIV_STAT_FSYS3_CHANGING (DIV_MMC4(DIV_STAT_CHANGING) | \
  337. DIV_MMC4_PRE(DIV_STAT_CHANGING))
  338.  
  339. #endif /*__EXYNOS4412_SETUP__ */

这块非常重要,配置不好会涉及到后面驱动移植。还需多注意。

tiny4412 --Uboot移植(3) 时钟的更多相关文章

  1. X-005 FriendlyARM tiny4412 uboot移植之时钟初始化

    <<<<<<<<<<<<<<<<<<<<<<<<< ...

  2. 第三章、Tiny4412 U-BOOT移植三 时钟设置【转】

    本文转自:http://blog.csdn.net/eshing/article/details/37521789 这一章说明配置时钟频率基本原理 OK,接着说,这次先讲讲CPU的系统时钟.U-BOO ...

  3. X-007 FriendlyARM tiny4412 u-boot移植之内存初始化

    <<<<<<<<<<<<<<<<<<<<<<<<< ...

  4. X-004 FriendlyARM tiny4412 uboot移植之点亮指路灯

    <<<<<<<<<<<<<<<<<<<<<<<<< ...

  5. X-003 FriendlyARM tiny4412 uboot移植之添加相应目录文件

    X-003 FriendlyARM tiny4412 uboot移植之添加相应目录文件 <<<<<<<<<<<<<< ...

  6. tiny4412 --Uboot移植(5) DDR3内存

    开发环境:win10 64位 + VMware12 + Ubuntu14.04 32位 工具链:linaro提供的gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-g ...

  7. 第四章、TIny4412 U-BOOT移植四 配置时钟频率源码分析【转】

    本文转载自:http://blog.csdn.net/eshing/article/details/37542459 版权声明:本文为博主原创文章,未经博主允许不得转载.   目录(?)[+]   上 ...

  8. X-010 FriendlyARM tiny4412 uboot移植之移植网卡驱动TFTP用起来

    <<<<<<<<<<<<<<<<<<<<<<<<< ...

  9. Tiny4412 U-BOOT移植(转)

    http://blog.csdn.net/eshing/article/details/37520291(转) 一.移植前说明: 1.  特别声明:此文档是我的学习文档,里面肯定有错误地方,仅供参考! ...

随机推荐

  1. centos7使用snmp

     一.安装snmp net-snmp :服务端 net-snmp-utils:客户端工具集   二.启动 systemctl start snmpd   三.修改配置文件(完整的配置文件如下) com ...

  2. 用jquery得到select选中的值

    <select class="pushtype" name="push_type" onchange="pushType(this)" ...

  3. 基于MATLAB System Generator 搭建Display Enhancement模型

    基于MATLAB System Generator 搭建Display Enhancement模型

  4. Linux系统目录权限chmod误操作权限修复方法

    Linux中,如果意外误操作将/目录权限批量设置,比如chmod -R 777 / ,系统中的大部分服务以及命令将无法使用,这时候可以通过系统自带的getfacl命令来拷贝和还原系统权限,若是其他系统 ...

  5. 基础:位(bit)、字节(byte)、字符、编码之间的关系

    1.位: 数据存储的最小单位.每个二进制数字0或者1就是1个位: 2.字节: 8个位构成一个字节:即:1 byte (字节)= 8 bit(位): 1 KB = 1024 B(字节): 1 MB = ...

  6. 8、sort排序中比较函数的几种应用方式

    1.待排序中的元素作数组的下标或map的键值 例题:PAT甲级_1141 PAT Ranking of Institutions #include<bits/stdc++.h> using ...

  7. windows copy 和xcopy

    #将文件夹下文件拷贝到指定目录 将d盘下1文件夹内所有内容拷贝到测试目录下copy d:\1\ Z:\chenkai\测试目录\ /yxcopy D:\soft\svn工具 Z:\chenkai\测试 ...

  8. [UE4]CheckBox

    一.CheckBox默认情况下是比较小的 二.要让CheckBox变大,最简单的方法就是直接设置Transform.Scale,但如此一来CheckBox就变得模糊了. 三.CheckBox控件是在C ...

  9. [UE4]Tree View

    类似List View,但Tree View要求提供树形结构的数据.Tree View和Tile View都是继承自List View 一.创建一个名为“TreeEntry”的UserWidget,添 ...

  10. (转)SQLServer查询数据库各种历史记录

    原文地址https://www.cnblogs.com/seusoftware/p/4826958.html 在SQL Server数据库中,从登陆开始,然后做了什么操作,以及数据库里发生了什么,大多 ...