3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
6 * Copyright (C) 2012 Freescale Semiconductor, Inc.
8 * Author: Fabio Estevam <fabio.estevam@freescale.com>
10 * SPDX-License-Identifier: GPL-2.0+
13 #include <asm/arch/clock.h>
14 #include <asm/arch/imx-regs.h>
15 #include <asm/arch/iomux.h>
16 #include <asm/arch/mx6-pins.h>
17 #include <linux/errno.h>
19 #include <asm/mach-imx/iomux-v3.h>
20 #include <asm/mach-imx/boot_mode.h>
21 #include <asm/mach-imx/mxc_i2c.h>
22 #include <asm/mach-imx/video.h>
24 #include <fsl_esdhc.h>
27 #include <asm/arch/mxc_hdmi.h>
28 #include <asm/arch/crm_regs.h>
30 #include <ipu_pixfmt.h>
33 #include <asm/arch/sys_proto.h>
36 DECLARE_GLOBAL_DATA_PTR;
38 #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)
42 #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)
46 #define ENET_PAD_CTRL (PAD_CTL_PUS_100K_UP | \
47 PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
49 #define SPI_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_SPEED_MED | \
50 PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
52 #define I2C_PAD_CTRL (PAD_CTL_PUS_100K_UP | \
53 PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \
54 PAD_CTL_ODE | PAD_CTL_SRE_FAST)
56 #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
58 #define DISP_PAD_CTRL (0x10)
60 #define ECSPI4_CS1 IMX_GPIO_NR(5, 2)
62 #if (CONFIG_SYS_BOARD_VERSION == 1)
63 #include "./aristainetos-v1.c"
64 #elif ((CONFIG_SYS_BOARD_VERSION == 2) || (CONFIG_SYS_BOARD_VERSION == 3))
65 #include "./aristainetos-v2.c"
69 struct i2c_pads_info i2c_pad_info1 = {
71 .i2c_mode = MX6_PAD_CSI0_DAT9__I2C1_SCL | PC,
72 .gpio_mode = MX6_PAD_CSI0_DAT9__GPIO5_IO27 | PC,
73 .gp = IMX_GPIO_NR(5, 27)
76 .i2c_mode = MX6_PAD_CSI0_DAT8__I2C1_SDA | PC,
77 .gpio_mode = MX6_PAD_CSI0_DAT8__GPIO5_IO26 | PC,
78 .gp = IMX_GPIO_NR(5, 26)
82 struct i2c_pads_info i2c_pad_info2 = {
84 .i2c_mode = MX6_PAD_KEY_COL3__I2C2_SCL | PC,
85 .gpio_mode = MX6_PAD_KEY_COL3__GPIO4_IO12 | PC,
86 .gp = IMX_GPIO_NR(4, 12)
89 .i2c_mode = MX6_PAD_KEY_ROW3__I2C2_SDA | PC,
90 .gpio_mode = MX6_PAD_KEY_ROW3__GPIO4_IO13 | PC,
91 .gp = IMX_GPIO_NR(4, 13)
95 iomux_v3_cfg_t const usdhc1_pads[] = {
96 MX6_PAD_SD1_CLK__SD1_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
97 MX6_PAD_SD1_CMD__SD1_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
98 MX6_PAD_SD1_DAT0__SD1_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
99 MX6_PAD_SD1_DAT1__SD1_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
100 MX6_PAD_SD1_DAT2__SD1_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
101 MX6_PAD_SD1_DAT3__SD1_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
106 gd->ram_size = imx_ddr_size();
111 #ifdef CONFIG_FSL_ESDHC
112 struct fsl_esdhc_cfg usdhc_cfg[2] = {
117 int board_mmc_getcd(struct mmc *mmc)
122 int board_mmc_init(bd_t *bis)
124 usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
125 imx_iomux_v3_setup_multiple_pads(usdhc1_pads, ARRAY_SIZE(usdhc1_pads));
126 #if (CONFIG_SYS_BOARD_VERSION == 2)
128 * usdhc2 has a levelshifter on the carrier board Rev. DV1,
129 * that will automatically detect the driving direction.
130 * During initialisation this isn't working correctly,
131 * which causes DAT3 to be driven low towards the SD-card.
132 * This causes a SD-card enetring the SPI-Mode
133 * and therefore getting inaccessible until next power cycle.
134 * As workaround we drive the DAT3 line as GPIO and set it high.
135 * This makes usdhc2 unusable in u-boot, but works for the
136 * initialisation in Linux
138 imx_iomux_v3_setup_pad(MX6_PAD_SD2_DAT3__GPIO1_IO12 |
139 MUX_PAD_CTRL(NO_PAD_CTRL));
140 gpio_direction_output(IMX_GPIO_NR(1, 12) , 1);
142 return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
147 * Do not overwrite the console
148 * Use always serial for U-Boot console
150 int overwrite_console(void)
155 struct display_info_t const displays[] = {
159 .pixfmt = IPU_PIX_FMT_RGB24,
161 .enable = enable_lvds,
175 .vmode = FB_VMODE_NONINTERLACED
178 #if ((CONFIG_SYS_BOARD_VERSION == 2) || (CONFIG_SYS_BOARD_VERSION == 3))
182 .pixfmt = IPU_PIX_FMT_RGB24,
184 .enable = enable_spi_display,
197 .sync = FB_SYNC_EXT | FB_SYNC_HOR_HIGH_ACT |
198 FB_SYNC_VERT_HIGH_ACT,
199 .vmode = FB_VMODE_NONINTERLACED
204 size_t display_count = ARRAY_SIZE(displays);
206 /* no console on this board */
207 int board_cfb_skip(void)
212 iomux_v3_cfg_t nfc_pads[] = {
213 MX6_PAD_NANDF_CLE__NAND_CLE | MUX_PAD_CTRL(NO_PAD_CTRL),
214 MX6_PAD_NANDF_ALE__NAND_ALE | MUX_PAD_CTRL(NO_PAD_CTRL),
215 MX6_PAD_NANDF_WP_B__NAND_WP_B | MUX_PAD_CTRL(NO_PAD_CTRL),
216 MX6_PAD_NANDF_RB0__NAND_READY_B | MUX_PAD_CTRL(NO_PAD_CTRL),
217 MX6_PAD_NANDF_CS0__NAND_CE0_B | MUX_PAD_CTRL(NO_PAD_CTRL),
218 MX6_PAD_SD4_CMD__NAND_RE_B | MUX_PAD_CTRL(NO_PAD_CTRL),
219 MX6_PAD_SD4_CLK__NAND_WE_B | MUX_PAD_CTRL(NO_PAD_CTRL),
220 MX6_PAD_NANDF_D0__NAND_DATA00 | MUX_PAD_CTRL(NO_PAD_CTRL),
221 MX6_PAD_NANDF_D1__NAND_DATA01 | MUX_PAD_CTRL(NO_PAD_CTRL),
222 MX6_PAD_NANDF_D2__NAND_DATA02 | MUX_PAD_CTRL(NO_PAD_CTRL),
223 MX6_PAD_NANDF_D3__NAND_DATA03 | MUX_PAD_CTRL(NO_PAD_CTRL),
224 MX6_PAD_NANDF_D4__NAND_DATA04 | MUX_PAD_CTRL(NO_PAD_CTRL),
225 MX6_PAD_NANDF_D5__NAND_DATA05 | MUX_PAD_CTRL(NO_PAD_CTRL),
226 MX6_PAD_NANDF_D6__NAND_DATA06 | MUX_PAD_CTRL(NO_PAD_CTRL),
227 MX6_PAD_NANDF_D7__NAND_DATA07 | MUX_PAD_CTRL(NO_PAD_CTRL),
228 MX6_PAD_SD4_DAT0__NAND_DQS | MUX_PAD_CTRL(NO_PAD_CTRL),
231 static void setup_gpmi_nand(void)
233 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
235 /* config gpmi nand iomux */
236 imx_iomux_v3_setup_multiple_pads(nfc_pads,
237 ARRAY_SIZE(nfc_pads));
239 /* gate ENFC_CLK_ROOT clock first,before clk source switch */
240 clrbits_le32(&mxc_ccm->CCGR2, MXC_CCM_CCGR2_IOMUX_IPT_CLK_IO_MASK);
242 /* config gpmi and bch clock to 100 MHz */
243 clrsetbits_le32(&mxc_ccm->cs2cdr,
244 MXC_CCM_CS2CDR_ENFC_CLK_PODF_MASK |
245 MXC_CCM_CS2CDR_ENFC_CLK_PRED_MASK |
246 MXC_CCM_CS2CDR_ENFC_CLK_SEL_MASK,
247 MXC_CCM_CS2CDR_ENFC_CLK_PODF(0) |
248 MXC_CCM_CS2CDR_ENFC_CLK_PRED(3) |
249 MXC_CCM_CS2CDR_ENFC_CLK_SEL(3));
251 /* enable ENFC_CLK_ROOT clock */
252 setbits_le32(&mxc_ccm->CCGR2, MXC_CCM_CCGR2_IOMUX_IPT_CLK_IO_MASK);
254 /* enable gpmi and bch clock gating */
255 setbits_le32(&mxc_ccm->CCGR4,
256 MXC_CCM_CCGR4_RAWNAND_U_BCH_INPUT_APB_MASK |
257 MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_BCH_MASK |
258 MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_GPMI_IO_MASK |
259 MXC_CCM_CCGR4_RAWNAND_U_GPMI_INPUT_APB_MASK |
260 MXC_CCM_CCGR4_PL301_MX6QPER1_BCH_OFFSET);
262 /* enable apbh clock gating */
263 setbits_le32(&mxc_ccm->CCGR0, MXC_CCM_CCGR0_APBHDMA_MASK);
268 struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
270 /* address of boot parameters */
271 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
275 setup_i2c(0, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE,
277 setup_i2c(1, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE,
279 setup_i2c(2, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE,
283 /* SPI NOR Flash read only */
284 gpio_request(CONFIG_GPIO_ENABLE_SPI_FLASH, "ena_spi_nor");
285 gpio_direction_output(CONFIG_GPIO_ENABLE_SPI_FLASH, 0);
286 gpio_free(CONFIG_GPIO_ENABLE_SPI_FLASH);
292 /* GPIO_1 for USB_OTG_ID */
293 clrsetbits_le32(&iomux->gpr[1], IOMUXC_GPR1_USB_OTG_ID_SEL_MASK, 0);
294 imx_iomux_v3_setup_multiple_pads(misc_pads, ARRAY_SIZE(misc_pads));
300 printf("Board: %s\n", CONFIG_BOARDNAME);
304 #ifdef CONFIG_USB_EHCI_MX6
305 int board_ehci_hcd_init(int port)
309 ret = gpio_request(ARISTAINETOS_USB_H1_PWR, "usb-h1-pwr");
311 gpio_direction_output(ARISTAINETOS_USB_H1_PWR, 1);
312 ret = gpio_request(ARISTAINETOS_USB_OTG_PWR, "usb-OTG-pwr");
314 gpio_direction_output(ARISTAINETOS_USB_OTG_PWR, 1);
318 int board_ehci_power(int port, int on)
321 gpio_set_value(ARISTAINETOS_USB_OTG_PWR, on);
323 gpio_set_value(ARISTAINETOS_USB_H1_PWR, on);