blob: 09500b3b9f4d0eaa5a98dfaf62e19f10a82425f6 [file] [log] [blame]
Stefano Babic64fdf452010-01-20 18:19:32 +01001/*
2 * (C) Copyright 2007
3 * Sascha Hauer, Pengutronix
4 *
5 * (C) Copyright 2009 Freescale Semiconductor, Inc.
6 *
7 * See file CREDITS for list of people who contributed to this
8 * project.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 */
25
26#include <common.h>
27#include <asm/arch/imx-regs.h>
Stefano Babice4d34492010-03-05 17:54:37 +010028#include <asm/arch/clock.h>
Stefano Babic64fdf452010-01-20 18:19:32 +010029#include <asm/errno.h>
30#include <asm/io.h>
31
Stefano Babice4d34492010-03-05 17:54:37 +010032#ifdef CONFIG_FSL_ESDHC
33#include <fsl_esdhc.h>
34#endif
35
Liu Hui-R64343595f3e52011-01-03 22:27:35 +000036#if !(defined(CONFIG_MX51) || defined(CONFIG_MX53))
Jason Liuff9f4752010-10-18 11:09:26 +080037#error "CPU_TYPE not defined"
38#endif
39
Stefano Babic64fdf452010-01-20 18:19:32 +010040u32 get_cpu_rev(void)
41{
Liu Hui-R64343595f3e52011-01-03 22:27:35 +000042#ifdef CONFIG_MX51
43 int system_rev = 0x51000;
44#else
45 int system_rev = 0x53000;
46#endif
Jason Liuff9f4752010-10-18 11:09:26 +080047 int reg = __raw_readl(ROM_SI_REV);
Stefano Babic64fdf452010-01-20 18:19:32 +010048
Liu Hui-R64343595f3e52011-01-03 22:27:35 +000049#if defined(CONFIG_MX51)
Stefano Babic64fdf452010-01-20 18:19:32 +010050 switch (reg) {
51 case 0x02:
Jason Liuff9f4752010-10-18 11:09:26 +080052 system_rev |= CHIP_REV_1_1;
Stefano Babic64fdf452010-01-20 18:19:32 +010053 break;
54 case 0x10:
55 if ((__raw_readl(GPIO1_BASE_ADDR + 0x0) & (0x1 << 22)) == 0)
Jason Liuff9f4752010-10-18 11:09:26 +080056 system_rev |= CHIP_REV_2_5;
Stefano Babic64fdf452010-01-20 18:19:32 +010057 else
Jason Liuff9f4752010-10-18 11:09:26 +080058 system_rev |= CHIP_REV_2_0;
Stefano Babic64fdf452010-01-20 18:19:32 +010059 break;
60 case 0x20:
Jason Liuff9f4752010-10-18 11:09:26 +080061 system_rev |= CHIP_REV_3_0;
Stefano Babic64fdf452010-01-20 18:19:32 +010062 break;
Stefano Babic64fdf452010-01-20 18:19:32 +010063 default:
Jason Liuff9f4752010-10-18 11:09:26 +080064 system_rev |= CHIP_REV_1_0;
Stefano Babic64fdf452010-01-20 18:19:32 +010065 break;
66 }
Liu Hui-R64343595f3e52011-01-03 22:27:35 +000067#else
68 switch (reg) {
69 case 0x20:
70 system_rev |= CHIP_REV_2_0;
71 break;
72 default:
73 system_rev |= CHIP_REV_1_0;
74 break;
75 }
76#endif
Stefano Babic64fdf452010-01-20 18:19:32 +010077 return system_rev;
78}
79
80
81#if defined(CONFIG_DISPLAY_CPUINFO)
82int print_cpuinfo(void)
83{
84 u32 cpurev;
85
86 cpurev = get_cpu_rev();
Jason Liuff9f4752010-10-18 11:09:26 +080087 printf("CPU: Freescale i.MX%x family rev%d.%d at %d MHz\n",
88 (cpurev & 0xFF000) >> 12,
89 (cpurev & 0x000F0) >> 4,
90 (cpurev & 0x0000F) >> 0,
Stefano Babice4d34492010-03-05 17:54:37 +010091 mxc_get_clock(MXC_ARM_CLK) / 1000000);
Stefano Babic64fdf452010-01-20 18:19:32 +010092 return 0;
93}
94#endif
95
96/*
97 * Initializes on-chip ethernet controllers.
98 * to override, implement board_eth_init()
99 */
100#if defined(CONFIG_FEC_MXC)
101extern int fecmxc_initialize(bd_t *bis);
102#endif
103
104int cpu_eth_init(bd_t *bis)
105{
106 int rc = -ENODEV;
107
108#if defined(CONFIG_FEC_MXC)
109 rc = fecmxc_initialize(bis);
110#endif
111
112 return rc;
113}
114
Liu Hui-R64343565e39c2010-11-18 23:45:55 +0000115#if defined(CONFIG_FEC_MXC)
116void imx_get_mac_from_fuse(unsigned char *mac)
117{
118 int i;
119 struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
120 struct fuse_bank *bank = &iim->bank[1];
121 struct fuse_bank1_regs *fuse =
122 (struct fuse_bank1_regs *)bank->fuse_regs;
123
124 for (i = 0; i < 6; i++)
125 mac[i] = readl(&fuse->mac_addr[i]) & 0xff;
126}
127#endif
128
Stefano Babic64fdf452010-01-20 18:19:32 +0100129/*
130 * Initializes on-chip MMC controllers.
131 * to override, implement board_mmc_init()
132 */
133int cpu_mmc_init(bd_t *bis)
134{
135#ifdef CONFIG_FSL_ESDHC
136 return fsl_esdhc_mmc_init(bis);
137#else
138 return 0;
139#endif
140}
141
142
143void reset_cpu(ulong addr)
144{
145 __raw_writew(4, WDOG1_BASE_ADDR);
146}