Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 2 | /* |
Marcel Ziswiler | 2ad3204 | 2019-03-25 17:25:00 +0100 | [diff] [blame] | 3 | * Copyright 2015-2019 Toradex, Inc. |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 4 | * |
| 5 | * Based on vf610twr.c: |
| 6 | * Copyright 2013 Freescale Semiconductor, Inc. |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Marcel Ziswiler | 2ad3204 | 2019-03-25 17:25:00 +0100 | [diff] [blame] | 10 | |
| 11 | #include <asm/arch/clock.h> |
| 12 | #include <asm/arch/crm_regs.h> |
| 13 | #include <asm/arch/ddrmc-vf610.h> |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 14 | #include <asm/arch/imx-regs.h> |
| 15 | #include <asm/arch/iomux-vf610.h> |
Marcel Ziswiler | 2ad3204 | 2019-03-25 17:25:00 +0100 | [diff] [blame] | 16 | #include <asm/gpio.h> |
| 17 | #include <asm/io.h> |
Stefan Agner | 1f8ced9 | 2016-11-30 13:41:54 -0800 | [diff] [blame] | 18 | #include <fdt_support.h> |
Stefan Agner | 1301175 | 2017-04-11 11:12:14 +0530 | [diff] [blame] | 19 | #include <fsl_dcu_fb.h> |
Marcel Ziswiler | 2ad3204 | 2019-03-25 17:25:00 +0100 | [diff] [blame] | 20 | #include <g_dnl.h> |
Stefan Agner | 1f8ced9 | 2016-11-30 13:41:54 -0800 | [diff] [blame] | 21 | #include <jffs2/load_kernel.h> |
Stefan Agner | 1f8ced9 | 2016-11-30 13:41:54 -0800 | [diff] [blame] | 22 | #include <mtd_node.h> |
Sanchayan Maity | ffb8959 | 2015-11-12 11:47:35 +0530 | [diff] [blame] | 23 | #include <usb.h> |
Marcel Ziswiler | 2ad3204 | 2019-03-25 17:25:00 +0100 | [diff] [blame] | 24 | |
Stefan Agner | 98ffd0f | 2016-11-30 13:41:53 -0800 | [diff] [blame] | 25 | #include "../common/tdx-common.h" |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 26 | |
| 27 | DECLARE_GLOBAL_DATA_PTR; |
| 28 | |
Gerard Salvatella | 108d739 | 2018-11-19 15:54:10 +0100 | [diff] [blame] | 29 | #define PTC0_GPIO_45 45 |
Sanchayan Maity | a5c270e | 2015-06-01 18:37:25 +0530 | [diff] [blame] | 30 | |
Albert ARIBAUD \\(3ADEV\\) | 25ac8ce | 2015-09-21 22:43:37 +0200 | [diff] [blame] | 31 | static struct ddrmc_cr_setting colibri_vf_cr_settings[] = { |
Stefan Agner | b320ca5 | 2019-03-25 17:25:11 +0100 | [diff] [blame] | 32 | { DDRMC_CR79_CTLUPD_AREF(1), 79 }, |
| 33 | /* sets manual values for read lvl. (gate) delay of data slice 0/1 */ |
| 34 | { DDRMC_CR105_RDLVL_DL_0(28), 105 }, |
| 35 | { DDRMC_CR106_RDLVL_GTDL_0(24), 106 }, |
| 36 | { DDRMC_CR110_RDLVL_DL_1(28) | DDRMC_CR110_RDLVL_GTDL_1(24), 110 }, |
| 37 | { DDRMC_CR102_RDLVL_GT_REGEN | DDRMC_CR102_RDLVL_REG_EN, 102 }, |
| 38 | |
Albert ARIBAUD \\(3ADEV\\) | 25ac8ce | 2015-09-21 22:43:37 +0200 | [diff] [blame] | 39 | /* AXI */ |
| 40 | { DDRMC_CR117_AXI0_W_PRI(0) | DDRMC_CR117_AXI0_R_PRI(0), 117 }, |
| 41 | { DDRMC_CR118_AXI1_W_PRI(1) | DDRMC_CR118_AXI1_R_PRI(1), 118 }, |
| 42 | { DDRMC_CR120_AXI0_PRI1_RPRI(2) | |
| 43 | DDRMC_CR120_AXI0_PRI0_RPRI(2), 120 }, |
| 44 | { DDRMC_CR121_AXI0_PRI3_RPRI(2) | |
| 45 | DDRMC_CR121_AXI0_PRI2_RPRI(2), 121 }, |
| 46 | { DDRMC_CR122_AXI1_PRI1_RPRI(1) | DDRMC_CR122_AXI1_PRI0_RPRI(1) | |
| 47 | DDRMC_CR122_AXI0_PRIRLX(100), 122 }, |
| 48 | { DDRMC_CR123_AXI1_P_ODR_EN | DDRMC_CR123_AXI1_PRI3_RPRI(1) | |
| 49 | DDRMC_CR123_AXI1_PRI2_RPRI(1), 123 }, |
| 50 | { DDRMC_CR124_AXI1_PRIRLX(100), 124 }, |
| 51 | { DDRMC_CR126_PHY_RDLAT(8), 126 }, |
| 52 | { DDRMC_CR132_WRLAT_ADJ(5) | |
| 53 | DDRMC_CR132_RDLAT_ADJ(6), 132 }, |
| 54 | { DDRMC_CR137_PHYCTL_DL(2), 137 }, |
| 55 | { DDRMC_CR138_PHY_WRLV_MXDL(256) | |
| 56 | DDRMC_CR138_PHYDRAM_CK_EN(1), 138 }, |
| 57 | { DDRMC_CR139_PHY_WRLV_RESPLAT(4) | DDRMC_CR139_PHY_WRLV_LOAD(7) | |
| 58 | DDRMC_CR139_PHY_WRLV_DLL(3) | |
| 59 | DDRMC_CR139_PHY_WRLV_EN(3), 139 }, |
| 60 | { DDRMC_CR140_PHY_WRLV_WW(64), 140 }, |
| 61 | { DDRMC_CR143_RDLV_GAT_MXDL(1536) | |
| 62 | DDRMC_CR143_RDLV_MXDL(128), 143 }, |
| 63 | { DDRMC_CR144_PHY_RDLVL_RES(4) | DDRMC_CR144_PHY_RDLV_LOAD(7) | |
| 64 | DDRMC_CR144_PHY_RDLV_DLL(3) | |
| 65 | DDRMC_CR144_PHY_RDLV_EN(3), 144 }, |
| 66 | { DDRMC_CR145_PHY_RDLV_RR(64), 145 }, |
| 67 | { DDRMC_CR146_PHY_RDLVL_RESP(64), 146 }, |
| 68 | { DDRMC_CR147_RDLV_RESP_MASK(983040), 147 }, |
| 69 | { DDRMC_CR148_RDLV_GATE_RESP_MASK(983040), 148 }, |
| 70 | { DDRMC_CR151_RDLV_GAT_DQ_ZERO_CNT(1) | |
| 71 | DDRMC_CR151_RDLVL_DQ_ZERO_CNT(1), 151 }, |
| 72 | |
| 73 | { DDRMC_CR154_PAD_ZQ_EARLY_CMP_EN_TIMER(13) | |
| 74 | DDRMC_CR154_PAD_ZQ_MODE(1) | |
| 75 | DDRMC_CR154_DDR_SEL_PAD_CONTR(3) | |
| 76 | DDRMC_CR154_PAD_ZQ_HW_FOR(1), 154 }, |
Stefan Agner | 0405f25 | 2018-12-04 11:10:18 +0100 | [diff] [blame] | 77 | { DDRMC_CR155_PAD_ODT_BYTE1(2) | DDRMC_CR155_PAD_ODT_BYTE0(2), 155 }, |
Albert ARIBAUD \\(3ADEV\\) | 25ac8ce | 2015-09-21 22:43:37 +0200 | [diff] [blame] | 78 | { DDRMC_CR158_TWR(6), 158 }, |
| 79 | { DDRMC_CR161_ODT_EN(1) | DDRMC_CR161_TODTH_RD(2) | |
| 80 | DDRMC_CR161_TODTH_WR(2), 161 }, |
| 81 | /* end marker */ |
| 82 | { 0, -1 } |
| 83 | }; |
| 84 | |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 85 | int dram_init(void) |
| 86 | { |
| 87 | static const struct ddr3_jedec_timings timings = { |
Albert ARIBAUD \\(3ADEV\\) | 25ac8ce | 2015-09-21 22:43:37 +0200 | [diff] [blame] | 88 | .tinit = 5, |
| 89 | .trst_pwron = 80000, |
| 90 | .cke_inactive = 200000, |
| 91 | .wrlat = 5, |
| 92 | .caslat_lin = 12, |
| 93 | .trc = 21, |
| 94 | .trrd = 4, |
| 95 | .tccd = 4, |
| 96 | .tbst_int_interval = 0, |
| 97 | .tfaw = 20, |
| 98 | .trp = 6, |
| 99 | .twtr = 4, |
| 100 | .tras_min = 15, |
| 101 | .tmrd = 4, |
| 102 | .trtp = 4, |
| 103 | .tras_max = 28080, |
| 104 | .tmod = 12, |
| 105 | .tckesr = 4, |
| 106 | .tcke = 3, |
| 107 | .trcd_int = 6, |
| 108 | .tras_lockout = 0, |
| 109 | .tdal = 12, |
Fabio Estevam | d19b782 | 2015-10-13 23:54:32 -0300 | [diff] [blame] | 110 | .bstlen = 3, |
Stefan Agner | 8661b8d | 2019-03-25 17:25:10 +0100 | [diff] [blame] | 111 | .tdll = 512, /* not applicable since freq. scaling |
| 112 | * is not used |
| 113 | */ |
Albert ARIBAUD \\(3ADEV\\) | 25ac8ce | 2015-09-21 22:43:37 +0200 | [diff] [blame] | 114 | .trp_ab = 6, |
| 115 | .tref = 3120, |
| 116 | .trfc = 64, |
| 117 | .tref_int = 0, |
| 118 | .tpdex = 3, |
| 119 | .txpdll = 10, |
Stefan Agner | 8661b8d | 2019-03-25 17:25:10 +0100 | [diff] [blame] | 120 | .txsnr = 68, /* changed to conform to JEDEC |
| 121 | * specifications |
| 122 | */ |
| 123 | .txsr = 506, /* changed to conform to JEDEC |
| 124 | * specifications |
| 125 | */ |
Albert ARIBAUD \\(3ADEV\\) | 25ac8ce | 2015-09-21 22:43:37 +0200 | [diff] [blame] | 126 | .cksrx = 5, |
| 127 | .cksre = 5, |
| 128 | .freq_chg_en = 0, |
| 129 | .zqcl = 256, |
| 130 | .zqinit = 512, |
| 131 | .zqcs = 64, |
| 132 | .ref_per_zq = 64, |
| 133 | .zqcs_rotate = 0, |
| 134 | .aprebit = 10, |
| 135 | .cmd_age_cnt = 64, |
| 136 | .age_cnt = 64, |
| 137 | .q_fullness = 7, |
| 138 | .odt_rd_mapcs0 = 0, |
| 139 | .odt_wr_mapcs0 = 1, |
| 140 | .wlmrd = 40, |
| 141 | .wldqsen = 25, |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 142 | }; |
| 143 | |
Albert ARIBAUD \\(3ADEV\\) | 25ac8ce | 2015-09-21 22:43:37 +0200 | [diff] [blame] | 144 | ddrmc_ctrl_init_ddr3(&timings, colibri_vf_cr_settings, NULL, 1, 2); |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 145 | gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE); |
| 146 | |
| 147 | return 0; |
| 148 | } |
| 149 | |
Bhuvanchandra DV | 7a27ba6 | 2015-06-01 18:37:17 +0530 | [diff] [blame] | 150 | #ifdef CONFIG_VYBRID_GPIO |
| 151 | static void setup_iomux_gpio(void) |
| 152 | { |
| 153 | static const iomux_v3_cfg_t gpio_pads[] = { |
| 154 | VF610_PAD_PTA17__GPIO_7, |
| 155 | VF610_PAD_PTA20__GPIO_10, |
| 156 | VF610_PAD_PTA21__GPIO_11, |
| 157 | VF610_PAD_PTA30__GPIO_20, |
| 158 | VF610_PAD_PTA31__GPIO_21, |
| 159 | VF610_PAD_PTB0__GPIO_22, |
| 160 | VF610_PAD_PTB1__GPIO_23, |
| 161 | VF610_PAD_PTB6__GPIO_28, |
| 162 | VF610_PAD_PTB7__GPIO_29, |
| 163 | VF610_PAD_PTB8__GPIO_30, |
| 164 | VF610_PAD_PTB9__GPIO_31, |
| 165 | VF610_PAD_PTB12__GPIO_34, |
| 166 | VF610_PAD_PTB13__GPIO_35, |
| 167 | VF610_PAD_PTB16__GPIO_38, |
| 168 | VF610_PAD_PTB17__GPIO_39, |
| 169 | VF610_PAD_PTB18__GPIO_40, |
| 170 | VF610_PAD_PTB21__GPIO_43, |
| 171 | VF610_PAD_PTB22__GPIO_44, |
| 172 | VF610_PAD_PTC0__GPIO_45, |
| 173 | VF610_PAD_PTC1__GPIO_46, |
| 174 | VF610_PAD_PTC2__GPIO_47, |
| 175 | VF610_PAD_PTC3__GPIO_48, |
| 176 | VF610_PAD_PTC4__GPIO_49, |
| 177 | VF610_PAD_PTC5__GPIO_50, |
| 178 | VF610_PAD_PTC6__GPIO_51, |
| 179 | VF610_PAD_PTC7__GPIO_52, |
| 180 | VF610_PAD_PTC8__GPIO_53, |
| 181 | VF610_PAD_PTD31__GPIO_63, |
| 182 | VF610_PAD_PTD30__GPIO_64, |
| 183 | VF610_PAD_PTD29__GPIO_65, |
| 184 | VF610_PAD_PTD28__GPIO_66, |
| 185 | VF610_PAD_PTD27__GPIO_67, |
| 186 | VF610_PAD_PTD26__GPIO_68, |
| 187 | VF610_PAD_PTD25__GPIO_69, |
| 188 | VF610_PAD_PTD24__GPIO_70, |
| 189 | VF610_PAD_PTD9__GPIO_88, |
| 190 | VF610_PAD_PTD10__GPIO_89, |
| 191 | VF610_PAD_PTD11__GPIO_90, |
| 192 | VF610_PAD_PTD12__GPIO_91, |
| 193 | VF610_PAD_PTD13__GPIO_92, |
| 194 | VF610_PAD_PTB23__GPIO_93, |
| 195 | VF610_PAD_PTB26__GPIO_96, |
| 196 | VF610_PAD_PTB28__GPIO_98, |
Bhuvanchandra DV | 7a27ba6 | 2015-06-01 18:37:17 +0530 | [diff] [blame] | 197 | VF610_PAD_PTC30__GPIO_103, |
| 198 | VF610_PAD_PTA7__GPIO_134, |
| 199 | }; |
| 200 | |
| 201 | imx_iomux_v3_setup_multiple_pads(gpio_pads, ARRAY_SIZE(gpio_pads)); |
| 202 | } |
| 203 | #endif |
| 204 | |
Stefan Agner | 1301175 | 2017-04-11 11:12:14 +0530 | [diff] [blame] | 205 | #ifdef CONFIG_VIDEO_FSL_DCU_FB |
| 206 | static void setup_iomux_fsl_dcu(void) |
| 207 | { |
| 208 | static const iomux_v3_cfg_t dcu0_pads[] = { |
| 209 | VF610_PAD_PTE0__DCU0_HSYNC, |
| 210 | VF610_PAD_PTE1__DCU0_VSYNC, |
| 211 | VF610_PAD_PTE2__DCU0_PCLK, |
| 212 | VF610_PAD_PTE4__DCU0_DE, |
| 213 | VF610_PAD_PTE5__DCU0_R0, |
| 214 | VF610_PAD_PTE6__DCU0_R1, |
| 215 | VF610_PAD_PTE7__DCU0_R2, |
| 216 | VF610_PAD_PTE8__DCU0_R3, |
| 217 | VF610_PAD_PTE9__DCU0_R4, |
| 218 | VF610_PAD_PTE10__DCU0_R5, |
| 219 | VF610_PAD_PTE11__DCU0_R6, |
| 220 | VF610_PAD_PTE12__DCU0_R7, |
| 221 | VF610_PAD_PTE13__DCU0_G0, |
| 222 | VF610_PAD_PTE14__DCU0_G1, |
| 223 | VF610_PAD_PTE15__DCU0_G2, |
| 224 | VF610_PAD_PTE16__DCU0_G3, |
| 225 | VF610_PAD_PTE17__DCU0_G4, |
| 226 | VF610_PAD_PTE18__DCU0_G5, |
| 227 | VF610_PAD_PTE19__DCU0_G6, |
| 228 | VF610_PAD_PTE20__DCU0_G7, |
| 229 | VF610_PAD_PTE21__DCU0_B0, |
| 230 | VF610_PAD_PTE22__DCU0_B1, |
| 231 | VF610_PAD_PTE23__DCU0_B2, |
| 232 | VF610_PAD_PTE24__DCU0_B3, |
| 233 | VF610_PAD_PTE25__DCU0_B4, |
| 234 | VF610_PAD_PTE26__DCU0_B5, |
| 235 | VF610_PAD_PTE27__DCU0_B6, |
| 236 | VF610_PAD_PTE28__DCU0_B7, |
| 237 | }; |
| 238 | |
| 239 | imx_iomux_v3_setup_multiple_pads(dcu0_pads, ARRAY_SIZE(dcu0_pads)); |
| 240 | } |
| 241 | |
| 242 | static void setup_tcon(void) |
| 243 | { |
| 244 | setbits_le32(TCON0_BASE_ADDR, (1 << 29)); |
| 245 | } |
| 246 | #endif |
| 247 | |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 248 | static inline int is_colibri_vf61(void) |
| 249 | { |
| 250 | struct mscm *mscm = (struct mscm *)MSCM_BASE_ADDR; |
| 251 | |
| 252 | /* |
| 253 | * Detect board type by Level 2 Cache: VF50 don't have any |
| 254 | * Level 2 Cache. |
| 255 | */ |
| 256 | return !!mscm->cpxcfg1; |
| 257 | } |
| 258 | |
| 259 | static void clock_init(void) |
| 260 | { |
| 261 | struct ccm_reg *ccm = (struct ccm_reg *)CCM_BASE_ADDR; |
| 262 | struct anadig_reg *anadig = (struct anadig_reg *)ANADIG_BASE_ADDR; |
| 263 | u32 pfd_clk_sel, ddr_clk_sel; |
| 264 | |
| 265 | clrsetbits_le32(&ccm->ccgr0, CCM_REG_CTRL_MASK, |
| 266 | CCM_CCGR0_UART0_CTRL_MASK); |
Bhuvanchandra DV | 9f23af3 | 2015-06-01 18:37:20 +0530 | [diff] [blame] | 267 | #ifdef CONFIG_FSL_DSPI |
| 268 | setbits_le32(&ccm->ccgr0, CCM_CCGR0_DSPI1_CTRL_MASK); |
| 269 | #endif |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 270 | clrsetbits_le32(&ccm->ccgr1, CCM_REG_CTRL_MASK, |
| 271 | CCM_CCGR1_PIT_CTRL_MASK | CCM_CCGR1_WDOGA5_CTRL_MASK); |
| 272 | clrsetbits_le32(&ccm->ccgr2, CCM_REG_CTRL_MASK, |
| 273 | CCM_CCGR2_IOMUXC_CTRL_MASK | CCM_CCGR2_PORTA_CTRL_MASK | |
| 274 | CCM_CCGR2_PORTB_CTRL_MASK | CCM_CCGR2_PORTC_CTRL_MASK | |
| 275 | CCM_CCGR2_PORTD_CTRL_MASK | CCM_CCGR2_PORTE_CTRL_MASK); |
| 276 | clrsetbits_le32(&ccm->ccgr3, CCM_REG_CTRL_MASK, |
| 277 | CCM_CCGR3_ANADIG_CTRL_MASK | CCM_CCGR3_SCSC_CTRL_MASK); |
| 278 | clrsetbits_le32(&ccm->ccgr4, CCM_REG_CTRL_MASK, |
| 279 | CCM_CCGR4_WKUP_CTRL_MASK | CCM_CCGR4_CCM_CTRL_MASK | |
Marcel Ziswiler | 510c2dd | 2019-03-25 17:25:01 +0100 | [diff] [blame] | 280 | CCM_CCGR4_GPC_CTRL_MASK); |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 281 | clrsetbits_le32(&ccm->ccgr6, CCM_REG_CTRL_MASK, |
| 282 | CCM_CCGR6_OCOTP_CTRL_MASK | CCM_CCGR6_DDRMC_CTRL_MASK); |
| 283 | clrsetbits_le32(&ccm->ccgr7, CCM_REG_CTRL_MASK, |
| 284 | CCM_CCGR7_SDHC1_CTRL_MASK); |
| 285 | clrsetbits_le32(&ccm->ccgr9, CCM_REG_CTRL_MASK, |
| 286 | CCM_CCGR9_FEC0_CTRL_MASK | CCM_CCGR9_FEC1_CTRL_MASK); |
| 287 | clrsetbits_le32(&ccm->ccgr10, CCM_REG_CTRL_MASK, |
| 288 | CCM_CCGR10_NFC_CTRL_MASK); |
| 289 | |
Stefan Agner | 027efd8 | 2016-11-30 13:41:55 -0800 | [diff] [blame] | 290 | #ifdef CONFIG_USB_EHCI_VF |
Sanchayan Maity | 7755e53 | 2015-04-17 18:56:42 +0530 | [diff] [blame] | 291 | setbits_le32(&ccm->ccgr1, CCM_CCGR1_USBC0_CTRL_MASK); |
Sanchayan Maity | 7755e53 | 2015-04-17 18:56:42 +0530 | [diff] [blame] | 292 | setbits_le32(&ccm->ccgr7, CCM_CCGR7_USBC1_CTRL_MASK); |
Stefan Agner | 027efd8 | 2016-11-30 13:41:55 -0800 | [diff] [blame] | 293 | |
| 294 | clrsetbits_le32(&anadig->pll3_ctrl, ANADIG_PLL3_CTRL_BYPASS | |
| 295 | ANADIG_PLL3_CTRL_POWERDOWN | |
| 296 | ANADIG_PLL3_CTRL_DIV_SELECT, |
| 297 | ANADIG_PLL3_CTRL_ENABLE); |
| 298 | clrsetbits_le32(&anadig->pll7_ctrl, ANADIG_PLL7_CTRL_BYPASS | |
| 299 | ANADIG_PLL7_CTRL_POWERDOWN | |
| 300 | ANADIG_PLL7_CTRL_DIV_SELECT, |
| 301 | ANADIG_PLL7_CTRL_ENABLE); |
Sanchayan Maity | 7755e53 | 2015-04-17 18:56:42 +0530 | [diff] [blame] | 302 | #endif |
| 303 | |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 304 | clrsetbits_le32(&anadig->pll5_ctrl, ANADIG_PLL5_CTRL_BYPASS | |
| 305 | ANADIG_PLL5_CTRL_POWERDOWN, ANADIG_PLL5_CTRL_ENABLE | |
| 306 | ANADIG_PLL5_CTRL_DIV_SELECT); |
| 307 | |
| 308 | if (is_colibri_vf61()) { |
| 309 | clrsetbits_le32(&anadig->pll2_ctrl, ANADIG_PLL5_CTRL_BYPASS | |
| 310 | ANADIG_PLL2_CTRL_POWERDOWN, |
| 311 | ANADIG_PLL2_CTRL_ENABLE | |
| 312 | ANADIG_PLL2_CTRL_DIV_SELECT); |
| 313 | } |
| 314 | |
| 315 | clrsetbits_le32(&anadig->pll1_ctrl, ANADIG_PLL1_CTRL_POWERDOWN, |
| 316 | ANADIG_PLL1_CTRL_ENABLE | ANADIG_PLL1_CTRL_DIV_SELECT); |
| 317 | |
| 318 | clrsetbits_le32(&ccm->ccr, CCM_CCR_OSCNT_MASK, |
| 319 | CCM_CCR_FIRC_EN | CCM_CCR_OSCNT(5)); |
| 320 | |
| 321 | /* See "Typical PLL Configuration" */ |
| 322 | if (is_colibri_vf61()) { |
| 323 | pfd_clk_sel = CCM_CCSR_PLL1_PFD_CLK_SEL(1); |
| 324 | ddr_clk_sel = CCM_CCSR_DDRC_CLK_SEL(0); |
| 325 | } else { |
| 326 | pfd_clk_sel = CCM_CCSR_PLL1_PFD_CLK_SEL(3); |
| 327 | ddr_clk_sel = CCM_CCSR_DDRC_CLK_SEL(1); |
| 328 | } |
| 329 | |
| 330 | clrsetbits_le32(&ccm->ccsr, CCM_REG_CTRL_MASK, pfd_clk_sel | |
| 331 | CCM_CCSR_PLL2_PFD4_EN | CCM_CCSR_PLL2_PFD3_EN | |
| 332 | CCM_CCSR_PLL2_PFD2_EN | CCM_CCSR_PLL2_PFD1_EN | |
| 333 | CCM_CCSR_PLL1_PFD4_EN | CCM_CCSR_PLL1_PFD3_EN | |
| 334 | CCM_CCSR_PLL1_PFD2_EN | CCM_CCSR_PLL1_PFD1_EN | |
| 335 | ddr_clk_sel | CCM_CCSR_FAST_CLK_SEL(1) | |
| 336 | CCM_CCSR_SYS_CLK_SEL(4)); |
| 337 | |
| 338 | clrsetbits_le32(&ccm->cacrr, CCM_REG_CTRL_MASK, |
| 339 | CCM_CACRR_IPG_CLK_DIV(1) | CCM_CACRR_BUS_CLK_DIV(2) | |
| 340 | CCM_CACRR_ARM_CLK_DIV(0)); |
| 341 | clrsetbits_le32(&ccm->cscmr1, CCM_REG_CTRL_MASK, |
| 342 | CCM_CSCMR1_ESDHC1_CLK_SEL(3) | |
| 343 | CCM_CSCMR1_NFC_CLK_SEL(0)); |
| 344 | clrsetbits_le32(&ccm->cscdr1, CCM_REG_CTRL_MASK, |
| 345 | CCM_CSCDR1_RMII_CLK_EN); |
| 346 | clrsetbits_le32(&ccm->cscdr2, CCM_REG_CTRL_MASK, |
| 347 | CCM_CSCDR2_ESDHC1_EN | CCM_CSCDR2_ESDHC1_CLK_DIV(0) | |
| 348 | CCM_CSCDR2_NFC_EN); |
| 349 | clrsetbits_le32(&ccm->cscdr3, CCM_REG_CTRL_MASK, |
Stefan Agner | 0ac1b1c | 2016-11-30 13:41:56 -0800 | [diff] [blame] | 350 | CCM_CSCDR3_NFC_PRE_DIV(3)); |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 351 | clrsetbits_le32(&ccm->cscmr2, CCM_REG_CTRL_MASK, |
| 352 | CCM_CSCMR2_RMII_CLK_SEL(2)); |
Stefan Agner | 1301175 | 2017-04-11 11:12:14 +0530 | [diff] [blame] | 353 | |
| 354 | #ifdef CONFIG_VIDEO_FSL_DCU_FB |
| 355 | setbits_le32(&ccm->ccgr1, CCM_CCGR1_TCON0_CTRL_MASK); |
| 356 | setbits_le32(&ccm->ccgr3, CCM_CCGR3_DCU0_CTRL_MASK); |
| 357 | #endif |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | static void mscm_init(void) |
| 361 | { |
| 362 | struct mscm_ir *mscmir = (struct mscm_ir *)MSCM_IR_BASE_ADDR; |
| 363 | int i; |
| 364 | |
| 365 | for (i = 0; i < MSCM_IRSPRC_NUM; i++) |
| 366 | writew(MSCM_IRSPRC_CP0_EN, &mscmir->irsprc[i]); |
| 367 | } |
| 368 | |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 369 | int board_early_init_f(void) |
| 370 | { |
| 371 | clock_init(); |
| 372 | mscm_init(); |
| 373 | |
Bhuvanchandra DV | 7a27ba6 | 2015-06-01 18:37:17 +0530 | [diff] [blame] | 374 | #ifdef CONFIG_VYBRID_GPIO |
| 375 | setup_iomux_gpio(); |
| 376 | #endif |
| 377 | |
Stefan Agner | 1301175 | 2017-04-11 11:12:14 +0530 | [diff] [blame] | 378 | #ifdef CONFIG_VIDEO_FSL_DCU_FB |
| 379 | setup_tcon(); |
| 380 | setup_iomux_fsl_dcu(); |
| 381 | #endif |
| 382 | |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 383 | return 0; |
| 384 | } |
| 385 | |
| 386 | #ifdef CONFIG_BOARD_LATE_INIT |
| 387 | int board_late_init(void) |
| 388 | { |
| 389 | struct src *src = (struct src *)SRC_BASE_ADDR; |
| 390 | |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 391 | if (((src->sbmr2 & SRC_SBMR2_BMOD_MASK) >> SRC_SBMR2_BMOD_SHIFT) |
| 392 | == SRC_SBMR2_BMOD_SERIAL) { |
| 393 | printf("Serial Downloader recovery mode, disable autoboot\n"); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 394 | env_set("bootdelay", "-1"); |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | return 0; |
| 398 | } |
| 399 | #endif /* CONFIG_BOARD_LATE_INIT */ |
| 400 | |
| 401 | int board_init(void) |
| 402 | { |
| 403 | struct scsc_reg *scsc = (struct scsc_reg *)SCSC_BASE_ADDR; |
| 404 | |
| 405 | /* address of boot parameters */ |
| 406 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 407 | |
| 408 | /* |
| 409 | * Enable external 32K Oscillator |
| 410 | * |
| 411 | * The internal clock experiences significant drift |
| 412 | * so we must use the external oscillator in order |
| 413 | * to maintain correct time in the hwclock |
| 414 | */ |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 415 | setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN); |
| 416 | |
| 417 | return 0; |
| 418 | } |
| 419 | |
| 420 | int checkboard(void) |
| 421 | { |
| 422 | if (is_colibri_vf61()) |
Bhuvanchandra DV | 66d67f8 | 2019-03-25 17:25:05 +0100 | [diff] [blame] | 423 | puts("Model: Toradex Colibri VF61\n"); |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 424 | else |
Bhuvanchandra DV | 66d67f8 | 2019-03-25 17:25:05 +0100 | [diff] [blame] | 425 | puts("Model: Toradex Colibri VF50\n"); |
Sanchayan Maity | cc4d78f | 2015-04-15 16:24:26 +0530 | [diff] [blame] | 426 | |
| 427 | return 0; |
| 428 | } |
Sanchayan Maity | 7755e53 | 2015-04-17 18:56:42 +0530 | [diff] [blame] | 429 | |
Stefan Agner | 98ffd0f | 2016-11-30 13:41:53 -0800 | [diff] [blame] | 430 | #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) |
| 431 | int ft_board_setup(void *blob, bd_t *bd) |
| 432 | { |
Stefan Agner | 1301175 | 2017-04-11 11:12:14 +0530 | [diff] [blame] | 433 | int ret = 0; |
Stefan Agner | 1f8ced9 | 2016-11-30 13:41:54 -0800 | [diff] [blame] | 434 | #ifdef CONFIG_FDT_FIXUP_PARTITIONS |
Masahiro Yamada | 20ead6f | 2018-07-19 16:28:23 +0900 | [diff] [blame] | 435 | static const struct node_info nodes[] = { |
Stefan Agner | 1f8ced9 | 2016-11-30 13:41:54 -0800 | [diff] [blame] | 436 | { "fsl,vf610-nfc", MTD_DEV_TYPE_NAND, }, /* NAND flash */ |
| 437 | }; |
| 438 | |
| 439 | /* Update partition nodes using info from mtdparts env var */ |
| 440 | puts(" Updating MTD partitions...\n"); |
| 441 | fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes)); |
| 442 | #endif |
Stefan Agner | 1301175 | 2017-04-11 11:12:14 +0530 | [diff] [blame] | 443 | #ifdef CONFIG_VIDEO_FSL_DCU_FB |
| 444 | ret = fsl_dcu_fixedfb_setup(blob); |
| 445 | if (ret) |
| 446 | return ret; |
| 447 | #endif |
Stefan Agner | 1f8ced9 | 2016-11-30 13:41:54 -0800 | [diff] [blame] | 448 | |
Stefan Agner | 98ffd0f | 2016-11-30 13:41:53 -0800 | [diff] [blame] | 449 | return ft_common_board_setup(blob, bd); |
| 450 | } |
| 451 | #endif |
| 452 | |
Gerard Salvatella | 108d739 | 2018-11-19 15:54:10 +0100 | [diff] [blame] | 453 | /* |
| 454 | * Backlight off before OS handover |
| 455 | */ |
| 456 | void board_preboot_os(void) |
| 457 | { |
| 458 | gpio_request(PTC0_GPIO_45, "BL_ON"); |
| 459 | gpio_direction_output(PTC0_GPIO_45, 0); |
| 460 | } |