blob: de19a562eb40c84592ec4ebb1d76adf59031749a [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Fabio Estevam7dd65452012-09-24 08:09:33 +00002/*
3 * Copyright (C) 2012 Freescale Semiconductor, Inc.
4 *
5 * Author: Fabio Estevam <fabio.estevam@freescale.com>
Fabio Estevam7dd65452012-09-24 08:09:33 +00006 */
7
8#include <common.h>
Simon Glass52559322019-11-14 12:57:46 -07009#include <init.h>
Fabio Estevam7dd65452012-09-24 08:09:33 +000010#include <asm/io.h>
11#include <asm/arch/clock.h>
12#include <asm/arch/imx-regs.h>
13#include <asm/arch/iomux.h>
Eric Nelsonb47abc32013-11-13 16:36:19 -070014#include <asm/arch/mx6-pins.h>
Simon Glass9fb625c2019-08-01 09:46:51 -060015#include <env.h>
Masahiro Yamada1221ce42016-09-21 11:28:55 +090016#include <linux/errno.h>
Fabio Estevam7dd65452012-09-24 08:09:33 +000017#include <asm/gpio.h>
Stefano Babic552a8482017-06-29 10:16:06 +020018#include <asm/mach-imx/iomux-v3.h>
19#include <asm/mach-imx/mxc_i2c.h>
20#include <asm/mach-imx/boot_mode.h>
21#include <asm/mach-imx/spi.h>
Fabio Estevam7dd65452012-09-24 08:09:33 +000022#include <mmc.h>
Yangbo Lue37ac712019-06-21 11:42:28 +080023#include <fsl_esdhc_imx.h>
Fabio Estevamfe5ebe92012-09-25 08:43:57 +000024#include <miiphy.h>
Fabio Estevamdce67bd2012-10-02 11:20:12 +000025#include <asm/arch/sys_proto.h>
Renato Frias19578162013-05-13 18:01:12 +000026#include <i2c.h>
Diego Dorta7594c512017-09-22 12:12:18 -030027#include <input.h>
Fabio Estevam510922a2014-09-22 13:55:52 -030028#include <asm/arch/mxc_hdmi.h>
Stefano Babic552a8482017-06-29 10:16:06 +020029#include <asm/mach-imx/video.h>
Fabio Estevam510922a2014-09-22 13:55:52 -030030#include <asm/arch/crm_regs.h>
Ye.Li8fe280f2014-10-30 18:53:49 +080031#include <pca953x.h>
Ye.Li593243d2014-11-06 16:29:02 +080032#include <power/pmic.h>
Peng Fan258c98f2015-01-27 10:14:04 +080033#include <power/pfuze100_pmic.h>
Ye.Li593243d2014-11-06 16:29:02 +080034#include "../common/pfuze.h"
Fabio Estevamdce67bd2012-10-02 11:20:12 +000035
Fabio Estevam7dd65452012-09-24 08:09:33 +000036DECLARE_GLOBAL_DATA_PTR;
37
Benoît Thébaudeau7e2173c2013-04-26 01:34:47 +000038#define UART_PAD_CTRL (PAD_CTL_PUS_100K_UP | \
39 PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \
40 PAD_CTL_SRE_FAST | PAD_CTL_HYS)
Fabio Estevam7dd65452012-09-24 08:09:33 +000041
Benoît Thébaudeau7e2173c2013-04-26 01:34:47 +000042#define USDHC_PAD_CTRL (PAD_CTL_PUS_47K_UP | \
43 PAD_CTL_SPEED_LOW | PAD_CTL_DSE_80ohm | \
44 PAD_CTL_SRE_FAST | PAD_CTL_HYS)
Fabio Estevam7dd65452012-09-24 08:09:33 +000045
Benoît Thébaudeau7e2173c2013-04-26 01:34:47 +000046#define ENET_PAD_CTRL (PAD_CTL_PUS_100K_UP | \
47 PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
Fabio Estevamfe5ebe92012-09-25 08:43:57 +000048
Renato Frias19578162013-05-13 18:01:12 +000049#define I2C_PAD_CTRL (PAD_CTL_PUS_100K_UP | \
50 PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \
51 PAD_CTL_ODE | PAD_CTL_SRE_FAST)
52
Ye.Li83bb3212014-11-12 14:02:05 +080053#define GPMI_PAD_CTRL0 (PAD_CTL_PKE | PAD_CTL_PUE | PAD_CTL_PUS_100K_UP)
54#define GPMI_PAD_CTRL1 (PAD_CTL_DSE_40ohm | PAD_CTL_SPEED_MED | \
55 PAD_CTL_SRE_FAST)
56#define GPMI_PAD_CTRL2 (GPMI_PAD_CTRL0 | GPMI_PAD_CTRL1)
57
Renato Frias19578162013-05-13 18:01:12 +000058#define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
59
Fabio Estevamcdbdde32014-11-14 11:27:23 -020060#define WEIM_NOR_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \
61 PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
62 PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
63
Ye.Li593243d2014-11-06 16:29:02 +080064#define I2C_PMIC 1
65
Fabio Estevam7dd65452012-09-24 08:09:33 +000066int dram_init(void)
67{
Vanessa Maegima369012e2016-06-08 15:17:54 -030068 gd->ram_size = imx_ddr_size();
Fabio Estevam7dd65452012-09-24 08:09:33 +000069
70 return 0;
71}
72
Fabio Estevam067a6592014-09-13 18:21:36 -030073static iomux_v3_cfg_t const uart4_pads[] = {
Vanessa Maegima823dff92017-06-29 09:33:45 -030074 IOMUX_PADS(PAD_KEY_COL0__UART4_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
75 IOMUX_PADS(PAD_KEY_ROW0__UART4_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
Fabio Estevam7dd65452012-09-24 08:09:33 +000076};
77
Fabio Estevamfe5ebe92012-09-25 08:43:57 +000078
Renato Frias19578162013-05-13 18:01:12 +000079/* I2C2 PMIC, iPod, Tuner, Codec, Touch, HDMI EDID, MIPI CSI2 card */
Vanessa Maegima823dff92017-06-29 09:33:45 -030080static struct i2c_pads_info mx6q_i2c_pad_info1 = {
Renato Frias19578162013-05-13 18:01:12 +000081 .scl = {
Vanessa Maegima823dff92017-06-29 09:33:45 -030082 .i2c_mode = MX6Q_PAD_EIM_EB2__I2C2_SCL | PC,
83 .gpio_mode = MX6Q_PAD_EIM_EB2__GPIO2_IO30 | PC,
Renato Frias19578162013-05-13 18:01:12 +000084 .gp = IMX_GPIO_NR(2, 30)
85 },
86 .sda = {
Vanessa Maegima823dff92017-06-29 09:33:45 -030087 .i2c_mode = MX6Q_PAD_KEY_ROW3__I2C2_SDA | PC,
88 .gpio_mode = MX6Q_PAD_KEY_ROW3__GPIO4_IO13 | PC,
89 .gp = IMX_GPIO_NR(4, 13)
90 }
91};
92
93static struct i2c_pads_info mx6dl_i2c_pad_info1 = {
94 .scl = {
95 .i2c_mode = MX6DL_PAD_EIM_EB2__I2C2_SCL | PC,
96 .gpio_mode = MX6DL_PAD_EIM_EB2__GPIO2_IO30 | PC,
97 .gp = IMX_GPIO_NR(2, 30)
98 },
99 .sda = {
100 .i2c_mode = MX6DL_PAD_KEY_ROW3__I2C2_SDA | PC,
101 .gpio_mode = MX6DL_PAD_KEY_ROW3__GPIO4_IO13 | PC,
Renato Frias19578162013-05-13 18:01:12 +0000102 .gp = IMX_GPIO_NR(4, 13)
103 }
104};
105
Fabio Estevamcdbdde32014-11-14 11:27:23 -0200106#ifndef CONFIG_SYS_FLASH_CFI
Renato Frias19578162013-05-13 18:01:12 +0000107/*
108 * I2C3 MLB, Port Expanders (A, B, C), Video ADC, Light Sensor,
109 * Compass Sensor, Accelerometer, Res Touch
110 */
Vanessa Maegima823dff92017-06-29 09:33:45 -0300111static struct i2c_pads_info mx6q_i2c_pad_info2 = {
Renato Frias19578162013-05-13 18:01:12 +0000112 .scl = {
Vanessa Maegima823dff92017-06-29 09:33:45 -0300113 .i2c_mode = MX6Q_PAD_GPIO_3__I2C3_SCL | PC,
114 .gpio_mode = MX6Q_PAD_GPIO_3__GPIO1_IO03 | PC,
Renato Frias19578162013-05-13 18:01:12 +0000115 .gp = IMX_GPIO_NR(1, 3)
116 },
117 .sda = {
Vanessa Maegima823dff92017-06-29 09:33:45 -0300118 .i2c_mode = MX6Q_PAD_EIM_D18__I2C3_SDA | PC,
119 .gpio_mode = MX6Q_PAD_EIM_D18__GPIO3_IO18 | PC,
120 .gp = IMX_GPIO_NR(3, 18)
121 }
122};
123
124static struct i2c_pads_info mx6dl_i2c_pad_info2 = {
125 .scl = {
126 .i2c_mode = MX6DL_PAD_GPIO_3__I2C3_SCL | PC,
127 .gpio_mode = MX6DL_PAD_GPIO_3__GPIO1_IO03 | PC,
128 .gp = IMX_GPIO_NR(1, 3)
129 },
130 .sda = {
131 .i2c_mode = MX6DL_PAD_EIM_D18__I2C3_SDA | PC,
132 .gpio_mode = MX6DL_PAD_EIM_D18__GPIO3_IO18 | PC,
Renato Frias19578162013-05-13 18:01:12 +0000133 .gp = IMX_GPIO_NR(3, 18)
134 }
135};
Fabio Estevamcdbdde32014-11-14 11:27:23 -0200136#endif
Renato Frias19578162013-05-13 18:01:12 +0000137
Fabio Estevam067a6592014-09-13 18:21:36 -0300138static iomux_v3_cfg_t const i2c3_pads[] = {
Vanessa Maegima823dff92017-06-29 09:33:45 -0300139 IOMUX_PADS(PAD_EIM_A24__GPIO5_IO04 | MUX_PAD_CTRL(NO_PAD_CTRL)),
Renato Frias19578162013-05-13 18:01:12 +0000140};
141
Fabio Estevam067a6592014-09-13 18:21:36 -0300142static iomux_v3_cfg_t const port_exp[] = {
Vanessa Maegima823dff92017-06-29 09:33:45 -0300143 IOMUX_PADS(PAD_SD2_DAT0__GPIO1_IO15 | MUX_PAD_CTRL(NO_PAD_CTRL)),
Renato Friasa1f67802013-05-13 18:01:13 +0000144};
145
Fabio Estevamca62e5d2017-07-10 15:59:11 -0300146#ifdef CONFIG_MTD_NOR_FLASH
Fabio Estevamcdbdde32014-11-14 11:27:23 -0200147static iomux_v3_cfg_t const eimnor_pads[] = {
Vanessa Maegima823dff92017-06-29 09:33:45 -0300148 IOMUX_PADS(PAD_EIM_D16__EIM_DATA16 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
149 IOMUX_PADS(PAD_EIM_D17__EIM_DATA17 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
150 IOMUX_PADS(PAD_EIM_D18__EIM_DATA18 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
151 IOMUX_PADS(PAD_EIM_D19__EIM_DATA19 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
152 IOMUX_PADS(PAD_EIM_D20__EIM_DATA20 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
153 IOMUX_PADS(PAD_EIM_D21__EIM_DATA21 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
154 IOMUX_PADS(PAD_EIM_D22__EIM_DATA22 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
155 IOMUX_PADS(PAD_EIM_D23__EIM_DATA23 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
156 IOMUX_PADS(PAD_EIM_D24__EIM_DATA24 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
157 IOMUX_PADS(PAD_EIM_D25__EIM_DATA25 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
158 IOMUX_PADS(PAD_EIM_D26__EIM_DATA26 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
159 IOMUX_PADS(PAD_EIM_D27__EIM_DATA27 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
160 IOMUX_PADS(PAD_EIM_D28__EIM_DATA28 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
161 IOMUX_PADS(PAD_EIM_D29__EIM_DATA29 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
162 IOMUX_PADS(PAD_EIM_D30__EIM_DATA30 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
163 IOMUX_PADS(PAD_EIM_D31__EIM_DATA31 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
164 IOMUX_PADS(PAD_EIM_DA0__EIM_AD00 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
165 IOMUX_PADS(PAD_EIM_DA1__EIM_AD01 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
166 IOMUX_PADS(PAD_EIM_DA2__EIM_AD02 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
167 IOMUX_PADS(PAD_EIM_DA3__EIM_AD03 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
168 IOMUX_PADS(PAD_EIM_DA4__EIM_AD04 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
169 IOMUX_PADS(PAD_EIM_DA5__EIM_AD05 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
170 IOMUX_PADS(PAD_EIM_DA6__EIM_AD06 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
171 IOMUX_PADS(PAD_EIM_DA7__EIM_AD07 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
172 IOMUX_PADS(PAD_EIM_DA8__EIM_AD08 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
173 IOMUX_PADS(PAD_EIM_DA9__EIM_AD09 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
174 IOMUX_PADS(PAD_EIM_DA10__EIM_AD10 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
175 IOMUX_PADS(PAD_EIM_DA11__EIM_AD11 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
176 IOMUX_PADS(PAD_EIM_DA12__EIM_AD12 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
177 IOMUX_PADS(PAD_EIM_DA13__EIM_AD13 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
178 IOMUX_PADS(PAD_EIM_DA14__EIM_AD14 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
179 IOMUX_PADS(PAD_EIM_DA15__EIM_AD15 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
180 IOMUX_PADS(PAD_EIM_A16__EIM_ADDR16 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
181 IOMUX_PADS(PAD_EIM_A17__EIM_ADDR17 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
182 IOMUX_PADS(PAD_EIM_A18__EIM_ADDR18 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
183 IOMUX_PADS(PAD_EIM_A19__EIM_ADDR19 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
184 IOMUX_PADS(PAD_EIM_A20__EIM_ADDR20 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
185 IOMUX_PADS(PAD_EIM_A21__EIM_ADDR21 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
186 IOMUX_PADS(PAD_EIM_A22__EIM_ADDR22 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
187 IOMUX_PADS(PAD_EIM_A23__EIM_ADDR23 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
188 IOMUX_PADS(PAD_EIM_OE__EIM_OE_B | MUX_PAD_CTRL(NO_PAD_CTRL)),
189 IOMUX_PADS(PAD_EIM_RW__EIM_RW | MUX_PAD_CTRL(NO_PAD_CTRL)),
190 IOMUX_PADS(PAD_EIM_CS0__EIM_CS0_B | MUX_PAD_CTRL(NO_PAD_CTRL)),
Fabio Estevamcdbdde32014-11-14 11:27:23 -0200191};
192
193static void eimnor_cs_setup(void)
194{
195 struct weim *weim_regs = (struct weim *)WEIM_BASE_ADDR;
196
197 writel(0x00020181, &weim_regs->cs0gcr1);
198 writel(0x00000001, &weim_regs->cs0gcr2);
199 writel(0x0a020000, &weim_regs->cs0rcr1);
200 writel(0x0000c000, &weim_regs->cs0rcr2);
201 writel(0x0804a240, &weim_regs->cs0wcr1);
202 writel(0x00000120, &weim_regs->wcr);
203
204 set_chipselect_size(CS0_128);
205}
206
Fabio Estevamcfb37772016-12-26 23:04:41 -0200207static void eim_clk_setup(void)
208{
209 struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
210 int cscmr1, ccgr6;
211
212
213 /* Turn off EIM clock */
214 ccgr6 = readl(&imx_ccm->CCGR6);
215 ccgr6 &= ~(0x3 << 10);
216 writel(ccgr6, &imx_ccm->CCGR6);
217
218 /*
219 * Configure clk_eim_slow_sel = 00 --> derive clock from AXI clk root
220 * and aclk_eim_slow_podf = 01 --> divide by 2
221 * so that we can have EIM at the maximum clock of 132MHz
222 */
223 cscmr1 = readl(&imx_ccm->cscmr1);
224 cscmr1 &= ~(MXC_CCM_CSCMR1_ACLK_EMI_SLOW_MASK |
225 MXC_CCM_CSCMR1_ACLK_EMI_SLOW_PODF_MASK);
226 cscmr1 |= (1 << MXC_CCM_CSCMR1_ACLK_EMI_SLOW_PODF_OFFSET);
227 writel(cscmr1, &imx_ccm->cscmr1);
228
229 /* Turn on EIM clock */
230 ccgr6 |= (0x3 << 10);
231 writel(ccgr6, &imx_ccm->CCGR6);
232}
233
Fabio Estevamcdbdde32014-11-14 11:27:23 -0200234static void setup_iomux_eimnor(void)
235{
Vanessa Maegima823dff92017-06-29 09:33:45 -0300236 SETUP_IOMUX_PADS(eimnor_pads);
Fabio Estevamcdbdde32014-11-14 11:27:23 -0200237
238 gpio_direction_output(IMX_GPIO_NR(5, 4), 0);
239
240 eimnor_cs_setup();
241}
Fabio Estevamca62e5d2017-07-10 15:59:11 -0300242#endif
Fabio Estevamcdbdde32014-11-14 11:27:23 -0200243
Fabio Estevamfe5ebe92012-09-25 08:43:57 +0000244
Fabio Estevam067a6592014-09-13 18:21:36 -0300245static iomux_v3_cfg_t const usdhc3_pads[] = {
Vanessa Maegima823dff92017-06-29 09:33:45 -0300246 IOMUX_PADS(PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
247 IOMUX_PADS(PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
248 IOMUX_PADS(PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
249 IOMUX_PADS(PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
250 IOMUX_PADS(PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
251 IOMUX_PADS(PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
252 IOMUX_PADS(PAD_SD3_DAT4__SD3_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
253 IOMUX_PADS(PAD_SD3_DAT5__SD3_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
254 IOMUX_PADS(PAD_SD3_DAT6__SD3_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
255 IOMUX_PADS(PAD_SD3_DAT7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
256 IOMUX_PADS(PAD_GPIO_18__SD3_VSELECT | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
257 IOMUX_PADS(PAD_NANDF_CS2__GPIO6_IO15 | MUX_PAD_CTRL(NO_PAD_CTRL)),
Fabio Estevam7dd65452012-09-24 08:09:33 +0000258};
259
260static void setup_iomux_uart(void)
261{
Vanessa Maegima823dff92017-06-29 09:33:45 -0300262 SETUP_IOMUX_PADS(uart4_pads);
Fabio Estevam7dd65452012-09-24 08:09:33 +0000263}
264
Yangbo Lue37ac712019-06-21 11:42:28 +0800265#ifdef CONFIG_FSL_ESDHC_IMX
Fabio Estevam067a6592014-09-13 18:21:36 -0300266static struct fsl_esdhc_cfg usdhc_cfg[1] = {
Fabio Estevam7dd65452012-09-24 08:09:33 +0000267 {USDHC3_BASE_ADDR},
268};
269
270int board_mmc_getcd(struct mmc *mmc)
271{
272 gpio_direction_input(IMX_GPIO_NR(6, 15));
273 return !gpio_get_value(IMX_GPIO_NR(6, 15));
274}
275
276int board_mmc_init(bd_t *bis)
277{
Vanessa Maegima823dff92017-06-29 09:33:45 -0300278 SETUP_IOMUX_PADS(usdhc3_pads);
Fabio Estevam7dd65452012-09-24 08:09:33 +0000279
Benoît Thébaudeaua2ac1b32012-10-01 08:36:25 +0000280 usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
Fabio Estevam7dd65452012-09-24 08:09:33 +0000281 return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
282}
283#endif
284
Ye.Li83bb3212014-11-12 14:02:05 +0800285#ifdef CONFIG_NAND_MXS
286static iomux_v3_cfg_t gpmi_pads[] = {
Vanessa Maegima823dff92017-06-29 09:33:45 -0300287 IOMUX_PADS(PAD_NANDF_CLE__NAND_CLE | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
288 IOMUX_PADS(PAD_NANDF_ALE__NAND_ALE | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
289 IOMUX_PADS(PAD_NANDF_WP_B__NAND_WP_B | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
290 IOMUX_PADS(PAD_NANDF_RB0__NAND_READY_B | MUX_PAD_CTRL(GPMI_PAD_CTRL0)),
291 IOMUX_PADS(PAD_NANDF_CS0__NAND_CE0_B | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
292 IOMUX_PADS(PAD_SD4_CMD__NAND_RE_B | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
293 IOMUX_PADS(PAD_SD4_CLK__NAND_WE_B | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
294 IOMUX_PADS(PAD_NANDF_D0__NAND_DATA00 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
295 IOMUX_PADS(PAD_NANDF_D1__NAND_DATA01 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
296 IOMUX_PADS(PAD_NANDF_D2__NAND_DATA02 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
297 IOMUX_PADS(PAD_NANDF_D3__NAND_DATA03 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
298 IOMUX_PADS(PAD_NANDF_D4__NAND_DATA04 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
299 IOMUX_PADS(PAD_NANDF_D5__NAND_DATA05 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
300 IOMUX_PADS(PAD_NANDF_D6__NAND_DATA06 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
301 IOMUX_PADS(PAD_NANDF_D7__NAND_DATA07 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
302 IOMUX_PADS(PAD_SD4_DAT0__NAND_DQS | MUX_PAD_CTRL(GPMI_PAD_CTRL1)),
Ye.Li83bb3212014-11-12 14:02:05 +0800303};
304
305static void setup_gpmi_nand(void)
306{
307 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
308
309 /* config gpmi nand iomux */
Vanessa Maegima823dff92017-06-29 09:33:45 -0300310 SETUP_IOMUX_PADS(gpmi_pads);
Ye.Li83bb3212014-11-12 14:02:05 +0800311
Ye.Li5f22d882015-01-12 17:37:13 +0800312 setup_gpmi_io_clk((MXC_CCM_CS2CDR_ENFC_CLK_PODF(0) |
Ye.Li83bb3212014-11-12 14:02:05 +0800313 MXC_CCM_CS2CDR_ENFC_CLK_PRED(3) |
Ye.Li5f22d882015-01-12 17:37:13 +0800314 MXC_CCM_CS2CDR_ENFC_CLK_SEL(3)));
Ye.Li83bb3212014-11-12 14:02:05 +0800315
316 /* enable apbh clock gating */
317 setbits_le32(&mxc_ccm->CCGR0, MXC_CCM_CCGR0_APBHDMA_MASK);
318}
319#endif
320
Fabio Estevam7dd65452012-09-24 08:09:33 +0000321u32 get_board_rev(void)
322{
Fabio Estevam4555c262017-11-27 10:25:09 -0200323 int rev = nxp_board_rev();
Fabio Estevamdce67bd2012-10-02 11:20:12 +0000324
325 return (get_cpu_rev() & ~(0xF << 8)) | rev;
Fabio Estevam7dd65452012-09-24 08:09:33 +0000326}
327
Fabio Estevam3f0a1042017-07-12 18:31:45 -0300328static int ar8031_phy_fixup(struct phy_device *phydev)
329{
330 unsigned short val;
331
332 /* To enable AR8031 ouput a 125MHz clk from CLK_25M */
333 phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x7);
334 phy_write(phydev, MDIO_DEVAD_NONE, 0xe, 0x8016);
335 phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x4007);
336
337 val = phy_read(phydev, MDIO_DEVAD_NONE, 0xe);
338 val &= 0xffe3;
339 val |= 0x18;
340 phy_write(phydev, MDIO_DEVAD_NONE, 0xe, val);
341
342 /* introduce tx clock delay */
343 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x5);
344 val = phy_read(phydev, MDIO_DEVAD_NONE, 0x1e);
345 val |= 0x0100;
346 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, val);
347
348 return 0;
349}
350
351int board_phy_config(struct phy_device *phydev)
352{
353 ar8031_phy_fixup(phydev);
354
355 if (phydev->drv->config)
356 phydev->drv->config(phydev);
357
358 return 0;
359}
360
Fabio Estevam510922a2014-09-22 13:55:52 -0300361#if defined(CONFIG_VIDEO_IPUV3)
Peng Fanccf43262015-12-15 16:27:18 +0800362static void disable_lvds(struct display_info_t const *dev)
363{
364 struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
365
366 clrbits_le32(&iomux->gpr[2],
367 IOMUXC_GPR2_LVDS_CH0_MODE_MASK |
368 IOMUXC_GPR2_LVDS_CH1_MODE_MASK);
369}
370
Fabio Estevam510922a2014-09-22 13:55:52 -0300371static void do_enable_hdmi(struct display_info_t const *dev)
372{
Peng Fanccf43262015-12-15 16:27:18 +0800373 disable_lvds(dev);
Fabio Estevam510922a2014-09-22 13:55:52 -0300374 imx_enable_hdmi_phy();
375}
376
377struct display_info_t const displays[] = {{
378 .bus = -1,
379 .addr = 0,
Peng Fanccf43262015-12-15 16:27:18 +0800380 .pixfmt = IPU_PIX_FMT_RGB666,
381 .detect = NULL,
382 .enable = NULL,
383 .mode = {
384 .name = "Hannstar-XGA",
385 .refresh = 60,
386 .xres = 1024,
387 .yres = 768,
388 .pixclock = 15385,
389 .left_margin = 220,
390 .right_margin = 40,
391 .upper_margin = 21,
392 .lower_margin = 7,
393 .hsync_len = 60,
394 .vsync_len = 10,
395 .sync = FB_SYNC_EXT,
396 .vmode = FB_VMODE_NONINTERLACED
397} }, {
398 .bus = -1,
399 .addr = 0,
Fabio Estevam510922a2014-09-22 13:55:52 -0300400 .pixfmt = IPU_PIX_FMT_RGB24,
401 .detect = detect_hdmi,
402 .enable = do_enable_hdmi,
403 .mode = {
404 .name = "HDMI",
405 .refresh = 60,
406 .xres = 1024,
407 .yres = 768,
408 .pixclock = 15385,
409 .left_margin = 220,
410 .right_margin = 40,
411 .upper_margin = 21,
412 .lower_margin = 7,
413 .hsync_len = 60,
414 .vsync_len = 10,
415 .sync = FB_SYNC_EXT,
416 .vmode = FB_VMODE_NONINTERLACED,
417} } };
418size_t display_count = ARRAY_SIZE(displays);
419
Peng Fanccf43262015-12-15 16:27:18 +0800420iomux_v3_cfg_t const backlight_pads[] = {
Vanessa Maegima823dff92017-06-29 09:33:45 -0300421 IOMUX_PADS(PAD_SD4_DAT1__GPIO2_IO09 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
Peng Fanccf43262015-12-15 16:27:18 +0800422};
423
424static void setup_iomux_backlight(void)
425{
Abel Vesa991f2772019-02-01 16:40:19 +0000426 gpio_request(IMX_GPIO_NR(2, 9), "backlight");
Peng Fanccf43262015-12-15 16:27:18 +0800427 gpio_direction_output(IMX_GPIO_NR(2, 9), 1);
Vanessa Maegima823dff92017-06-29 09:33:45 -0300428 SETUP_IOMUX_PADS(backlight_pads);
Peng Fanccf43262015-12-15 16:27:18 +0800429}
430
Fabio Estevam510922a2014-09-22 13:55:52 -0300431static void setup_display(void)
432{
433 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
Peng Fanccf43262015-12-15 16:27:18 +0800434 struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
Fabio Estevam510922a2014-09-22 13:55:52 -0300435 int reg;
436
Peng Fanccf43262015-12-15 16:27:18 +0800437 setup_iomux_backlight();
Fabio Estevam510922a2014-09-22 13:55:52 -0300438 enable_ipu_clock();
439 imx_setup_hdmi();
440
Peng Fanccf43262015-12-15 16:27:18 +0800441 /* Turn on LDB_DI0 and LDB_DI1 clocks */
442 reg = readl(&mxc_ccm->CCGR3);
443 reg |= MXC_CCM_CCGR3_LDB_DI0_MASK | MXC_CCM_CCGR3_LDB_DI1_MASK;
444 writel(reg, &mxc_ccm->CCGR3);
445
446 /* Set LDB_DI0 and LDB_DI1 clk select to 3b'011 */
447 reg = readl(&mxc_ccm->cs2cdr);
448 reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK |
449 MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK);
450 reg |= (3 << MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET) |
451 (3 << MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET);
452 writel(reg, &mxc_ccm->cs2cdr);
453
454 reg = readl(&mxc_ccm->cscmr2);
455 reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV | MXC_CCM_CSCMR2_LDB_DI1_IPU_DIV;
456 writel(reg, &mxc_ccm->cscmr2);
457
Fabio Estevam510922a2014-09-22 13:55:52 -0300458 reg = readl(&mxc_ccm->chsccdr);
459 reg |= (CHSCCDR_CLK_SEL_LDB_DI0
460 << MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET);
Peng Fanccf43262015-12-15 16:27:18 +0800461 reg |= (CHSCCDR_CLK_SEL_LDB_DI0 <<
462 MXC_CCM_CHSCCDR_IPU1_DI1_CLK_SEL_OFFSET);
Fabio Estevam510922a2014-09-22 13:55:52 -0300463 writel(reg, &mxc_ccm->chsccdr);
Peng Fanccf43262015-12-15 16:27:18 +0800464
465 reg = IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_LOW |
466 IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_LOW |
467 IOMUXC_GPR2_BIT_MAPPING_CH1_SPWG |
468 IOMUXC_GPR2_DATA_WIDTH_CH1_18BIT |
469 IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG |
470 IOMUXC_GPR2_DATA_WIDTH_CH0_18BIT |
471 IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0 |
472 IOMUXC_GPR2_LVDS_CH1_MODE_DISABLED;
473 writel(reg, &iomux->gpr[2]);
474
475 reg = readl(&iomux->gpr[3]);
476 reg &= ~(IOMUXC_GPR3_LVDS0_MUX_CTL_MASK |
477 IOMUXC_GPR3_HDMI_MUX_CTL_MASK);
478 reg |= (IOMUXC_GPR3_MUX_SRC_IPU1_DI0 <<
479 IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET) |
480 (IOMUXC_GPR3_MUX_SRC_IPU1_DI0 <<
481 IOMUXC_GPR3_HDMI_MUX_CTL_OFFSET);
482 writel(reg, &iomux->gpr[3]);
Fabio Estevam510922a2014-09-22 13:55:52 -0300483}
484#endif /* CONFIG_VIDEO_IPUV3 */
485
486/*
487 * Do not overwrite the console
488 * Use always serial for U-Boot console
489 */
490int overwrite_console(void)
491{
492 return 1;
493}
494
Fabio Estevam7dd65452012-09-24 08:09:33 +0000495int board_early_init_f(void)
496{
497 setup_iomux_uart();
Ye.Li83bb3212014-11-12 14:02:05 +0800498
499#ifdef CONFIG_NAND_MXS
500 setup_gpmi_nand();
501#endif
Fabio Estevamcdbdde32014-11-14 11:27:23 -0200502
Fabio Estevamca62e5d2017-07-10 15:59:11 -0300503#ifdef CONFIG_MTD_NOR_FLASH
504 eim_clk_setup();
505#endif
Fabio Estevam7dd65452012-09-24 08:09:33 +0000506 return 0;
507}
508
509int board_init(void)
510{
511 /* address of boot parameters */
512 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
513
Renato Frias19578162013-05-13 18:01:12 +0000514 /* I2C 2 and 3 setup - I2C 3 hw mux with EIM */
Vanessa Maegima823dff92017-06-29 09:33:45 -0300515 if (is_mx6dq() || is_mx6dqp())
516 setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6q_i2c_pad_info1);
517 else
518 setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6dl_i2c_pad_info1);
Renato Frias19578162013-05-13 18:01:12 +0000519 /* I2C 3 Steer */
Abel Vesa991f2772019-02-01 16:40:19 +0000520 gpio_request(IMX_GPIO_NR(5, 4), "steer logic");
Renato Frias19578162013-05-13 18:01:12 +0000521 gpio_direction_output(IMX_GPIO_NR(5, 4), 1);
Vanessa Maegima823dff92017-06-29 09:33:45 -0300522 SETUP_IOMUX_PADS(i2c3_pads);
Fabio Estevamcdbdde32014-11-14 11:27:23 -0200523#ifndef CONFIG_SYS_FLASH_CFI
Vanessa Maegima823dff92017-06-29 09:33:45 -0300524 if (is_mx6dq() || is_mx6dqp())
525 setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6q_i2c_pad_info2);
526 else
527 setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6dl_i2c_pad_info2);
Fabio Estevamcdbdde32014-11-14 11:27:23 -0200528#endif
Abel Vesa991f2772019-02-01 16:40:19 +0000529 gpio_request(IMX_GPIO_NR(1, 15), "expander en");
Renato Friasa1f67802013-05-13 18:01:13 +0000530 gpio_direction_output(IMX_GPIO_NR(1, 15), 1);
Vanessa Maegima823dff92017-06-29 09:33:45 -0300531 SETUP_IOMUX_PADS(port_exp);
Renato Friasa1f67802013-05-13 18:01:13 +0000532
Peng Fanccf43262015-12-15 16:27:18 +0800533#ifdef CONFIG_VIDEO_IPUV3
534 setup_display();
535#endif
Fabio Estevamca62e5d2017-07-10 15:59:11 -0300536
537#ifdef CONFIG_MTD_NOR_FLASH
Fabio Estevamcdbdde32014-11-14 11:27:23 -0200538 setup_iomux_eimnor();
Fabio Estevamca62e5d2017-07-10 15:59:11 -0300539#endif
Fabio Estevam7dd65452012-09-24 08:09:33 +0000540 return 0;
541}
542
Nikita Kiryanov155fa9a2014-08-20 15:08:50 +0300543#ifdef CONFIG_MXC_SPI
544int board_spi_cs_gpio(unsigned bus, unsigned cs)
545{
546 return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(4, 9)) : -1;
547}
548#endif
549
Ye.Li593243d2014-11-06 16:29:02 +0800550int power_init_board(void)
551{
552 struct pmic *p;
Peng Fan361b7152015-07-11 11:38:47 +0800553 unsigned int value;
Ye.Li593243d2014-11-06 16:29:02 +0800554
555 p = pfuze_common_init(I2C_PMIC);
556 if (!p)
557 return -ENODEV;
558
Peng Fan361b7152015-07-11 11:38:47 +0800559 if (is_mx6dqp()) {
560 /* set SW2 staby volatage 0.975V*/
561 pmic_reg_read(p, PFUZE100_SW2STBY, &value);
562 value &= ~0x3f;
563 value |= 0x17;
564 pmic_reg_write(p, PFUZE100_SW2STBY, value);
565 }
Peng Fan258c98f2015-01-27 10:14:04 +0800566
Peng Fan361b7152015-07-11 11:38:47 +0800567 return pfuze_mode_init(p, APS_PFM);
Ye.Li593243d2014-11-06 16:29:02 +0800568}
569
Otavio Salvador85449db2013-03-16 08:05:07 +0000570#ifdef CONFIG_CMD_BMODE
571static const struct boot_mode board_boot_modes[] = {
572 /* 4 bit bus width */
573 {"mmc0", MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)},
574 {NULL, 0},
575};
576#endif
577
578int board_late_init(void)
579{
580#ifdef CONFIG_CMD_BMODE
581 add_board_boot_modes(board_boot_modes);
582#endif
583
Peng Fane6fc8992015-07-11 11:38:46 +0800584#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
Simon Glass382bee52017-08-03 12:22:09 -0600585 env_set("board_name", "SABREAUTO");
Peng Fane6fc8992015-07-11 11:38:46 +0800586
Peng Fan361b7152015-07-11 11:38:47 +0800587 if (is_mx6dqp())
Simon Glass382bee52017-08-03 12:22:09 -0600588 env_set("board_rev", "MX6QP");
Peng Fan83e13942016-05-23 18:36:06 +0800589 else if (is_mx6dq())
Simon Glass382bee52017-08-03 12:22:09 -0600590 env_set("board_rev", "MX6Q");
Peng Fan83e13942016-05-23 18:36:06 +0800591 else if (is_mx6sdl())
Simon Glass382bee52017-08-03 12:22:09 -0600592 env_set("board_rev", "MX6DL");
Peng Fane6fc8992015-07-11 11:38:46 +0800593#endif
594
Otavio Salvador85449db2013-03-16 08:05:07 +0000595 return 0;
596}
597
Fabio Estevam7dd65452012-09-24 08:09:33 +0000598int checkboard(void)
599{
Fabio Estevam4555c262017-11-27 10:25:09 -0200600 printf("Board: MX6Q-Sabreauto rev%c\n", nxp_board_rev_string());
Fabio Estevam7dd65452012-09-24 08:09:33 +0000601
602 return 0;
603}
Ye.Li8fe280f2014-10-30 18:53:49 +0800604
605#ifdef CONFIG_USB_EHCI_MX6
Ye.Li8fe280f2014-10-30 18:53:49 +0800606int board_ehci_hcd_init(int port)
607{
608 switch (port) {
609 case 0:
Ye.Li8fe280f2014-10-30 18:53:49 +0800610 /*
611 * Set daisy chain for otg_pin_id on 6q.
612 * For 6dl, this bit is reserved.
613 */
614 imx_iomux_set_gpr_register(1, 13, 1, 0);
615 break;
616 case 1:
617 break;
618 default:
619 printf("MXC USB port %d not yet supported\n", port);
620 return -EINVAL;
621 }
622 return 0;
623}
Ye.Li8fe280f2014-10-30 18:53:49 +0800624#endif
Vanessa Maegima823dff92017-06-29 09:33:45 -0300625
626#ifdef CONFIG_SPL_BUILD
627#include <asm/arch/mx6-ddr.h>
628#include <spl.h>
Masahiro Yamadab08c8c42018-03-05 01:20:11 +0900629#include <linux/libfdt.h>
Vanessa Maegima823dff92017-06-29 09:33:45 -0300630
Diego Dorta07f6ddb2017-07-07 15:38:34 -0300631#ifdef CONFIG_SPL_OS_BOOT
632int spl_start_uboot(void)
633{
634 return 0;
635}
636#endif
637
Vanessa Maegima823dff92017-06-29 09:33:45 -0300638static void ccgr_init(void)
639{
640 struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
641
642 writel(0x00C03F3F, &ccm->CCGR0);
643 writel(0x0030FC03, &ccm->CCGR1);
644 writel(0x0FFFC000, &ccm->CCGR2);
645 writel(0x3FF00000, &ccm->CCGR3);
646 writel(0x00FFF300, &ccm->CCGR4);
647 writel(0x0F0000C3, &ccm->CCGR5);
648 writel(0x000003FF, &ccm->CCGR6);
649}
650
Vanessa Maegima823dff92017-06-29 09:33:45 -0300651static int mx6q_dcd_table[] = {
652 0x020e0798, 0x000C0000,
653 0x020e0758, 0x00000000,
654 0x020e0588, 0x00000030,
655 0x020e0594, 0x00000030,
656 0x020e056c, 0x00000030,
657 0x020e0578, 0x00000030,
658 0x020e074c, 0x00000030,
659 0x020e057c, 0x00000030,
660 0x020e058c, 0x00000000,
661 0x020e059c, 0x00000030,
662 0x020e05a0, 0x00000030,
663 0x020e078c, 0x00000030,
664 0x020e0750, 0x00020000,
665 0x020e05a8, 0x00000028,
666 0x020e05b0, 0x00000028,
667 0x020e0524, 0x00000028,
668 0x020e051c, 0x00000028,
669 0x020e0518, 0x00000028,
670 0x020e050c, 0x00000028,
671 0x020e05b8, 0x00000028,
672 0x020e05c0, 0x00000028,
673 0x020e0774, 0x00020000,
674 0x020e0784, 0x00000028,
675 0x020e0788, 0x00000028,
676 0x020e0794, 0x00000028,
677 0x020e079c, 0x00000028,
678 0x020e07a0, 0x00000028,
679 0x020e07a4, 0x00000028,
680 0x020e07a8, 0x00000028,
681 0x020e0748, 0x00000028,
682 0x020e05ac, 0x00000028,
683 0x020e05b4, 0x00000028,
684 0x020e0528, 0x00000028,
685 0x020e0520, 0x00000028,
686 0x020e0514, 0x00000028,
687 0x020e0510, 0x00000028,
688 0x020e05bc, 0x00000028,
689 0x020e05c4, 0x00000028,
690 0x021b0800, 0xa1390003,
691 0x021b080c, 0x001F001F,
692 0x021b0810, 0x001F001F,
693 0x021b480c, 0x001F001F,
694 0x021b4810, 0x001F001F,
695 0x021b083c, 0x43260335,
696 0x021b0840, 0x031A030B,
697 0x021b483c, 0x4323033B,
698 0x021b4840, 0x0323026F,
699 0x021b0848, 0x483D4545,
700 0x021b4848, 0x44433E48,
701 0x021b0850, 0x41444840,
702 0x021b4850, 0x4835483E,
703 0x021b081c, 0x33333333,
704 0x021b0820, 0x33333333,
705 0x021b0824, 0x33333333,
706 0x021b0828, 0x33333333,
707 0x021b481c, 0x33333333,
708 0x021b4820, 0x33333333,
709 0x021b4824, 0x33333333,
710 0x021b4828, 0x33333333,
711 0x021b08b8, 0x00000800,
712 0x021b48b8, 0x00000800,
713 0x021b0004, 0x00020036,
714 0x021b0008, 0x09444040,
715 0x021b000c, 0x8A8F7955,
716 0x021b0010, 0xFF328F64,
717 0x021b0014, 0x01FF00DB,
718 0x021b0018, 0x00001740,
719 0x021b001c, 0x00008000,
720 0x021b002c, 0x000026d2,
721 0x021b0030, 0x008F1023,
722 0x021b0040, 0x00000047,
723 0x021b0000, 0x841A0000,
724 0x021b001c, 0x04088032,
725 0x021b001c, 0x00008033,
726 0x021b001c, 0x00048031,
727 0x021b001c, 0x09408030,
728 0x021b001c, 0x04008040,
729 0x021b0020, 0x00005800,
730 0x021b0818, 0x00011117,
731 0x021b4818, 0x00011117,
732 0x021b0004, 0x00025576,
733 0x021b0404, 0x00011006,
734 0x021b001c, 0x00000000,
735 0x020c4068, 0x00C03F3F,
736 0x020c406c, 0x0030FC03,
737 0x020c4070, 0x0FFFC000,
738 0x020c4074, 0x3FF00000,
739 0x020c4078, 0xFFFFF300,
740 0x020c407c, 0x0F0000F3,
741 0x020c4080, 0x00000FFF,
742 0x020e0010, 0xF00000CF,
743 0x020e0018, 0x007F007F,
744 0x020e001c, 0x007F007F,
745};
746
747static int mx6qp_dcd_table[] = {
748 0x020e0798, 0x000C0000,
749 0x020e0758, 0x00000000,
750 0x020e0588, 0x00000030,
751 0x020e0594, 0x00000030,
752 0x020e056c, 0x00000030,
753 0x020e0578, 0x00000030,
754 0x020e074c, 0x00000030,
755 0x020e057c, 0x00000030,
756 0x020e058c, 0x00000000,
757 0x020e059c, 0x00000030,
758 0x020e05a0, 0x00000030,
759 0x020e078c, 0x00000030,
760 0x020e0750, 0x00020000,
761 0x020e05a8, 0x00000030,
762 0x020e05b0, 0x00000030,
763 0x020e0524, 0x00000030,
764 0x020e051c, 0x00000030,
765 0x020e0518, 0x00000030,
766 0x020e050c, 0x00000030,
767 0x020e05b8, 0x00000030,
768 0x020e05c0, 0x00000030,
769 0x020e0774, 0x00020000,
770 0x020e0784, 0x00000030,
771 0x020e0788, 0x00000030,
772 0x020e0794, 0x00000030,
773 0x020e079c, 0x00000030,
774 0x020e07a0, 0x00000030,
775 0x020e07a4, 0x00000030,
776 0x020e07a8, 0x00000030,
777 0x020e0748, 0x00000030,
778 0x020e05ac, 0x00000030,
779 0x020e05b4, 0x00000030,
780 0x020e0528, 0x00000030,
781 0x020e0520, 0x00000030,
782 0x020e0514, 0x00000030,
783 0x020e0510, 0x00000030,
784 0x020e05bc, 0x00000030,
785 0x020e05c4, 0x00000030,
786 0x021b0800, 0xa1390003,
787 0x021b080c, 0x001b001e,
788 0x021b0810, 0x002e0029,
789 0x021b480c, 0x001b002a,
790 0x021b4810, 0x0019002c,
791 0x021b083c, 0x43240334,
792 0x021b0840, 0x0324031a,
793 0x021b483c, 0x43340344,
794 0x021b4840, 0x03280276,
795 0x021b0848, 0x44383A3E,
796 0x021b4848, 0x3C3C3846,
797 0x021b0850, 0x2e303230,
798 0x021b4850, 0x38283E34,
799 0x021b081c, 0x33333333,
800 0x021b0820, 0x33333333,
801 0x021b0824, 0x33333333,
802 0x021b0828, 0x33333333,
803 0x021b481c, 0x33333333,
804 0x021b4820, 0x33333333,
805 0x021b4824, 0x33333333,
806 0x021b4828, 0x33333333,
807 0x021b08c0, 0x24912492,
808 0x021b48c0, 0x24912492,
809 0x021b08b8, 0x00000800,
810 0x021b48b8, 0x00000800,
811 0x021b0004, 0x00020036,
812 0x021b0008, 0x09444040,
813 0x021b000c, 0x898E7955,
814 0x021b0010, 0xFF328F64,
815 0x021b0014, 0x01FF00DB,
816 0x021b0018, 0x00001740,
817 0x021b001c, 0x00008000,
818 0x021b002c, 0x000026d2,
819 0x021b0030, 0x008E1023,
820 0x021b0040, 0x00000047,
821 0x021b0400, 0x14420000,
822 0x021b0000, 0x841A0000,
823 0x00bb0008, 0x00000004,
824 0x00bb000c, 0x2891E41A,
825 0x00bb0038, 0x00000564,
826 0x00bb0014, 0x00000040,
827 0x00bb0028, 0x00000020,
828 0x00bb002c, 0x00000020,
829 0x021b001c, 0x04088032,
830 0x021b001c, 0x00008033,
831 0x021b001c, 0x00048031,
832 0x021b001c, 0x09408030,
833 0x021b001c, 0x04008040,
834 0x021b0020, 0x00005800,
835 0x021b0818, 0x00011117,
836 0x021b4818, 0x00011117,
837 0x021b0004, 0x00025576,
838 0x021b0404, 0x00011006,
839 0x021b001c, 0x00000000,
840 0x020c4068, 0x00C03F3F,
841 0x020c406c, 0x0030FC03,
842 0x020c4070, 0x0FFFC000,
843 0x020c4074, 0x3FF00000,
844 0x020c4078, 0xFFFFF300,
845 0x020c407c, 0x0F0000F3,
846 0x020c4080, 0x00000FFF,
847 0x020e0010, 0xF00000CF,
848 0x020e0018, 0x77177717,
849 0x020e001c, 0x77177717,
850};
851
852static int mx6dl_dcd_table[] = {
853 0x020e0774, 0x000C0000,
854 0x020e0754, 0x00000000,
855 0x020e04ac, 0x00000030,
856 0x020e04b0, 0x00000030,
857 0x020e0464, 0x00000030,
858 0x020e0490, 0x00000030,
859 0x020e074c, 0x00000030,
860 0x020e0494, 0x00000030,
861 0x020e04a0, 0x00000000,
862 0x020e04b4, 0x00000030,
863 0x020e04b8, 0x00000030,
864 0x020e076c, 0x00000030,
865 0x020e0750, 0x00020000,
866 0x020e04bc, 0x00000028,
867 0x020e04c0, 0x00000028,
868 0x020e04c4, 0x00000028,
869 0x020e04c8, 0x00000028,
870 0x020e04cc, 0x00000028,
871 0x020e04d0, 0x00000028,
872 0x020e04d4, 0x00000028,
873 0x020e04d8, 0x00000028,
874 0x020e0760, 0x00020000,
875 0x020e0764, 0x00000028,
876 0x020e0770, 0x00000028,
877 0x020e0778, 0x00000028,
878 0x020e077c, 0x00000028,
879 0x020e0780, 0x00000028,
880 0x020e0784, 0x00000028,
881 0x020e078c, 0x00000028,
882 0x020e0748, 0x00000028,
883 0x020e0470, 0x00000028,
884 0x020e0474, 0x00000028,
885 0x020e0478, 0x00000028,
886 0x020e047c, 0x00000028,
887 0x020e0480, 0x00000028,
888 0x020e0484, 0x00000028,
889 0x020e0488, 0x00000028,
890 0x020e048c, 0x00000028,
891 0x021b0800, 0xa1390003,
892 0x021b080c, 0x001F001F,
893 0x021b0810, 0x001F001F,
894 0x021b480c, 0x001F001F,
895 0x021b4810, 0x001F001F,
896 0x021b083c, 0x42190217,
897 0x021b0840, 0x017B017B,
898 0x021b483c, 0x4176017B,
899 0x021b4840, 0x015F016C,
900 0x021b0848, 0x4C4C4D4C,
901 0x021b4848, 0x4A4D4C48,
902 0x021b0850, 0x3F3F3F40,
903 0x021b4850, 0x3538382E,
904 0x021b081c, 0x33333333,
905 0x021b0820, 0x33333333,
906 0x021b0824, 0x33333333,
907 0x021b0828, 0x33333333,
908 0x021b481c, 0x33333333,
909 0x021b4820, 0x33333333,
910 0x021b4824, 0x33333333,
911 0x021b4828, 0x33333333,
912 0x021b08b8, 0x00000800,
913 0x021b48b8, 0x00000800,
914 0x021b0004, 0x00020025,
915 0x021b0008, 0x00333030,
916 0x021b000c, 0x676B5313,
917 0x021b0010, 0xB66E8B63,
918 0x021b0014, 0x01FF00DB,
919 0x021b0018, 0x00001740,
920 0x021b001c, 0x00008000,
921 0x021b002c, 0x000026d2,
922 0x021b0030, 0x006B1023,
923 0x021b0040, 0x00000047,
924 0x021b0000, 0x841A0000,
925 0x021b001c, 0x04008032,
926 0x021b001c, 0x00008033,
927 0x021b001c, 0x00048031,
928 0x021b001c, 0x05208030,
929 0x021b001c, 0x04008040,
930 0x021b0020, 0x00005800,
931 0x021b0818, 0x00011117,
932 0x021b4818, 0x00011117,
933 0x021b0004, 0x00025565,
934 0x021b0404, 0x00011006,
935 0x021b001c, 0x00000000,
936 0x020c4068, 0x00C03F3F,
937 0x020c406c, 0x0030FC03,
938 0x020c4070, 0x0FFFC000,
939 0x020c4074, 0x3FF00000,
940 0x020c4078, 0xFFFFF300,
941 0x020c407c, 0x0F0000C3,
942 0x020c4080, 0x00000FFF,
943 0x020e0010, 0xF00000CF,
944 0x020e0018, 0x007F007F,
945 0x020e001c, 0x007F007F,
946};
947
948static void ddr_init(int *table, int size)
949{
950 int i;
951
952 for (i = 0; i < size / 2 ; i++)
953 writel(table[2 * i + 1], table[2 * i]);
954}
955
956static void spl_dram_init(void)
957{
958 if (is_mx6dq())
959 ddr_init(mx6q_dcd_table, ARRAY_SIZE(mx6q_dcd_table));
960 else if (is_mx6dqp())
961 ddr_init(mx6qp_dcd_table, ARRAY_SIZE(mx6qp_dcd_table));
962 else if (is_mx6sdl())
963 ddr_init(mx6dl_dcd_table, ARRAY_SIZE(mx6dl_dcd_table));
964}
965
966void board_init_f(ulong dummy)
967{
968 /* DDR initialization */
969 spl_dram_init();
970
971 /* setup AIPS and disable watchdog */
972 arch_cpu_init();
973
974 ccgr_init();
975 gpr_init();
976
977 /* iomux and setup of i2c */
978 board_early_init_f();
979
980 /* setup GP timer */
981 timer_init();
982
983 /* UART clocks enabled and gd valid - init serial console */
984 preloader_console_init();
985
986 /* Clear the BSS. */
987 memset(__bss_start, 0, __bss_end - __bss_start);
988
989 /* load/boot image from boot device */
990 board_init_r(NULL, 0);
991}
992#endif
Abel Vesa90571a42019-02-01 16:40:13 +0000993
994#ifdef CONFIG_SPL_LOAD_FIT
995int board_fit_config_name_match(const char *name)
996{
997 if (is_mx6dq()) {
998 if (!strcmp(name, "imx6q-sabreauto"))
999 return 0;
1000 } else if (is_mx6dqp()) {
1001 if (!strcmp(name, "imx6qp-sabreauto"))
1002 return 0;
1003 } else if (is_mx6dl()) {
1004 if (!strcmp(name, "imx6dl-sabreauto"))
1005 return 0;
1006 }
1007
1008 return -1;
1009}
1010#endif