2 * Copyright (C) 2011 Lothar Waßmann <LW@KARO-electronics.de>
3 * based on: board/freesclae/mx28_evk.c (C) 2010 Freescale Semiconductor, Inc.
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
28 #include <asm/arch/iomux-mx28.h>
29 #include <asm/arch/clock.h>
30 #include <asm/arch/imx-regs.h>
31 #include <asm/arch/regs-pinctrl.h>
32 #include <asm/arch/regs-clkctrl.h>
33 #include <asm/arch/regs-ocotp.h>
34 #include <asm/arch/sys_proto.h>
38 #include <imx_ssp_mmc.h>
40 DECLARE_GLOBAL_DATA_PTR;
45 int board_early_init_f(void)
47 /* IO0 clock at 480MHz */
48 mx28_set_ioclk(MXC_IOCLK0, 480000);
49 /* IO1 clock at 480MHz */
50 mx28_set_ioclk(MXC_IOCLK1, 480000);
52 /* SSP0 clock at 96MHz */
53 mx28_set_sspclk(MXC_SSPCLK0, 96000, 0);
54 /* SSP2 clock at 96MHz */
55 mx28_set_sspclk(MXC_SSPCLK2, 96000, 0);
60 void coloured_LED_init(void)
63 gpio_set_value(MX28_PAD_ENET0_RXD3__GPIO_4_10, 0);
68 /* Address of boot parameters */
69 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x1000;
75 return mx28_dram_init();
79 int board_mmc_init(bd_t *bis)
81 return mxsmmc_initialize(bis, 0, NULL);
83 #endif /* CONFIG_CMD_MMC */
86 #ifdef CONFIG_GET_FEC_MAC_ADDR_FROM_IIM
88 #ifdef CONFIG_FEC_MXC_MULTI
94 static int fec_get_mac_addr(int index)
98 struct mx28_ocotp_regs *ocotp_regs =
99 (struct mx28_ocotp_regs *)MXS_OCOTP_BASE;
100 u32 *cust = &ocotp_regs->hw_ocotp_cust0;
102 char env_name[] = "eth.addr";
104 if (index < 0 || index > FEC_MAX_IDX)
107 /* set this bit to open the OTP banks for reading */
108 writel(OCOTP_CTRL_RD_BANK_OPEN,
109 &ocotp_regs->hw_ocotp_ctrl_set);
111 /* wait until OTP contents are readable */
112 while (OCOTP_CTRL_BUSY & readl(&ocotp_regs->hw_ocotp_ctrl)) {
118 val1 = readl(&cust[index * 8]);
119 val2 = readl(&cust[index * 8 + 4]);
120 if ((val1 | val2) == 0)
122 snprintf(mac, sizeof(mac), "%02x:%02x:%02x:%02x:%02x:%02x",
123 (val1 >> 24) & 0xFF, (val1 >> 16) & 0xFF,
124 (val1 >> 8) & 0xFF, (val1 >> 0) & 0xFF,
125 (val2 >> 24) & 0xFF, (val2 >> 16) & 0xFF);
127 snprintf(env_name, sizeof(env_name), "ethaddr");
129 snprintf(env_name, sizeof(env_name), "eth%daddr", index);
131 setenv(env_name, mac);
134 #endif /* CONFIG_GET_FEC_MAC_ADDR_FROM_IIM */
136 static iomux_cfg_t tx28_fec_pads[] = {
137 MX28_PAD_ENET0_RX_EN__ENET0_RX_EN,
138 MX28_PAD_ENET0_RXD0__ENET0_RXD0,
139 MX28_PAD_ENET0_RXD1__ENET0_RXD1,
142 int board_eth_init(bd_t *bis)
146 /* Reset the external phy */
147 gpio_direction_output(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 0);
149 /* Power on the external phy */
150 gpio_direction_output(MX28_PAD_PWM4__GPIO_3_29, 1);
152 /* Pull strap pins to high */
153 gpio_direction_output(MX28_PAD_ENET0_RX_EN__GPIO_4_2, 1);
154 gpio_direction_output(MX28_PAD_ENET0_RXD0__GPIO_4_3, 1);
155 gpio_direction_output(MX28_PAD_ENET0_RXD1__GPIO_4_4, 1);
156 gpio_direction_input(MX28_PAD_ENET0_TX_CLK__GPIO_4_5);
159 gpio_set_value(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 1);
162 mxs_iomux_setup_multiple_pads(tx28_fec_pads, ARRAY_SIZE(tx28_fec_pads));
164 ret = cpu_eth_init(bis);
166 printf("cpu_eth_init() failed: %d\n", ret);
170 ret = fec_get_mac_addr(0);
172 printf("Failed to read FEC0 MAC address from OCOTP\n");
175 #ifdef CONFIG_FEC_MXC_MULTI
176 if (getenv("ethaddr")) {
177 ret = fecmxc_initialize_multi(bis, 0, 0, MXS_ENET0_BASE);
179 printf("FEC MXS: Unable to init FEC0\n");
184 ret = fec_get_mac_addr(1);
186 printf("Failed to read FEC1 MAC address from OCOTP\n");
189 if (getenv("eth1addr")) {
190 ret = fecmxc_initialize_multi(bis, 1, 1, MXS_ENET1_BASE);
192 printf("FEC MXS: Unable to init FEC1\n");
198 if (getenv("ethaddr")) {
199 ret = fecmxc_initialize(bis);
204 #endif /* CONFIG_FEC_MXC */
212 void show_activity(int arg)
214 static int led_state = LED_STATE_INIT;
217 if (led_state == LED_STATE_INIT) {
219 gpio_set_value(MX28_PAD_ENET0_RXD3__GPIO_4_10, 1);
220 led_state = LED_STATE_ON;
222 if (get_timer(last) > CONFIG_SYS_HZ) {
224 if (led_state == LED_STATE_ON) {
225 gpio_set_value(MX28_PAD_ENET0_RXD3__GPIO_4_10, 0);
227 gpio_set_value(MX28_PAD_ENET0_RXD3__GPIO_4_10, 1);
229 led_state = 1 - led_state;