1*83d290c5STom Rini/* SPDX-License-Identifier: GPL-2.0+ */ 2a7f480d9SStefan Roese/* 3a7f480d9SStefan Roese * Copyright (C) 2015-2016 Stefan Roese <sr@denx.de> 4a7f480d9SStefan Roese * 503bf9d58SJagan Teki * Refer doc/README.imximage for more details about how-to configure 6a7f480d9SStefan Roese * and create imximage boot image 7a7f480d9SStefan Roese * 8a7f480d9SStefan Roese * The syntax is taken as close as possible with the kwbimage 9a7f480d9SStefan Roese */ 10a7f480d9SStefan Roese 11a7f480d9SStefan Roese/* image version */ 12a7f480d9SStefan Roese 13a7f480d9SStefan RoeseIMAGE_VERSION 2 14a7f480d9SStefan Roese 15a7f480d9SStefan Roese/* 16a7f480d9SStefan Roese * Boot Device : one of 17a7f480d9SStefan Roese * sd, nand 18a7f480d9SStefan Roese */ 19a7f480d9SStefan RoeseBOOT_FROM sd 20a7f480d9SStefan Roese 21a7f480d9SStefan Roese/* 22a7f480d9SStefan Roese * Device Configuration Data (DCD) 23a7f480d9SStefan Roese * 24a7f480d9SStefan Roese * Each entry must have the format: 25a7f480d9SStefan Roese * Addr-type Address Value 26a7f480d9SStefan Roese * 27a7f480d9SStefan Roese * where: 28a7f480d9SStefan Roese * Addr-type register length (1,2 or 4 bytes) 29a7f480d9SStefan Roese * Address absolute address of the register 30a7f480d9SStefan Roese * value value to be stored in the register 31a7f480d9SStefan Roese */ 32a7f480d9SStefan Roese 33a7f480d9SStefan Roese#define __ASSEMBLY__ 34a7f480d9SStefan Roese#include <config.h> 35a7f480d9SStefan Roese 36a7f480d9SStefan Roese/* Enable all clocks */ 37a7f480d9SStefan RoeseDATA 4 0x020c4068 0xffffffff 38a7f480d9SStefan RoeseDATA 4 0x020c406c 0xffffffff 39a7f480d9SStefan RoeseDATA 4 0x020c4070 0xffffffff 40a7f480d9SStefan RoeseDATA 4 0x020c4074 0xffffffff 41a7f480d9SStefan RoeseDATA 4 0x020c4078 0xffffffff 42a7f480d9SStefan RoeseDATA 4 0x020c407c 0xffffffff 43a7f480d9SStefan RoeseDATA 4 0x020c4080 0xffffffff 44a7f480d9SStefan RoeseDATA 4 0x020c4084 0xffffffff 45a7f480d9SStefan Roese 46a7f480d9SStefan Roese/* ddr io type */ 47a7f480d9SStefan RoeseDATA 4 0x020e04b4 0x000C0000 /* IOMUXC_SW_PAD_CTL_GRP_DDR_TYPE */ 48a7f480d9SStefan RoeseDATA 4 0x020e04ac 0x00000000 /* IOMUXC_SW_PAD_CTL_GRP_DDRPKE */ 49a7f480d9SStefan Roese 50a7f480d9SStefan Roese/* clock */ 51a7f480d9SStefan RoeseDATA 4 0x020e027c 0x00000030 /* IOMUXC_SW_PAD_CTL_PAD_DRAM_SDCLK0_P */ 52a7f480d9SStefan Roese 53a7f480d9SStefan Roese/* control and address */ 54a7f480d9SStefan RoeseDATA 4 0x020E0250 0x00000030 /* IOMUXC_SW_PAD_CTL_PAD_DRAM_CAS */ 55a7f480d9SStefan RoeseDATA 4 0x020E024C 0x00000030 /* IOMUXC_SW_PAD_CTL_PAD_DRAM_RAS */ 56a7f480d9SStefan RoeseDATA 4 0x020E0490 0x00000030 /* IOMUXC_SW_PAD_CTL_GRP_ADDDS */ 57a7f480d9SStefan RoeseDATA 4 0x020E0288 0x00000030 /* IOMUXC_SW_PAD_CTL_PAD_DRAM_RESET */ 58a7f480d9SStefan RoeseDATA 4 0x020E0270 0x00000000 /* IOMUXC_SW_PAD_CTL_PAD_DRAM_SDBA2 - DSE can be 59a7f480d9SStefan Roese configured using Group Control Register: 60a7f480d9SStefan Roese IOMUXC_SW_PAD_CTL_GRP_CTLDS */ 61a7f480d9SStefan RoeseDATA 4 0x020E0260 0x00000030 /* IOMUXC_SW_PAD_CTL_PAD_DRAM_ODT0 */ 62a7f480d9SStefan RoeseDATA 4 0x020E0264 0x00000030 /* IOMUXC_SW_PAD_CTL_PAD_DRAM_ODT1 */ 63a7f480d9SStefan RoeseDATA 4 0x020E04A0 0x00000030 /* IOMUXC_SW_PAD_CTL_GRP_CTLDS */ 64a7f480d9SStefan Roese 65a7f480d9SStefan Roese/* data strobes */ 66a7f480d9SStefan RoeseDATA 4 0x020e0494 0x00020000 /* IOMUXC_SW_PAD_CTL_GRP_DDRMODE_CTL */ 67a7f480d9SStefan RoeseDATA 4 0x020e0280 0x00000030 /* IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS0_P */ 68a7f480d9SStefan RoeseDATA 4 0x020e0284 0x00000030 /* IOMUXC_SW_PAD_CTL_PAD_DRAM_SDQS1_P */ 69a7f480d9SStefan Roese 70a7f480d9SStefan Roese/* data */ 71a7f480d9SStefan RoeseDATA 4 0x020E04B0 0x00020000 /* IOMUXC_SW_PAD_CTL_GRP_DDRMODE */ 72a7f480d9SStefan RoeseDATA 4 0x020E0498 0x00000030 /* IOMUXC_SW_PAD_CTL_GRP_B0DS */ 73a7f480d9SStefan RoeseDATA 4 0x020E04A4 0x00000030 /* IOMUXC_SW_PAD_CTL_GRP_B1DS */ 74a7f480d9SStefan RoeseDATA 4 0x020E0244 0x00000030 /* IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM0 */ 75a7f480d9SStefan RoeseDATA 4 0x020E0248 0x00000030 /* IOMUXC_SW_PAD_CTL_PAD_DRAM_DQM1 */ 76a7f480d9SStefan Roese 77a7f480d9SStefan Roese/* 78a7f480d9SStefan Roese * DDR Controller Registers 79a7f480d9SStefan Roese * 80a7f480d9SStefan Roese * Manufacturer: IM 81a7f480d9SStefan Roese * Device Part Number: IME1G16D3EEBG-15EI 82a7f480d9SStefan Roese * Clock Freq.: 400MHz 83a7f480d9SStefan Roese * Density per CS in Gb: 1 84a7f480d9SStefan Roese * Chip Selects used: 1 85a7f480d9SStefan Roese * Number of Banks: 8 86a7f480d9SStefan Roese * Row address: 13 87a7f480d9SStefan Roese * Column address: 10 88a7f480d9SStefan Roese * Data bus width 16 89a7f480d9SStefan Roese */ 90a7f480d9SStefan RoeseDATA 4 0x021b001c 0x00008000 /* MMDC0_MDSCR, set the Configuration request bit 91a7f480d9SStefan Roese during MMDC set up */ 92a7f480d9SStefan Roese 93a7f480d9SStefan Roese/* 94a7f480d9SStefan Roese * Calibration setup 95a7f480d9SStefan Roese */ 96a7f480d9SStefan RoeseDATA 4 0x021b0800 0xA1390003 /* DDR_PHY_P0_MPZQHWCTRL, enable both one-time & 97a7f480d9SStefan Roese periodic HW ZQ calibration. */ 98a7f480d9SStefan Roese 99a7f480d9SStefan Roese/* 100a7f480d9SStefan Roese * For target board, may need to run write leveling calibration to fine tune 101a7f480d9SStefan Roese * these settings. 102a7f480d9SStefan Roese */ 103a7f480d9SStefan RoeseDATA 4 0x021b080c 0x00000000 104a7f480d9SStefan Roese 105a7f480d9SStefan Roese/* Read DQS Gating calibration */ 106a7f480d9SStefan RoeseDATA 4 0x021b083c 0x4164015C /* MPDGCTRL0 PHY0 */ 107a7f480d9SStefan Roese 108a7f480d9SStefan Roese/* Read calibration */ 109a7f480d9SStefan RoeseDATA 4 0x021b0848 0x40404446 /* MPRDDLCTL PHY0 */ 110a7f480d9SStefan Roese 111a7f480d9SStefan Roese/* Write calibration */ 112a7f480d9SStefan RoeseDATA 4 0x021b0850 0x40405A52 /* MPWRDLCTL PHY0 */ 113a7f480d9SStefan Roese 114a7f480d9SStefan Roese/* 115a7f480d9SStefan Roese * read data bit delay: (3 is the reccommended default value, although out of 116a7f480d9SStefan Roese * reset value is 0) 117a7f480d9SStefan Roese */ 118a7f480d9SStefan RoeseDATA 4 0x021b081c 0x33333333 /* DDR_PHY_P0_MPREDQBY0DL3 */ 119a7f480d9SStefan RoeseDATA 4 0x021b0820 0x33333333 /* DDR_PHY_P0_MPREDQBY1DL3 */ 120a7f480d9SStefan RoeseDATA 4 0x021b082c 0xF3333333 121a7f480d9SStefan RoeseDATA 4 0x021b0830 0xF3333333 122a7f480d9SStefan Roese 123a7f480d9SStefan RoeseDATA 4 0x021b08c0 0x00921012 124a7f480d9SStefan Roese 125a7f480d9SStefan Roese/* Clock Fine Tuning */ 126a7f480d9SStefan RoeseDATA 4 0x021B0858 0x00000F00 /* [MMDC_MPSDCTRL] MMDC PHY CK Control Register */ 127a7f480d9SStefan Roese 128a7f480d9SStefan Roese/* Complete calibration by forced measurement: */ 129a7f480d9SStefan RoeseDATA 4 0x021b08b8 0x00000800 /* DDR_PHY_P0_MPMUR0, frc_msr */ 130a7f480d9SStefan Roese/* 131a7f480d9SStefan Roese * Calibration setup end 132a7f480d9SStefan Roese */ 133a7f480d9SStefan Roese 134a7f480d9SStefan Roese/* MMDC init: */ 135a7f480d9SStefan RoeseDATA 4 0x021b0004 0x0002002D /* MMDC0_MDPDC */ 136a7f480d9SStefan RoeseDATA 4 0x021b0008 0x1B333030 /* MMDC0_MDOTC */ 137a7f480d9SStefan RoeseDATA 4 0x021b000c 0x3F4352F3 /* MMDC0_MDCFG0 */ 138a7f480d9SStefan RoeseDATA 4 0x021b0010 0xB66D0B63 /* MMDC0_MDCFG1 */ 139a7f480d9SStefan RoeseDATA 4 0x021b0014 0x01FF00DB /* MMDC0_MDCFG2 */ 140a7f480d9SStefan Roese 141a7f480d9SStefan Roese/* 142a7f480d9SStefan Roese * MDMISC: RALAT kept to the high level of 5. 143a7f480d9SStefan Roese * MDMISC: consider reducing RALAT if your 528MHz board design allow that. 144a7f480d9SStefan Roese * Lower RALAT benefits: 145a7f480d9SStefan Roese * a. better operation at low frequency, for LPDDR2 freq < 100MHz, change RALAT 146a7f480d9SStefan Roese * to 3 147a7f480d9SStefan Roese * b. Small performence improvment 148a7f480d9SStefan Roese */ 149a7f480d9SStefan RoeseDATA 4 0x021b0018 0x00201740 /* MMDC0_MDMISC */ 150a7f480d9SStefan Roese 151a7f480d9SStefan RoeseDATA 4 0x021b001c 0x00008000 /* MMDC0_MDSCR, set the Configuration request bit 152a7f480d9SStefan Roese during MMDC set up */ 153a7f480d9SStefan Roese 154a7f480d9SStefan RoeseDATA 4 0x021b002c 0x000026D2 /* MMDC0_MDRWD */ 155a7f480d9SStefan RoeseDATA 4 0x021b0030 0x00431023 /* MMDC0_MDOR */ 156a7f480d9SStefan RoeseDATA 4 0x021b0040 0x00000047 /* Chan0 CS0_END */ 157a7f480d9SStefan RoeseDATA 4 0x021b0000 0x82180000 /* MMDC0_MDCTL */ 158a7f480d9SStefan Roese 159a7f480d9SStefan Roese/* Mode register writes */ 160a7f480d9SStefan RoeseDATA 4 0x021b001c 0x02008032 /* MMDC0_MDSCR, MR2 write, CS0 */ 161a7f480d9SStefan RoeseDATA 4 0x021b001c 0x00008033 /* MMDC0_MDSCR, MR3 write, CS0 */ 162a7f480d9SStefan RoeseDATA 4 0x021b001c 0x00048031 /* MMDC0_MDSCR, MR1 write, CS0 */ 163a7f480d9SStefan RoeseDATA 4 0x021b001c 0x15208030 /* MMDC0_MDSCR, MR0 write, CS0 */ 164a7f480d9SStefan RoeseDATA 4 0x021b001c 0x04008040 /* MMDC0_MDSCR, ZQ calibration command sent to 165a7f480d9SStefan Roese device on CS0 */ 166a7f480d9SStefan Roese 167a7f480d9SStefan RoeseDATA 4 0x021b0020 0x00000800 /* MMDC0_MDREF */ 168a7f480d9SStefan RoeseDATA 4 0x021b0818 0x00000227 /* DDR_PHY_P0_MPODTCTRL */ 169a7f480d9SStefan RoeseDATA 4 0x021b0004 0x0002556D /* MMDC0_MDPDC now SDCTL power down enabled */ 170a7f480d9SStefan RoeseDATA 4 0x021b0404 0x00011006 /* MMDC0_MAPSR ADOPT power down enabled, MMDC will 171a7f480d9SStefan Roese enter automatically to self-refresh while the 172a7f480d9SStefan Roese number of idle cycle reached. */ 173a7f480d9SStefan RoeseDATA 4 0x021b001c 0x00000000 /* MMDC0_MDSCR, clear this register (especially 174a7f480d9SStefan Roese the configuration bit as initialization is 175a7f480d9SStefan Roese complete) */ 176