2 * Freescale i.MX28 common code
4 * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
5 * on behalf of DENX Software Engineering GmbH
7 * Based on code from LTIB:
8 * Copyright (C) 2010 Freescale Semiconductor, Inc.
10 * See file CREDITS for list of people who contributed to this
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 #include <asm/errno.h>
32 #include <asm/arch/clock.h>
33 #include <asm/arch/gpio.h>
34 #include <asm/arch/iomux.h>
35 #include <asm/arch/imx-regs.h>
36 #include <asm/arch/sys_proto.h>
38 /* 1 second delay should be plenty of time for block reset. */
39 #define RESET_MAX_TIMEOUT 1000000
41 #define MX28_BLOCK_SFTRST (1 << 31)
42 #define MX28_BLOCK_CLKGATE (1 << 30)
44 /* Lowlevel init isn't used on i.MX28, so just have a dummy here */
45 inline void lowlevel_init(void) {}
47 void reset_cpu(ulong ignored) __attribute__((noreturn));
49 void reset_cpu(ulong ignored)
52 struct mx28_rtc_regs *rtc_regs =
53 (struct mx28_rtc_regs *)MXS_RTC_BASE;
55 /* Wait 1 uS before doing the actual watchdog reset */
56 writel(1, &rtc_regs->hw_rtc_watchdog);
57 writel(RTC_CTRL_WATCHDOGEN, &rtc_regs->hw_rtc_ctrl_set);
59 /* Endless loop, reset will exit from here */
64 int mx28_wait_mask_set(struct mx28_register *reg, uint32_t mask, int timeout)
67 if ((readl(®->reg) & mask) == mask)
75 int mx28_wait_mask_clr(struct mx28_register *reg, uint32_t mask, int timeout)
78 if ((readl(®->reg) & mask) == 0)
86 int mx28_reset_block(struct mx28_register *reg)
89 writel(MX28_BLOCK_SFTRST, ®->reg_clr);
91 if (mx28_wait_mask_clr(reg, MX28_BLOCK_SFTRST, RESET_MAX_TIMEOUT))
95 writel(MX28_BLOCK_CLKGATE, ®->reg_clr);
98 writel(MX28_BLOCK_SFTRST, ®->reg_set);
100 /* Wait for CLKGATE being set */
101 if (mx28_wait_mask_set(reg, MX28_BLOCK_CLKGATE, RESET_MAX_TIMEOUT))
105 writel(MX28_BLOCK_SFTRST, ®->reg_clr);
107 if (mx28_wait_mask_clr(reg, MX28_BLOCK_SFTRST, RESET_MAX_TIMEOUT))
111 writel(MX28_BLOCK_CLKGATE, ®->reg_clr);
113 if (mx28_wait_mask_clr(reg, MX28_BLOCK_CLKGATE, RESET_MAX_TIMEOUT))
119 #ifdef CONFIG_ARCH_CPU_INIT
120 int arch_cpu_init(void)
122 struct mx28_clkctrl_regs *clkctrl_regs =
123 (struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE;
128 /* Clear bypass bit */
129 writel(CLKCTRL_CLKSEQ_BYPASS_GPMI,
130 &clkctrl_regs->hw_clkctrl_clkseq_set);
132 /* Set GPMI clock to ref_gpmi / 12 */
133 clrsetbits_le32(&clkctrl_regs->hw_clkctrl_gpmi,
134 CLKCTRL_GPMI_CLKGATE | CLKCTRL_GPMI_DIV_MASK, 1);
139 * Configure GPIO unit
147 #if defined(CONFIG_DISPLAY_CPUINFO)
148 int print_cpuinfo(void)
150 printf("Freescale i.MX28 family\n");
155 int do_mx28_showclocks(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
157 printf("CPU: %3d MHz\n", mxc_get_clock(MXC_ARM_CLK) / 1000000);
158 printf("BUS: %3d MHz\n", mxc_get_clock(MXC_AHB_CLK) / 1000000);
159 printf("EMI: %3d MHz\n", mxc_get_clock(MXC_EMI_CLK));
160 printf("GPMI: %3d MHz\n", mxc_get_clock(MXC_GPMI_CLK) / 1000000);
165 * Initializes on-chip ethernet controllers.
167 #ifdef CONFIG_CMD_NET
168 int cpu_eth_init(bd_t *bis)
170 struct mx28_clkctrl_regs *clkctrl_regs =
171 (struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE;
173 /* Turn on ENET clocks */
174 clrbits_le32(&clkctrl_regs->hw_clkctrl_enet,
175 CLKCTRL_ENET_SLEEP | CLKCTRL_ENET_DISABLE);
177 /* Set up ENET PLL for 50 MHz */
178 /* Power on ENET PLL */
179 writel(CLKCTRL_PLL2CTRL0_POWER,
180 &clkctrl_regs->hw_clkctrl_pll2ctrl0_set);
184 /* Gate on ENET PLL */
185 writel(CLKCTRL_PLL2CTRL0_CLKGATE,
186 &clkctrl_regs->hw_clkctrl_pll2ctrl0_clr);
188 /* Enable pad output */
189 setbits_le32(&clkctrl_regs->hw_clkctrl_enet, CLKCTRL_ENET_CLK_OUT_EN);
196 clocks, CONFIG_SYS_MAXARGS, 1, do_mx28_showclocks,