2 * (C) Copyright 2012, Stefano Babic <sbabic@denx.de>
4 * (C) Copyright 2010 Freescale Semiconductor, Inc.
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
25 #include <asm/arch/imx-regs.h>
26 #include <asm/arch/mx5x_pins.h>
27 #include <asm/arch/sys_proto.h>
28 #include <asm/arch/crm_regs.h>
29 #include <asm/arch/clock.h>
30 #include <asm/arch/iomux.h>
31 #include <asm/errno.h>
34 #include <fsl_esdhc.h>
37 /* NOR flash configuration */
38 #define IMA3_MX53_CS0GCR1 (CSEN | DSZ(2))
39 #define IMA3_MX53_CS0GCR2 0
40 #define IMA3_MX53_CS0RCR1 (RCSN(2) | OEN(1) | RWSC(15))
41 #define IMA3_MX53_CS0RCR2 0
42 #define IMA3_MX53_CS0WCR1 (WBED1 | WCSN(2) | WEN(1) | WWSC(15))
43 #define IMA3_MX53_CS0WCR2 0
45 DECLARE_GLOBAL_DATA_PTR;
47 static void weim_nor_settings(void)
49 struct weim *weim_regs = (struct weim *)WEIM_BASE_ADDR;
51 writel(IMA3_MX53_CS0GCR1, &weim_regs->cs0gcr1);
52 writel(IMA3_MX53_CS0GCR2, &weim_regs->cs0gcr2);
53 writel(IMA3_MX53_CS0RCR1, &weim_regs->cs0rcr1);
54 writel(IMA3_MX53_CS0RCR2, &weim_regs->cs0rcr2);
55 writel(IMA3_MX53_CS0WCR1, &weim_regs->cs0wcr1);
56 writel(IMA3_MX53_CS0WCR2, &weim_regs->cs0wcr2);
57 writel(0x0, &weim_regs->wcr);
59 set_chipselect_size(CS0_128);
64 gd->ram_size = get_ram_size((void *) CONFIG_SYS_SDRAM_BASE,
69 static void setup_iomux_uart(void)
72 mxc_request_iomux(MX53_PIN_CSI0_D13, IOMUX_CONFIG_ALT2);
73 mxc_iomux_set_pad(MX53_PIN_CSI0_D13,
74 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
75 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE |
76 PAD_CTL_100K_PU | PAD_CTL_ODE_OPENDRAIN_ENABLE);
77 mxc_iomux_set_input(MX53_UART4_IPP_UART_RXD_MUX_SELECT_INPUT, 0x3);
80 mxc_request_iomux(MX53_PIN_CSI0_D12, IOMUX_CONFIG_ALT2);
81 mxc_iomux_set_pad(MX53_PIN_CSI0_D12,
82 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
83 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE |
84 PAD_CTL_100K_PU | PAD_CTL_ODE_OPENDRAIN_ENABLE);
87 static void setup_iomux_fec(void)
90 mxc_request_iomux(MX53_PIN_FEC_MDIO, IOMUX_CONFIG_ALT0);
91 mxc_iomux_set_pad(MX53_PIN_FEC_MDIO,
92 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
93 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE | PAD_CTL_22K_PU |
94 PAD_CTL_ODE_OPENDRAIN_ENABLE);
95 mxc_iomux_set_input(MX53_FEC_FEC_MDI_SELECT_INPUT, 0x1);
98 mxc_request_iomux(MX53_PIN_FEC_MDC, IOMUX_CONFIG_ALT0);
99 mxc_iomux_set_pad(MX53_PIN_FEC_MDC, PAD_CTL_DRV_HIGH);
102 mxc_request_iomux(MX53_PIN_KEY_COL0, IOMUX_CONFIG_ALT6);
103 mxc_iomux_set_pad(MX53_PIN_KEY_COL0, PAD_CTL_HYS_ENABLE |
107 mxc_request_iomux(MX53_PIN_KEY_COL2, IOMUX_CONFIG_ALT6);
108 mxc_iomux_set_pad(MX53_PIN_KEY_COL2, PAD_CTL_HYS_ENABLE |
112 mxc_request_iomux(MX53_PIN_FEC_RXD1, IOMUX_CONFIG_ALT0);
113 mxc_iomux_set_pad(MX53_PIN_FEC_RXD1, PAD_CTL_HYS_ENABLE |
117 mxc_request_iomux(MX53_PIN_FEC_RXD0, IOMUX_CONFIG_ALT0);
118 mxc_iomux_set_pad(MX53_PIN_FEC_RXD0, PAD_CTL_HYS_ENABLE |
122 mxc_request_iomux(MX53_PIN_GPIO_19, IOMUX_CONFIG_ALT6);
123 mxc_iomux_set_pad(MX53_PIN_GPIO_19, PAD_CTL_DRV_HIGH);
126 mxc_request_iomux(MX53_PIN_KEY_ROW2, IOMUX_CONFIG_ALT6);
127 mxc_iomux_set_pad(MX53_PIN_KEY_ROW2, PAD_CTL_DRV_HIGH);
130 mxc_request_iomux(MX53_PIN_FEC_TXD1, IOMUX_CONFIG_ALT0);
131 mxc_iomux_set_pad(MX53_PIN_FEC_TXD1, PAD_CTL_DRV_HIGH);
134 mxc_request_iomux(MX53_PIN_FEC_TXD0, IOMUX_CONFIG_ALT0);
135 mxc_iomux_set_pad(MX53_PIN_FEC_TXD0, PAD_CTL_DRV_HIGH);
138 mxc_request_iomux(MX53_PIN_FEC_TX_EN, IOMUX_CONFIG_ALT0);
139 mxc_iomux_set_pad(MX53_PIN_FEC_TX_EN, PAD_CTL_DRV_HIGH);
142 mxc_request_iomux(MX53_PIN_FEC_REF_CLK, IOMUX_CONFIG_ALT0);
143 mxc_iomux_set_pad(MX53_PIN_FEC_REF_CLK, PAD_CTL_HYS_ENABLE |
147 mxc_request_iomux(MX53_PIN_FEC_RX_ER, IOMUX_CONFIG_ALT0);
148 mxc_iomux_set_pad(MX53_PIN_FEC_RX_ER, PAD_CTL_HYS_ENABLE |
152 mxc_request_iomux(MX53_PIN_FEC_CRS_DV, IOMUX_CONFIG_ALT0);
153 mxc_iomux_set_pad(MX53_PIN_FEC_CRS_DV, PAD_CTL_HYS_ENABLE |
157 mxc_request_iomux(MX53_PIN_KEY_COL3, IOMUX_CONFIG_ALT6);
158 mxc_iomux_set_pad(MX53_PIN_KEY_COL3, PAD_CTL_HYS_ENABLE |
162 mxc_request_iomux(MX53_PIN_KEY_ROW1, IOMUX_CONFIG_ALT6);
163 mxc_iomux_set_pad(MX53_PIN_KEY_ROW1, PAD_CTL_HYS_ENABLE |
165 mxc_iomux_set_input(MX53_FEC_FEC_COL_SELECT_INPUT, 0x0);
168 mxc_request_iomux(MX53_PIN_KEY_COL1, IOMUX_CONFIG_ALT6);
169 mxc_iomux_set_pad(MX53_PIN_KEY_COL1, PAD_CTL_HYS_ENABLE |
171 mxc_iomux_set_input(MX53_FEC_FEC_RX_CLK_SELECT_INPUT, 0x0);
174 #ifdef CONFIG_FSL_ESDHC
175 struct fsl_esdhc_cfg esdhc_cfg = { MMC_SDHC1_BASE_ADDR };
177 int board_mmc_getcd(struct mmc *mmc)
181 ret = !gpio_get_value(IOMUX_TO_GPIO(MX53_PIN_GPIO_1));
186 int board_mmc_init(bd_t *bis)
188 mxc_request_iomux(MX53_PIN_SD1_CMD, IOMUX_CONFIG_ALT0);
189 mxc_request_iomux(MX53_PIN_SD1_CLK, IOMUX_CONFIG_ALT0);
190 mxc_request_iomux(MX53_PIN_SD1_DATA0, IOMUX_CONFIG_ALT0);
191 mxc_request_iomux(MX53_PIN_SD1_DATA1, IOMUX_CONFIG_ALT0);
192 mxc_request_iomux(MX53_PIN_SD1_DATA2, IOMUX_CONFIG_ALT0);
193 mxc_request_iomux(MX53_PIN_SD1_DATA3, IOMUX_CONFIG_ALT0);
194 mxc_request_iomux(MX53_PIN_GPIO_1, IOMUX_CONFIG_ALT1);
195 mxc_iomux_set_pad(MX53_PIN_GPIO_1,
196 PAD_CTL_DRV_HIGH | PAD_CTL_HYS_ENABLE |
197 PAD_CTL_PUE_KEEPER | PAD_CTL_100K_PU |
198 PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_PKE_ENABLE);
199 gpio_direction_input(IOMUX_TO_GPIO(MX53_PIN_GPIO_1));
201 mxc_iomux_set_pad(MX53_PIN_SD1_CMD,
202 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH | PAD_CTL_PUE_PULL |
203 PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU);
204 mxc_iomux_set_pad(MX53_PIN_SD1_CLK,
205 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE |
206 PAD_CTL_47K_PU | PAD_CTL_DRV_HIGH);
207 mxc_iomux_set_pad(MX53_PIN_SD1_DATA0,
208 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH | PAD_CTL_PUE_PULL |
209 PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
210 mxc_iomux_set_pad(MX53_PIN_SD1_DATA1,
211 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH | PAD_CTL_PUE_PULL |
212 PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
213 mxc_iomux_set_pad(MX53_PIN_SD1_DATA2,
214 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH | PAD_CTL_PUE_PULL |
215 PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
216 mxc_iomux_set_pad(MX53_PIN_SD1_DATA3,
217 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH | PAD_CTL_PUE_PULL |
218 PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
220 return fsl_esdhc_initialize(bis, &esdhc_cfg);
224 static void setup_iomux_spi(void)
227 mxc_request_iomux(MX53_PIN_CSI0_D8, IOMUX_CONFIG_ALT3);
228 mxc_iomux_set_pad(MX53_PIN_CSI0_D8,
229 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH | PAD_CTL_PUE_PULL |
230 PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
231 mxc_iomux_set_input(MX53_ECSPI2_IPP_CSPI_CLK_IN_SELECT_INPUT, 0x1);
233 mxc_request_iomux(MX53_PIN_CSI0_D9, IOMUX_CONFIG_ALT3);
234 mxc_iomux_set_pad(MX53_PIN_CSI0_D9,
235 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH | PAD_CTL_PUE_PULL |
236 PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
237 mxc_iomux_set_input(MX53_ECSPI2_IPP_IND_MOSI_SELECT_INPUT, 0x1);
239 mxc_request_iomux(MX53_PIN_CSI0_D10, IOMUX_CONFIG_ALT3);
240 mxc_iomux_set_pad(MX53_PIN_CSI0_D10,
241 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH | PAD_CTL_PUE_PULL |
242 PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
243 mxc_iomux_set_input(MX53_ECSPI2_IPP_IND_MISO_SELECT_INPUT, 0x1);
245 mxc_request_iomux(MX53_PIN_CSI0_D11, IOMUX_CONFIG_GPIO);
246 mxc_iomux_set_pad(MX53_PIN_CSI0_D11,
247 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH | PAD_CTL_PUE_PULL |
248 PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
249 gpio_direction_output(IOMUX_TO_GPIO(MX53_PIN_CSI0_D11), 1);
252 int board_early_init_f(void)
254 /* configure I/O pads */
268 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
270 mxc_set_sata_internal_clock();
275 #if defined(CONFIG_RESET_PHY_R)
283 miiphy_reset("FEC", CONFIG_PHY_ADDR);
285 /* set hard link to 100Mbit, full-duplex */
286 miiphy_read("FEC", CONFIG_PHY_ADDR, MII_BMCR, ®);
287 reg &= ~BMCR_ANENABLE;
288 reg |= (BMCR_SPEED100 | BMCR_FULLDPLX);
289 miiphy_write("FEC", CONFIG_PHY_ADDR, MII_BMCR, reg);
291 miiphy_read("FEC", CONFIG_PHY_ADDR, 0x16, ®);
293 miiphy_write("FEC", CONFIG_PHY_ADDR, 0x16, reg);
299 puts("Board: IMA3_MX53\n");