Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016 Amarula Solutions B.V. |
| 4 | * Copyright (C) 2016 Engicam S.r.l. |
| 5 | * Author: Jagan Teki <jagan@amarulasolutions.com> |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Simon Glass | 4d72caa | 2020-05-10 11:40:01 -0600 | [diff] [blame^] | 9 | #include <image.h> |
Simon Glass | b03e051 | 2019-11-14 12:57:24 -0700 | [diff] [blame] | 10 | #include <serial.h> |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 11 | #include <spl.h> |
| 12 | |
| 13 | #include <asm/io.h> |
| 14 | #include <asm/gpio.h> |
| 15 | #include <linux/sizes.h> |
| 16 | |
| 17 | #include <asm/arch/clock.h> |
| 18 | #include <asm/arch/crm_regs.h> |
| 19 | #include <asm/arch/iomux.h> |
| 20 | #include <asm/arch/mx6-ddr.h> |
| 21 | #include <asm/arch/mx6-pins.h> |
| 22 | #include <asm/arch/sys_proto.h> |
| 23 | |
Stefano Babic | 552a848 | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 24 | #include <asm/mach-imx/iomux-v3.h> |
| 25 | #include <asm/mach-imx/video.h> |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 26 | |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 27 | #define UART_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \ |
| 28 | PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \ |
| 29 | PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS) |
| 30 | |
Jagan Teki | a81b0fd | 2017-05-07 02:43:13 +0530 | [diff] [blame] | 31 | static iomux_v3_cfg_t const uart_pads[] = { |
| 32 | #ifdef CONFIG_MX6QDL |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 33 | IOMUX_PADS(PAD_KEY_COL0__UART4_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)), |
| 34 | IOMUX_PADS(PAD_KEY_ROW0__UART4_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)), |
Jagan Teki | a81b0fd | 2017-05-07 02:43:13 +0530 | [diff] [blame] | 35 | #elif CONFIG_MX6UL |
| 36 | IOMUX_PADS(PAD_UART1_TX_DATA__UART1_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL)), |
| 37 | IOMUX_PADS(PAD_UART1_RX_DATA__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL)), |
| 38 | #endif |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 39 | }; |
| 40 | |
Jagan Teki | a1797be | 2017-11-21 00:02:11 +0530 | [diff] [blame] | 41 | #ifdef CONFIG_SPL_LOAD_FIT |
| 42 | int board_fit_config_name_match(const char *name) |
| 43 | { |
| 44 | if (is_mx6dq() && !strcmp(name, "imx6q-icore")) |
| 45 | return 0; |
| 46 | else if (is_mx6dq() && !strcmp(name, "imx6q-icore-rqs")) |
| 47 | return 0; |
Jagan Teki | 82e8ba0 | 2018-06-02 17:25:27 +0530 | [diff] [blame] | 48 | else if (is_mx6dq() && !strcmp(name, "imx6q-icore-mipi")) |
| 49 | return 0; |
Jagan Teki | a1797be | 2017-11-21 00:02:11 +0530 | [diff] [blame] | 50 | else if ((is_mx6dl() || is_mx6solo()) && !strcmp(name, "imx6dl-icore")) |
| 51 | return 0; |
| 52 | else if ((is_mx6dl() || is_mx6solo()) && !strcmp(name, "imx6dl-icore-rqs")) |
| 53 | return 0; |
Jagan Teki | 82e8ba0 | 2018-06-02 17:25:27 +0530 | [diff] [blame] | 54 | else if ((is_mx6dl() || is_mx6solo()) && !strcmp(name, "imx6dl-icore-mipi")) |
| 55 | return 0; |
Jagan Teki | a1797be | 2017-11-21 00:02:11 +0530 | [diff] [blame] | 56 | else |
| 57 | return -1; |
| 58 | } |
| 59 | #endif |
| 60 | |
Jagan Teki | 52aaddd | 2017-11-21 00:02:16 +0530 | [diff] [blame] | 61 | #ifdef CONFIG_ENV_IS_IN_MMC |
| 62 | void board_boot_order(u32 *spl_boot_list) |
| 63 | { |
| 64 | u32 bmode = imx6_src_get_boot_mode(); |
| 65 | u8 boot_dev = BOOT_DEVICE_MMC1; |
| 66 | |
| 67 | switch ((bmode & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) { |
| 68 | case IMX6_BMODE_SD: |
| 69 | case IMX6_BMODE_ESD: |
| 70 | /* SD/eSD - BOOT_DEVICE_MMC1 */ |
| 71 | break; |
| 72 | case IMX6_BMODE_MMC: |
| 73 | case IMX6_BMODE_EMMC: |
| 74 | /* MMC/eMMC */ |
| 75 | boot_dev = BOOT_DEVICE_MMC2; |
| 76 | break; |
| 77 | default: |
| 78 | /* Default - BOOT_DEVICE_MMC1 */ |
| 79 | printf("Wrong board boot order\n"); |
| 80 | break; |
| 81 | } |
| 82 | |
| 83 | spl_boot_list[0] = boot_dev; |
| 84 | } |
| 85 | #endif |
| 86 | |
Jagan Teki | 63af4b0 | 2017-08-28 16:45:48 +0530 | [diff] [blame] | 87 | #ifdef CONFIG_SPL_OS_BOOT |
| 88 | int spl_start_uboot(void) |
| 89 | { |
| 90 | /* break into full u-boot on 'c' */ |
| 91 | if (serial_tstc() && serial_getc() == 'c') |
| 92 | return 1; |
| 93 | |
| 94 | return 0; |
| 95 | } |
| 96 | #endif |
| 97 | |
Jagan Teki | a81b0fd | 2017-05-07 02:43:13 +0530 | [diff] [blame] | 98 | #ifdef CONFIG_MX6QDL |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 99 | /* |
| 100 | * Driving strength: |
| 101 | * 0x30 == 40 Ohm |
| 102 | * 0x28 == 48 Ohm |
| 103 | */ |
| 104 | #define IMX6DQ_DRIVE_STRENGTH 0x30 |
| 105 | #define IMX6SDL_DRIVE_STRENGTH 0x28 |
| 106 | |
| 107 | /* configure MX6Q/DUAL mmdc DDR io registers */ |
| 108 | static struct mx6dq_iomux_ddr_regs mx6dq_ddr_ioregs = { |
| 109 | .dram_sdqs0 = IMX6DQ_DRIVE_STRENGTH, |
| 110 | .dram_sdqs1 = IMX6DQ_DRIVE_STRENGTH, |
| 111 | .dram_sdqs2 = IMX6DQ_DRIVE_STRENGTH, |
| 112 | .dram_sdqs3 = IMX6DQ_DRIVE_STRENGTH, |
| 113 | .dram_sdqs4 = IMX6DQ_DRIVE_STRENGTH, |
| 114 | .dram_sdqs5 = IMX6DQ_DRIVE_STRENGTH, |
| 115 | .dram_sdqs6 = IMX6DQ_DRIVE_STRENGTH, |
| 116 | .dram_sdqs7 = IMX6DQ_DRIVE_STRENGTH, |
| 117 | .dram_dqm0 = IMX6DQ_DRIVE_STRENGTH, |
| 118 | .dram_dqm1 = IMX6DQ_DRIVE_STRENGTH, |
| 119 | .dram_dqm2 = IMX6DQ_DRIVE_STRENGTH, |
| 120 | .dram_dqm3 = IMX6DQ_DRIVE_STRENGTH, |
| 121 | .dram_dqm4 = IMX6DQ_DRIVE_STRENGTH, |
| 122 | .dram_dqm5 = IMX6DQ_DRIVE_STRENGTH, |
| 123 | .dram_dqm6 = IMX6DQ_DRIVE_STRENGTH, |
| 124 | .dram_dqm7 = IMX6DQ_DRIVE_STRENGTH, |
| 125 | .dram_cas = IMX6DQ_DRIVE_STRENGTH, |
| 126 | .dram_ras = IMX6DQ_DRIVE_STRENGTH, |
| 127 | .dram_sdclk_0 = IMX6DQ_DRIVE_STRENGTH, |
| 128 | .dram_sdclk_1 = IMX6DQ_DRIVE_STRENGTH, |
| 129 | .dram_reset = IMX6DQ_DRIVE_STRENGTH, |
| 130 | .dram_sdcke0 = IMX6DQ_DRIVE_STRENGTH, |
| 131 | .dram_sdcke1 = IMX6DQ_DRIVE_STRENGTH, |
| 132 | .dram_sdba2 = 0x00000000, |
| 133 | .dram_sdodt0 = IMX6DQ_DRIVE_STRENGTH, |
| 134 | .dram_sdodt1 = IMX6DQ_DRIVE_STRENGTH, |
| 135 | }; |
| 136 | |
| 137 | /* configure MX6Q/DUAL mmdc GRP io registers */ |
| 138 | static struct mx6dq_iomux_grp_regs mx6dq_grp_ioregs = { |
| 139 | .grp_b0ds = IMX6DQ_DRIVE_STRENGTH, |
| 140 | .grp_b1ds = IMX6DQ_DRIVE_STRENGTH, |
| 141 | .grp_b2ds = IMX6DQ_DRIVE_STRENGTH, |
| 142 | .grp_b3ds = IMX6DQ_DRIVE_STRENGTH, |
| 143 | .grp_b4ds = IMX6DQ_DRIVE_STRENGTH, |
| 144 | .grp_b5ds = IMX6DQ_DRIVE_STRENGTH, |
| 145 | .grp_b6ds = IMX6DQ_DRIVE_STRENGTH, |
| 146 | .grp_b7ds = IMX6DQ_DRIVE_STRENGTH, |
| 147 | .grp_addds = IMX6DQ_DRIVE_STRENGTH, |
| 148 | .grp_ddrmode_ctl = 0x00020000, |
| 149 | .grp_ddrpke = 0x00000000, |
| 150 | .grp_ddrmode = 0x00020000, |
| 151 | .grp_ctlds = IMX6DQ_DRIVE_STRENGTH, |
| 152 | .grp_ddr_type = 0x000c0000, |
| 153 | }; |
| 154 | |
| 155 | /* configure MX6SOLO/DUALLITE mmdc DDR io registers */ |
| 156 | struct mx6sdl_iomux_ddr_regs mx6sdl_ddr_ioregs = { |
| 157 | .dram_sdclk_0 = IMX6SDL_DRIVE_STRENGTH, |
| 158 | .dram_sdclk_1 = IMX6SDL_DRIVE_STRENGTH, |
| 159 | .dram_cas = IMX6SDL_DRIVE_STRENGTH, |
| 160 | .dram_ras = IMX6SDL_DRIVE_STRENGTH, |
| 161 | .dram_reset = IMX6SDL_DRIVE_STRENGTH, |
| 162 | .dram_sdcke0 = IMX6SDL_DRIVE_STRENGTH, |
| 163 | .dram_sdcke1 = IMX6SDL_DRIVE_STRENGTH, |
| 164 | .dram_sdba2 = 0x00000000, |
| 165 | .dram_sdodt0 = IMX6SDL_DRIVE_STRENGTH, |
| 166 | .dram_sdodt1 = IMX6SDL_DRIVE_STRENGTH, |
| 167 | .dram_sdqs0 = IMX6SDL_DRIVE_STRENGTH, |
| 168 | .dram_sdqs1 = IMX6SDL_DRIVE_STRENGTH, |
| 169 | .dram_sdqs2 = IMX6SDL_DRIVE_STRENGTH, |
| 170 | .dram_sdqs3 = IMX6SDL_DRIVE_STRENGTH, |
| 171 | .dram_sdqs4 = IMX6SDL_DRIVE_STRENGTH, |
| 172 | .dram_sdqs5 = IMX6SDL_DRIVE_STRENGTH, |
| 173 | .dram_sdqs6 = IMX6SDL_DRIVE_STRENGTH, |
| 174 | .dram_sdqs7 = IMX6SDL_DRIVE_STRENGTH, |
| 175 | .dram_dqm0 = IMX6SDL_DRIVE_STRENGTH, |
| 176 | .dram_dqm1 = IMX6SDL_DRIVE_STRENGTH, |
| 177 | .dram_dqm2 = IMX6SDL_DRIVE_STRENGTH, |
| 178 | .dram_dqm3 = IMX6SDL_DRIVE_STRENGTH, |
| 179 | .dram_dqm4 = IMX6SDL_DRIVE_STRENGTH, |
| 180 | .dram_dqm5 = IMX6SDL_DRIVE_STRENGTH, |
| 181 | .dram_dqm6 = IMX6SDL_DRIVE_STRENGTH, |
| 182 | .dram_dqm7 = IMX6SDL_DRIVE_STRENGTH, |
| 183 | }; |
| 184 | |
| 185 | /* configure MX6SOLO/DUALLITE mmdc GRP io registers */ |
| 186 | struct mx6sdl_iomux_grp_regs mx6sdl_grp_ioregs = { |
| 187 | .grp_ddr_type = 0x000c0000, |
| 188 | .grp_ddrmode_ctl = 0x00020000, |
| 189 | .grp_ddrpke = 0x00000000, |
| 190 | .grp_addds = IMX6SDL_DRIVE_STRENGTH, |
| 191 | .grp_ctlds = IMX6SDL_DRIVE_STRENGTH, |
| 192 | .grp_ddrmode = 0x00020000, |
| 193 | .grp_b0ds = IMX6SDL_DRIVE_STRENGTH, |
| 194 | .grp_b1ds = IMX6SDL_DRIVE_STRENGTH, |
| 195 | .grp_b2ds = IMX6SDL_DRIVE_STRENGTH, |
| 196 | .grp_b3ds = IMX6SDL_DRIVE_STRENGTH, |
| 197 | .grp_b4ds = IMX6SDL_DRIVE_STRENGTH, |
| 198 | .grp_b5ds = IMX6SDL_DRIVE_STRENGTH, |
| 199 | .grp_b6ds = IMX6SDL_DRIVE_STRENGTH, |
| 200 | .grp_b7ds = IMX6SDL_DRIVE_STRENGTH, |
| 201 | }; |
| 202 | |
| 203 | /* mt41j256 */ |
| 204 | static struct mx6_ddr3_cfg mt41j256 = { |
| 205 | .mem_speed = 1066, |
| 206 | .density = 2, |
| 207 | .width = 16, |
| 208 | .banks = 8, |
| 209 | .rowaddr = 13, |
| 210 | .coladdr = 10, |
| 211 | .pagesz = 2, |
| 212 | .trcd = 1375, |
| 213 | .trcmin = 4875, |
| 214 | .trasmin = 3500, |
| 215 | .SRT = 0, |
| 216 | }; |
| 217 | |
| 218 | static struct mx6_mmdc_calibration mx6dq_mmdc_calib = { |
| 219 | .p0_mpwldectrl0 = 0x000E0009, |
| 220 | .p0_mpwldectrl1 = 0x0018000E, |
| 221 | .p1_mpwldectrl0 = 0x00000007, |
| 222 | .p1_mpwldectrl1 = 0x00000000, |
| 223 | .p0_mpdgctrl0 = 0x43280334, |
| 224 | .p0_mpdgctrl1 = 0x031C0314, |
| 225 | .p1_mpdgctrl0 = 0x4318031C, |
| 226 | .p1_mpdgctrl1 = 0x030C0258, |
| 227 | .p0_mprddlctl = 0x3E343A40, |
| 228 | .p1_mprddlctl = 0x383C3844, |
| 229 | .p0_mpwrdlctl = 0x40404440, |
| 230 | .p1_mpwrdlctl = 0x4C3E4446, |
| 231 | }; |
| 232 | |
| 233 | /* DDR 64bit */ |
| 234 | static struct mx6_ddr_sysinfo mem_q = { |
| 235 | .ddr_type = DDR_TYPE_DDR3, |
| 236 | .dsize = 2, |
| 237 | .cs1_mirror = 0, |
| 238 | /* config for full 4GB range so that get_mem_size() works */ |
| 239 | .cs_density = 32, |
| 240 | .ncs = 1, |
| 241 | .bi_on = 1, |
| 242 | .rtt_nom = 2, |
| 243 | .rtt_wr = 2, |
| 244 | .ralat = 5, |
| 245 | .walat = 0, |
| 246 | .mif3_mode = 3, |
| 247 | .rst_to_cke = 0x23, |
| 248 | .sde_to_rst = 0x10, |
| 249 | }; |
| 250 | |
| 251 | static struct mx6_mmdc_calibration mx6dl_mmdc_calib = { |
| 252 | .p0_mpwldectrl0 = 0x001F0024, |
| 253 | .p0_mpwldectrl1 = 0x00110018, |
| 254 | .p1_mpwldectrl0 = 0x001F0024, |
| 255 | .p1_mpwldectrl1 = 0x00110018, |
| 256 | .p0_mpdgctrl0 = 0x4230022C, |
| 257 | .p0_mpdgctrl1 = 0x02180220, |
| 258 | .p1_mpdgctrl0 = 0x42440248, |
| 259 | .p1_mpdgctrl1 = 0x02300238, |
| 260 | .p0_mprddlctl = 0x44444A48, |
| 261 | .p1_mprddlctl = 0x46484A42, |
| 262 | .p0_mpwrdlctl = 0x38383234, |
| 263 | .p1_mpwrdlctl = 0x3C34362E, |
| 264 | }; |
| 265 | |
| 266 | /* DDR 64bit 1GB */ |
| 267 | static struct mx6_ddr_sysinfo mem_dl = { |
| 268 | .dsize = 2, |
| 269 | .cs1_mirror = 0, |
| 270 | /* config for full 4GB range so that get_mem_size() works */ |
| 271 | .cs_density = 32, |
| 272 | .ncs = 1, |
| 273 | .bi_on = 1, |
| 274 | .rtt_nom = 1, |
| 275 | .rtt_wr = 1, |
| 276 | .ralat = 5, |
| 277 | .walat = 0, |
| 278 | .mif3_mode = 3, |
| 279 | .rst_to_cke = 0x23, |
| 280 | .sde_to_rst = 0x10, |
| 281 | }; |
| 282 | |
| 283 | /* DDR 32bit 512MB */ |
| 284 | static struct mx6_ddr_sysinfo mem_s = { |
| 285 | .dsize = 1, |
| 286 | .cs1_mirror = 0, |
| 287 | /* config for full 4GB range so that get_mem_size() works */ |
| 288 | .cs_density = 32, |
| 289 | .ncs = 1, |
| 290 | .bi_on = 1, |
| 291 | .rtt_nom = 1, |
| 292 | .rtt_wr = 1, |
| 293 | .ralat = 5, |
| 294 | .walat = 0, |
| 295 | .mif3_mode = 3, |
| 296 | .rst_to_cke = 0x23, |
| 297 | .sde_to_rst = 0x10, |
| 298 | }; |
Jagan Teki | a81b0fd | 2017-05-07 02:43:13 +0530 | [diff] [blame] | 299 | #endif /* CONFIG_MX6QDL */ |
| 300 | |
| 301 | #ifdef CONFIG_MX6UL |
| 302 | static struct mx6ul_iomux_grp_regs mx6_grp_ioregs = { |
| 303 | .grp_addds = 0x00000030, |
| 304 | .grp_ddrmode_ctl = 0x00020000, |
| 305 | .grp_b0ds = 0x00000030, |
| 306 | .grp_ctlds = 0x00000030, |
| 307 | .grp_b1ds = 0x00000030, |
| 308 | .grp_ddrpke = 0x00000000, |
| 309 | .grp_ddrmode = 0x00020000, |
| 310 | .grp_ddr_type = 0x000c0000, |
| 311 | }; |
| 312 | |
| 313 | static struct mx6ul_iomux_ddr_regs mx6_ddr_ioregs = { |
| 314 | .dram_dqm0 = 0x00000030, |
| 315 | .dram_dqm1 = 0x00000030, |
| 316 | .dram_ras = 0x00000030, |
| 317 | .dram_cas = 0x00000030, |
| 318 | .dram_odt0 = 0x00000030, |
| 319 | .dram_odt1 = 0x00000030, |
| 320 | .dram_sdba2 = 0x00000000, |
| 321 | .dram_sdclk_0 = 0x00000008, |
| 322 | .dram_sdqs0 = 0x00000038, |
| 323 | .dram_sdqs1 = 0x00000030, |
| 324 | .dram_reset = 0x00000030, |
| 325 | }; |
| 326 | |
| 327 | static struct mx6_mmdc_calibration mx6_mmcd_calib = { |
| 328 | .p0_mpwldectrl0 = 0x00070007, |
| 329 | .p0_mpdgctrl0 = 0x41490145, |
| 330 | .p0_mprddlctl = 0x40404546, |
| 331 | .p0_mpwrdlctl = 0x4040524D, |
| 332 | }; |
| 333 | |
| 334 | struct mx6_ddr_sysinfo ddr_sysinfo = { |
| 335 | .dsize = 0, |
| 336 | .cs_density = 20, |
| 337 | .ncs = 1, |
| 338 | .cs1_mirror = 0, |
| 339 | .rtt_wr = 2, |
| 340 | .rtt_nom = 1, /* RTT_Nom = RZQ/2 */ |
| 341 | .walat = 1, /* Write additional latency */ |
| 342 | .ralat = 5, /* Read additional latency */ |
| 343 | .mif3_mode = 3, /* Command prediction working mode */ |
| 344 | .bi_on = 1, /* Bank interleaving enabled */ |
| 345 | .sde_to_rst = 0x10, /* 14 cycles, 200us (JEDEC default) */ |
| 346 | .rst_to_cke = 0x23, /* 33 cycles, 500us (JEDEC default) */ |
| 347 | .ddr_type = DDR_TYPE_DDR3, |
| 348 | }; |
| 349 | |
| 350 | static struct mx6_ddr3_cfg mem_ddr = { |
| 351 | .mem_speed = 800, |
| 352 | .density = 4, |
| 353 | .width = 16, |
| 354 | .banks = 8, |
| 355 | #ifdef TARGET_MX6UL_ISIOT |
| 356 | .rowaddr = 15, |
| 357 | #else |
| 358 | .rowaddr = 13, |
| 359 | #endif |
| 360 | .coladdr = 10, |
| 361 | .pagesz = 2, |
| 362 | .trcd = 1375, |
| 363 | .trcmin = 4875, |
| 364 | .trasmin = 3500, |
| 365 | }; |
| 366 | #endif /* CONFIG_MX6UL */ |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 367 | |
| 368 | static void ccgr_init(void) |
| 369 | { |
| 370 | struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 371 | |
Jagan Teki | a81b0fd | 2017-05-07 02:43:13 +0530 | [diff] [blame] | 372 | #ifdef CONFIG_MX6QDL |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 373 | writel(0x00003F3F, &ccm->CCGR0); |
| 374 | writel(0x0030FC00, &ccm->CCGR1); |
| 375 | writel(0x000FC000, &ccm->CCGR2); |
| 376 | writel(0x3F300000, &ccm->CCGR3); |
| 377 | writel(0xFF00F300, &ccm->CCGR4); |
| 378 | writel(0x0F0000C3, &ccm->CCGR5); |
| 379 | writel(0x000003CC, &ccm->CCGR6); |
Jagan Teki | a81b0fd | 2017-05-07 02:43:13 +0530 | [diff] [blame] | 380 | #elif CONFIG_MX6UL |
| 381 | writel(0x00c03f3f, &ccm->CCGR0); |
| 382 | writel(0xfcffff00, &ccm->CCGR1); |
| 383 | writel(0x0cffffcc, &ccm->CCGR2); |
| 384 | writel(0x3f3c3030, &ccm->CCGR3); |
| 385 | writel(0xff00fffc, &ccm->CCGR4); |
| 386 | writel(0x033f30ff, &ccm->CCGR5); |
| 387 | writel(0x00c00fff, &ccm->CCGR6); |
| 388 | #endif |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 389 | } |
| 390 | |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 391 | static void spl_dram_init(void) |
| 392 | { |
Jagan Teki | a81b0fd | 2017-05-07 02:43:13 +0530 | [diff] [blame] | 393 | #ifdef CONFIG_MX6QDL |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 394 | if (is_mx6solo()) { |
| 395 | mx6sdl_dram_iocfg(32, &mx6sdl_ddr_ioregs, &mx6sdl_grp_ioregs); |
| 396 | mx6_dram_cfg(&mem_s, &mx6dl_mmdc_calib, &mt41j256); |
| 397 | } else if (is_mx6dl()) { |
| 398 | mx6sdl_dram_iocfg(64, &mx6sdl_ddr_ioregs, &mx6sdl_grp_ioregs); |
| 399 | mx6_dram_cfg(&mem_dl, &mx6dl_mmdc_calib, &mt41j256); |
| 400 | } else if (is_mx6dq()) { |
| 401 | mx6dq_dram_iocfg(64, &mx6dq_ddr_ioregs, &mx6dq_grp_ioregs); |
| 402 | mx6_dram_cfg(&mem_q, &mx6dq_mmdc_calib, &mt41j256); |
| 403 | } |
Jagan Teki | a81b0fd | 2017-05-07 02:43:13 +0530 | [diff] [blame] | 404 | #elif CONFIG_MX6UL |
| 405 | mx6ul_dram_iocfg(mem_ddr.width, &mx6_ddr_ioregs, &mx6_grp_ioregs); |
| 406 | mx6_dram_cfg(&ddr_sysinfo, &mx6_mmcd_calib, &mem_ddr); |
| 407 | #endif |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 408 | |
| 409 | udelay(100); |
| 410 | } |
| 411 | |
| 412 | void board_init_f(ulong dummy) |
| 413 | { |
| 414 | ccgr_init(); |
| 415 | |
| 416 | /* setup AIPS and disable watchdog */ |
| 417 | arch_cpu_init(); |
| 418 | |
Michael Trimarchi | 3058879 | 2018-06-23 16:10:07 +0200 | [diff] [blame] | 419 | if (!(is_mx6ul())) |
| 420 | gpr_init(); |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 421 | |
| 422 | /* iomux */ |
Jagan Teki | a81b0fd | 2017-05-07 02:43:13 +0530 | [diff] [blame] | 423 | SETUP_IOMUX_PADS(uart_pads); |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 424 | |
| 425 | /* setup GP timer */ |
| 426 | timer_init(); |
| 427 | |
| 428 | /* UART clocks enabled and gd valid - init serial console */ |
| 429 | preloader_console_init(); |
| 430 | |
| 431 | /* DDR initialization */ |
| 432 | spl_dram_init(); |
Jagan Teki | d8de3c7 | 2017-05-07 02:43:12 +0530 | [diff] [blame] | 433 | } |