blob: 57170ce0452cd0fd134831d5f9b7cafad37a24bf [file] [log] [blame]
Jason Liu938080d2011-05-13 01:58:55 +00001/*
2 * Copyright (C) 2011 Freescale Semiconductor, Inc.
3 * Jason Liu <r64343@freescale.com>
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <asm/io.h>
26#include <asm/arch/imx-regs.h>
27#include <asm/arch/mx5x_pins.h>
28#include <asm/arch/sys_proto.h>
29#include <asm/arch/crm_regs.h>
30#include <asm/arch/iomux.h>
31#include <asm/arch/clock.h>
32#include <asm/errno.h>
33#include <netdev.h>
34#include <i2c.h>
35#include <mmc.h>
36#include <fsl_esdhc.h>
Stefano Babic50410072011-08-21 10:59:33 +020037#include <asm/gpio.h>
Jason Liu938080d2011-05-13 01:58:55 +000038
39DECLARE_GLOBAL_DATA_PTR;
40
Jason Liu938080d2011-05-13 01:58:55 +000041int dram_init(void)
42{
43 u32 size1, size2;
44
Albert ARIBAUDa55d23c2011-07-03 05:55:33 +000045 size1 = get_ram_size((void *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
46 size2 = get_ram_size((void *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
Jason Liu938080d2011-05-13 01:58:55 +000047
48 gd->ram_size = size1 + size2;
49
50 return 0;
51}
52void dram_init_banksize(void)
53{
54 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
55 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
56
57 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
58 gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
59}
60
61static void setup_iomux_uart(void)
62{
63 /* UART1 RXD */
64 mxc_request_iomux(MX53_PIN_CSI0_D11, IOMUX_CONFIG_ALT2);
65 mxc_iomux_set_pad(MX53_PIN_CSI0_D11,
66 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
67 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
68 PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU |
69 PAD_CTL_ODE_OPENDRAIN_ENABLE);
70 mxc_iomux_set_input(MX53_UART1_IPP_UART_RXD_MUX_SELECT_INPUT, 0x1);
71
72 /* UART1 TXD */
73 mxc_request_iomux(MX53_PIN_CSI0_D10, IOMUX_CONFIG_ALT2);
74 mxc_iomux_set_pad(MX53_PIN_CSI0_D10,
75 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
76 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
77 PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU |
78 PAD_CTL_ODE_OPENDRAIN_ENABLE);
79}
80
Wolfgang Grandegger45cf6ad2011-11-11 14:03:37 +010081#ifdef CONFIG_USB_EHCI_MX5
82void board_ehci_hcd_init(int port)
83{
84 /* request VBUS power enable pin, GPIO[8}, gpio7 */
85 mxc_request_iomux(MX53_PIN_ATA_DA_2, IOMUX_CONFIG_ALT1);
86 gpio_direction_output(IOMUX_TO_GPIO(MX53_PIN_ATA_DA_2), 0);
87 gpio_set_value(IOMUX_TO_GPIO(MX53_PIN_ATA_DA_2), 1);
88}
89#endif
90
Jason Liu938080d2011-05-13 01:58:55 +000091static void setup_iomux_fec(void)
92{
93 /*FEC_MDIO*/
94 mxc_request_iomux(MX53_PIN_FEC_MDIO, IOMUX_CONFIG_ALT0);
95 mxc_iomux_set_pad(MX53_PIN_FEC_MDIO,
96 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
97 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
98 PAD_CTL_22K_PU | PAD_CTL_ODE_OPENDRAIN_ENABLE);
99 mxc_iomux_set_input(MX53_FEC_FEC_MDI_SELECT_INPUT, 0x1);
100
101 /*FEC_MDC*/
102 mxc_request_iomux(MX53_PIN_FEC_MDC, IOMUX_CONFIG_ALT0);
103 mxc_iomux_set_pad(MX53_PIN_FEC_MDC, PAD_CTL_DRV_HIGH);
104
105 /* FEC RXD1 */
106 mxc_request_iomux(MX53_PIN_FEC_RXD1, IOMUX_CONFIG_ALT0);
107 mxc_iomux_set_pad(MX53_PIN_FEC_RXD1,
108 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
109
110 /* FEC RXD0 */
111 mxc_request_iomux(MX53_PIN_FEC_RXD0, IOMUX_CONFIG_ALT0);
112 mxc_iomux_set_pad(MX53_PIN_FEC_RXD0,
113 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
114
115 /* FEC TXD1 */
116 mxc_request_iomux(MX53_PIN_FEC_TXD1, IOMUX_CONFIG_ALT0);
117 mxc_iomux_set_pad(MX53_PIN_FEC_TXD1, PAD_CTL_DRV_HIGH);
118
119 /* FEC TXD0 */
120 mxc_request_iomux(MX53_PIN_FEC_TXD0, IOMUX_CONFIG_ALT0);
121 mxc_iomux_set_pad(MX53_PIN_FEC_TXD0, PAD_CTL_DRV_HIGH);
122
123 /* FEC TX_EN */
124 mxc_request_iomux(MX53_PIN_FEC_TX_EN, IOMUX_CONFIG_ALT0);
125 mxc_iomux_set_pad(MX53_PIN_FEC_TX_EN, PAD_CTL_DRV_HIGH);
126
127 /* FEC TX_CLK */
128 mxc_request_iomux(MX53_PIN_FEC_REF_CLK, IOMUX_CONFIG_ALT0);
129 mxc_iomux_set_pad(MX53_PIN_FEC_REF_CLK,
130 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
131
132 /* FEC RX_ER */
133 mxc_request_iomux(MX53_PIN_FEC_RX_ER, IOMUX_CONFIG_ALT0);
134 mxc_iomux_set_pad(MX53_PIN_FEC_RX_ER,
135 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
136
137 /* FEC CRS */
138 mxc_request_iomux(MX53_PIN_FEC_CRS_DV, IOMUX_CONFIG_ALT0);
139 mxc_iomux_set_pad(MX53_PIN_FEC_CRS_DV,
140 PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE);
141}
142
143#ifdef CONFIG_FSL_ESDHC
144struct fsl_esdhc_cfg esdhc_cfg[2] = {
145 {MMC_SDHC1_BASE_ADDR, 1},
146 {MMC_SDHC3_BASE_ADDR, 1},
147};
148
149int board_mmc_getcd(u8 *cd, struct mmc *mmc)
150{
151 struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
152
Fabio Estevam73128aa2011-11-15 05:51:29 +0000153 mxc_request_iomux(MX53_PIN_EIM_DA11, IOMUX_CONFIG_ALT1);
154 mxc_request_iomux(MX53_PIN_EIM_DA13, IOMUX_CONFIG_ALT1);
155
Jason Liu938080d2011-05-13 01:58:55 +0000156 if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR)
Stefano Babic50410072011-08-21 10:59:33 +0200157 *cd = gpio_get_value(77); /*GPIO3_13*/
Jason Liu938080d2011-05-13 01:58:55 +0000158 else
Stefano Babic50410072011-08-21 10:59:33 +0200159 *cd = gpio_get_value(75); /*GPIO3_11*/
Jason Liu938080d2011-05-13 01:58:55 +0000160
161 return 0;
162}
163
164int board_mmc_init(bd_t *bis)
165{
166 u32 index;
167 s32 status = 0;
168
169 for (index = 0; index < CONFIG_SYS_FSL_ESDHC_NUM; index++) {
170 switch (index) {
171 case 0:
172 mxc_request_iomux(MX53_PIN_SD1_CMD, IOMUX_CONFIG_ALT0);
173 mxc_request_iomux(MX53_PIN_SD1_CLK, IOMUX_CONFIG_ALT0);
174 mxc_request_iomux(MX53_PIN_SD1_DATA0,
175 IOMUX_CONFIG_ALT0);
176 mxc_request_iomux(MX53_PIN_SD1_DATA1,
177 IOMUX_CONFIG_ALT0);
178 mxc_request_iomux(MX53_PIN_SD1_DATA2,
179 IOMUX_CONFIG_ALT0);
180 mxc_request_iomux(MX53_PIN_SD1_DATA3,
181 IOMUX_CONFIG_ALT0);
182 mxc_request_iomux(MX53_PIN_EIM_DA13,
183 IOMUX_CONFIG_ALT1);
184
185 mxc_iomux_set_pad(MX53_PIN_SD1_CMD,
186 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
187 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
188 PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU);
189 mxc_iomux_set_pad(MX53_PIN_SD1_CLK,
190 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
191 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU |
192 PAD_CTL_DRV_HIGH);
193 mxc_iomux_set_pad(MX53_PIN_SD1_DATA0,
194 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
195 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
196 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
197 mxc_iomux_set_pad(MX53_PIN_SD1_DATA1,
198 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
199 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
200 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
201 mxc_iomux_set_pad(MX53_PIN_SD1_DATA2,
202 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
203 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
204 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
205 mxc_iomux_set_pad(MX53_PIN_SD1_DATA3,
206 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
207 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
208 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
209 break;
210 case 1:
211 mxc_request_iomux(MX53_PIN_ATA_RESET_B,
212 IOMUX_CONFIG_ALT2);
213 mxc_request_iomux(MX53_PIN_ATA_IORDY,
214 IOMUX_CONFIG_ALT2);
215 mxc_request_iomux(MX53_PIN_ATA_DATA8,
216 IOMUX_CONFIG_ALT4);
217 mxc_request_iomux(MX53_PIN_ATA_DATA9,
218 IOMUX_CONFIG_ALT4);
219 mxc_request_iomux(MX53_PIN_ATA_DATA10,
220 IOMUX_CONFIG_ALT4);
221 mxc_request_iomux(MX53_PIN_ATA_DATA11,
222 IOMUX_CONFIG_ALT4);
223 mxc_request_iomux(MX53_PIN_ATA_DATA0,
224 IOMUX_CONFIG_ALT4);
225 mxc_request_iomux(MX53_PIN_ATA_DATA1,
226 IOMUX_CONFIG_ALT4);
227 mxc_request_iomux(MX53_PIN_ATA_DATA2,
228 IOMUX_CONFIG_ALT4);
229 mxc_request_iomux(MX53_PIN_ATA_DATA3,
230 IOMUX_CONFIG_ALT4);
231 mxc_request_iomux(MX53_PIN_EIM_DA11,
232 IOMUX_CONFIG_ALT1);
233
234 mxc_iomux_set_pad(MX53_PIN_ATA_RESET_B,
235 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
236 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
237 PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PU);
238 mxc_iomux_set_pad(MX53_PIN_ATA_IORDY,
239 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
240 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU |
241 PAD_CTL_DRV_HIGH);
242 mxc_iomux_set_pad(MX53_PIN_ATA_DATA8,
243 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
244 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
245 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
246 mxc_iomux_set_pad(MX53_PIN_ATA_DATA9,
247 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
248 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
249 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
250 mxc_iomux_set_pad(MX53_PIN_ATA_DATA10,
251 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
252 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
253 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
254 mxc_iomux_set_pad(MX53_PIN_ATA_DATA11,
255 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
256 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
257 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
258 mxc_iomux_set_pad(MX53_PIN_ATA_DATA0,
259 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
260 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
261 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
262 mxc_iomux_set_pad(MX53_PIN_ATA_DATA1,
263 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
264 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
265 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
266 mxc_iomux_set_pad(MX53_PIN_ATA_DATA2,
267 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
268 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
269 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
270 mxc_iomux_set_pad(MX53_PIN_ATA_DATA3,
271 PAD_CTL_HYS_ENABLE | PAD_CTL_DRV_HIGH |
272 PAD_CTL_PUE_PULL | PAD_CTL_PKE_ENABLE |
273 PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU);
274
275 break;
276 default:
277 printf("Warning: you configured more ESDHC controller"
278 "(%d) as supported by the board(2)\n",
279 CONFIG_SYS_FSL_ESDHC_NUM);
280 return status;
281 }
282 status |= fsl_esdhc_initialize(bis, &esdhc_cfg[index]);
283 }
284
285 return status;
286}
287#endif
288
289int board_early_init_f(void)
290{
291 setup_iomux_uart();
292 setup_iomux_fec();
293
294 return 0;
295}
296
297int board_init(void)
298{
Jason Liu938080d2011-05-13 01:58:55 +0000299 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
300
301 return 0;
302}
303
304int checkboard(void)
305{
306 puts("Board: MX53 LOCO\n");
307
308 return 0;
309}