2 * Copyright (C) 2007, Guennadi Liakhovetski <lg@denx.de>
4 * (C) Copyright 2008-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
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <asm/errno.h>
28 #include <asm/arch/imx-regs.h>
29 #include <asm/arch/crm_regs.h>
30 #include <asm/arch/mx35_pins.h>
31 #include <asm/arch/iomux.h>
36 #include <linux/types.h>
38 #include <asm/arch/sys_proto.h>
41 #ifndef BOARD_LATE_INIT
42 #error "BOARD_LATE_INIT must be set for this board"
45 #ifndef CONFIG_BOARD_EARLY_INIT_F
46 #error "CONFIG_BOARD_EARLY_INIT_F must be set for this board"
49 #define mdelay(n) ({unsigned long msec = (n); while (msec--) udelay(1000); })
51 DECLARE_GLOBAL_DATA_PTR;
55 gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1,
61 static void setup_iomux_i2c(void)
65 /* setup pins for I2C1 */
66 mxc_request_iomux(MX35_PIN_I2C1_CLK, MUX_CONFIG_SION);
67 mxc_request_iomux(MX35_PIN_I2C1_DAT, MUX_CONFIG_SION);
69 pad = (PAD_CTL_HYS_SCHMITZ | PAD_CTL_PKE_ENABLE \
70 | PAD_CTL_PUE_PUD | PAD_CTL_ODE_OpenDrain);
72 mxc_iomux_set_pad(MX35_PIN_I2C1_CLK, pad);
73 mxc_iomux_set_pad(MX35_PIN_I2C1_DAT, pad);
77 static void setup_iomux_spi(void)
79 mxc_request_iomux(MX35_PIN_CSPI1_MOSI, MUX_CONFIG_SION);
80 mxc_request_iomux(MX35_PIN_CSPI1_MISO, MUX_CONFIG_SION);
81 mxc_request_iomux(MX35_PIN_CSPI1_SS0, MUX_CONFIG_SION);
82 mxc_request_iomux(MX35_PIN_CSPI1_SS1, MUX_CONFIG_SION);
83 mxc_request_iomux(MX35_PIN_CSPI1_SCLK, MUX_CONFIG_SION);
86 static void setup_iomux_fec(void)
90 /* setup pins for FEC */
91 mxc_request_iomux(MX35_PIN_FEC_TX_CLK, MUX_CONFIG_FUNC);
92 mxc_request_iomux(MX35_PIN_FEC_RX_CLK, MUX_CONFIG_FUNC);
93 mxc_request_iomux(MX35_PIN_FEC_RX_DV, MUX_CONFIG_FUNC);
94 mxc_request_iomux(MX35_PIN_FEC_COL, MUX_CONFIG_FUNC);
95 mxc_request_iomux(MX35_PIN_FEC_RDATA0, MUX_CONFIG_FUNC);
96 mxc_request_iomux(MX35_PIN_FEC_TDATA0, MUX_CONFIG_FUNC);
97 mxc_request_iomux(MX35_PIN_FEC_TX_EN, MUX_CONFIG_FUNC);
98 mxc_request_iomux(MX35_PIN_FEC_MDC, MUX_CONFIG_FUNC);
99 mxc_request_iomux(MX35_PIN_FEC_MDIO, MUX_CONFIG_FUNC);
100 mxc_request_iomux(MX35_PIN_FEC_TX_ERR, MUX_CONFIG_FUNC);
101 mxc_request_iomux(MX35_PIN_FEC_RX_ERR, MUX_CONFIG_FUNC);
102 mxc_request_iomux(MX35_PIN_FEC_CRS, MUX_CONFIG_FUNC);
103 mxc_request_iomux(MX35_PIN_FEC_RDATA1, MUX_CONFIG_FUNC);
104 mxc_request_iomux(MX35_PIN_FEC_TDATA1, MUX_CONFIG_FUNC);
105 mxc_request_iomux(MX35_PIN_FEC_RDATA2, MUX_CONFIG_FUNC);
106 mxc_request_iomux(MX35_PIN_FEC_TDATA2, MUX_CONFIG_FUNC);
107 mxc_request_iomux(MX35_PIN_FEC_RDATA3, MUX_CONFIG_FUNC);
108 mxc_request_iomux(MX35_PIN_FEC_TDATA3, MUX_CONFIG_FUNC);
110 pad = (PAD_CTL_DRV_3_3V | PAD_CTL_PUE_PUD | PAD_CTL_ODE_CMOS | \
111 PAD_CTL_DRV_NORMAL | PAD_CTL_SRE_SLOW);
113 mxc_iomux_set_pad(MX35_PIN_FEC_TX_CLK, pad | PAD_CTL_HYS_SCHMITZ | \
114 PAD_CTL_PKE_ENABLE | PAD_CTL_100K_PD);
115 mxc_iomux_set_pad(MX35_PIN_FEC_RX_CLK, pad | PAD_CTL_HYS_SCHMITZ | \
116 PAD_CTL_PKE_ENABLE | PAD_CTL_100K_PD);
117 mxc_iomux_set_pad(MX35_PIN_FEC_RX_DV, pad | PAD_CTL_HYS_SCHMITZ | \
118 PAD_CTL_PKE_ENABLE | PAD_CTL_100K_PD);
119 mxc_iomux_set_pad(MX35_PIN_FEC_COL, pad | PAD_CTL_HYS_SCHMITZ | \
120 PAD_CTL_PKE_ENABLE | PAD_CTL_100K_PD);
121 mxc_iomux_set_pad(MX35_PIN_FEC_RDATA0, pad | PAD_CTL_HYS_SCHMITZ | \
122 PAD_CTL_PKE_ENABLE | PAD_CTL_100K_PD);
123 mxc_iomux_set_pad(MX35_PIN_FEC_TDATA0, pad | PAD_CTL_HYS_CMOS | \
124 PAD_CTL_PKE_NONE | PAD_CTL_100K_PD);
125 mxc_iomux_set_pad(MX35_PIN_FEC_TX_EN, pad | PAD_CTL_HYS_CMOS | \
126 PAD_CTL_PKE_NONE | PAD_CTL_100K_PD);
127 mxc_iomux_set_pad(MX35_PIN_FEC_MDC, pad | PAD_CTL_HYS_CMOS | \
128 PAD_CTL_PKE_NONE | PAD_CTL_100K_PD);
129 mxc_iomux_set_pad(MX35_PIN_FEC_MDIO, pad | PAD_CTL_HYS_SCHMITZ | \
130 PAD_CTL_PKE_ENABLE | PAD_CTL_22K_PU);
131 mxc_iomux_set_pad(MX35_PIN_FEC_TX_ERR, pad | PAD_CTL_HYS_CMOS | \
132 PAD_CTL_PKE_NONE | PAD_CTL_100K_PD);
133 mxc_iomux_set_pad(MX35_PIN_FEC_RX_ERR, pad | PAD_CTL_HYS_SCHMITZ | \
134 PAD_CTL_PKE_ENABLE | PAD_CTL_100K_PD);
135 mxc_iomux_set_pad(MX35_PIN_FEC_CRS, pad | PAD_CTL_HYS_SCHMITZ | \
136 PAD_CTL_PKE_ENABLE | PAD_CTL_100K_PD);
137 mxc_iomux_set_pad(MX35_PIN_FEC_RDATA1, pad | PAD_CTL_HYS_SCHMITZ | \
138 PAD_CTL_PKE_ENABLE | PAD_CTL_100K_PD);
139 mxc_iomux_set_pad(MX35_PIN_FEC_TDATA1, pad | PAD_CTL_HYS_CMOS | \
140 PAD_CTL_PKE_NONE | PAD_CTL_100K_PD);
141 mxc_iomux_set_pad(MX35_PIN_FEC_RDATA2, pad | PAD_CTL_HYS_SCHMITZ | \
142 PAD_CTL_PKE_ENABLE | PAD_CTL_100K_PD);
143 mxc_iomux_set_pad(MX35_PIN_FEC_TDATA2, pad | PAD_CTL_HYS_CMOS | \
144 PAD_CTL_PKE_NONE | PAD_CTL_100K_PD);
145 mxc_iomux_set_pad(MX35_PIN_FEC_RDATA3, pad | PAD_CTL_HYS_SCHMITZ | \
146 PAD_CTL_PKE_ENABLE | PAD_CTL_100K_PD);
147 mxc_iomux_set_pad(MX35_PIN_FEC_TDATA3, pad | PAD_CTL_HYS_CMOS | \
148 PAD_CTL_PKE_NONE | PAD_CTL_100K_PD);
151 int board_early_init_f(void)
153 struct ccm_regs *ccm =
154 (struct ccm_regs *)IMX_CCM_BASE;
157 writel(readl(&ccm->cgr0) |
158 MXC_CCM_CGR0_EMI_MASK |
159 MXC_CCM_CGR0_EDI0_MASK |
160 MXC_CCM_CGR0_EPIT1_MASK,
163 writel(readl(&ccm->cgr1) |
164 MXC_CCM_CGR1_FEC_MASK |
165 MXC_CCM_CGR1_GPIO1_MASK |
166 MXC_CCM_CGR1_GPIO2_MASK |
167 MXC_CCM_CGR1_GPIO3_MASK |
168 MXC_CCM_CGR1_I2C1_MASK |
169 MXC_CCM_CGR1_I2C2_MASK |
170 MXC_CCM_CGR1_IPU_MASK,
174 __raw_writel(readl(&ccm->rcsr) | MXC_CCM_RCSR_NFC_FMS, &ccm->rcsr);
185 gd->bd->bi_arch_number = MACH_TYPE_MX35_3DS; /* board id for linux */
186 /* address of boot parameters */
187 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
192 static inline int pmic_detect(void)
196 id = pmic_reg_read(REG_IDENTIFICATION);
198 id = (id >> 6) & 0x7;
204 u32 get_board_rev(void)
210 return (get_cpu_rev() & ~(0xF << 8)) | (rev & 0xF) << 8;
213 int board_late_init(void)
219 mxc_request_iomux(MX35_PIN_WATCHDOG_RST, MUX_CONFIG_SION |
222 pmic_val = pmic_reg_read(REG_SETTING_0);
223 pmic_reg_write(REG_SETTING_0, pmic_val | VO_1_30V | VO_1_50V);
224 pmic_val = pmic_reg_read(REG_MODE_0);
225 pmic_reg_write(REG_MODE_0, pmic_val | VGEN3EN);
227 mxc_request_iomux(MX35_PIN_COMPARE, MUX_CONFIG_GPIO);
228 mxc_iomux_set_input(MUX_IN_GPIO1_IN_5, INPUT_CTL_PATH0);
230 mxc_gpio_direction(37, MXC_GPIO_DIRECTION_OUT);
234 val = mc9sdz60_reg_read(MC9SDZ60_REG_GPIO_1) | 0x04;
235 mc9sdz60_reg_write(MC9SDZ60_REG_GPIO_1, val);
238 val = mc9sdz60_reg_read(MC9SDZ60_REG_RESET_1) & 0x7F;
239 mc9sdz60_reg_write(MC9SDZ60_REG_RESET_1, val);
243 mc9sdz60_reg_write(MC9SDZ60_REG_RESET_1, val);
250 struct ccm_regs *ccm =
251 (struct ccm_regs *)IMX_CCM_BASE;
252 u32 cpu_rev = get_cpu_rev();
255 * Be sure that I2C is initialized to check
258 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
260 /* Print board revision */
261 printf("Board: MX35 PDK %d.0 ", ((get_board_rev() >> 8) + 1) & 0x0F);
263 /* Print CPU revision */
264 printf("i.MX35 %d.%d [", (cpu_rev & 0xF0) >> 4, cpu_rev & 0x0F);
266 switch (readl(&ccm->rcsr) & 0x0F) {
287 int board_eth_init(bd_t *bis)
290 #if defined(CONFIG_SMC911X)
291 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);