blob: 290011923eaf35699ddc9437f639702bf167de4b [file] [log] [blame]
Stefano Babica521a772010-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 Babicac41d4d2010-03-05 17:54:37 +010028#include <asm/arch/clock.h>
Stefano Babica521a772010-01-20 18:19:32 +010029#include <asm/errno.h>
30#include <asm/io.h>
31
Stefano Babicac41d4d2010-03-05 17:54:37 +010032#ifdef CONFIG_FSL_ESDHC
33#include <fsl_esdhc.h>
34#endif
35
Jason Liue7a7ed22010-10-18 11:09:26 +080036#if defined(CONFIG_MX51)
37#define CPU_TYPE 0x51000
38#else
39#error "CPU_TYPE not defined"
40#endif
41
Stefano Babica521a772010-01-20 18:19:32 +010042u32 get_cpu_rev(void)
43{
Jason Liue7a7ed22010-10-18 11:09:26 +080044 int system_rev = CPU_TYPE;
45 int reg = __raw_readl(ROM_SI_REV);
Stefano Babica521a772010-01-20 18:19:32 +010046
Stefano Babica521a772010-01-20 18:19:32 +010047 switch (reg) {
48 case 0x02:
Jason Liue7a7ed22010-10-18 11:09:26 +080049 system_rev |= CHIP_REV_1_1;
Stefano Babica521a772010-01-20 18:19:32 +010050 break;
51 case 0x10:
52 if ((__raw_readl(GPIO1_BASE_ADDR + 0x0) & (0x1 << 22)) == 0)
Jason Liue7a7ed22010-10-18 11:09:26 +080053 system_rev |= CHIP_REV_2_5;
Stefano Babica521a772010-01-20 18:19:32 +010054 else
Jason Liue7a7ed22010-10-18 11:09:26 +080055 system_rev |= CHIP_REV_2_0;
Stefano Babica521a772010-01-20 18:19:32 +010056 break;
57 case 0x20:
Jason Liue7a7ed22010-10-18 11:09:26 +080058 system_rev |= CHIP_REV_3_0;
Stefano Babica521a772010-01-20 18:19:32 +010059 break;
60 return system_rev;
61 default:
Jason Liue7a7ed22010-10-18 11:09:26 +080062 system_rev |= CHIP_REV_1_0;
Stefano Babica521a772010-01-20 18:19:32 +010063 break;
64 }
65 return system_rev;
66}
67
68
69#if defined(CONFIG_DISPLAY_CPUINFO)
70int print_cpuinfo(void)
71{
72 u32 cpurev;
73
74 cpurev = get_cpu_rev();
Jason Liue7a7ed22010-10-18 11:09:26 +080075 printf("CPU: Freescale i.MX%x family rev%d.%d at %d MHz\n",
76 (cpurev & 0xFF000) >> 12,
77 (cpurev & 0x000F0) >> 4,
78 (cpurev & 0x0000F) >> 0,
Stefano Babicac41d4d2010-03-05 17:54:37 +010079 mxc_get_clock(MXC_ARM_CLK) / 1000000);
Stefano Babica521a772010-01-20 18:19:32 +010080 return 0;
81}
82#endif
83
84/*
85 * Initializes on-chip ethernet controllers.
86 * to override, implement board_eth_init()
87 */
88#if defined(CONFIG_FEC_MXC)
89extern int fecmxc_initialize(bd_t *bis);
90#endif
91
92int cpu_eth_init(bd_t *bis)
93{
94 int rc = -ENODEV;
95
96#if defined(CONFIG_FEC_MXC)
97 rc = fecmxc_initialize(bis);
98#endif
99
100 return rc;
101}
102
Liu Hui-R643434df66192010-11-18 23:45:55 +0000103#if defined(CONFIG_FEC_MXC)
104void imx_get_mac_from_fuse(unsigned char *mac)
105{
106 int i;
107 struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
108 struct fuse_bank *bank = &iim->bank[1];
109 struct fuse_bank1_regs *fuse =
110 (struct fuse_bank1_regs *)bank->fuse_regs;
111
112 for (i = 0; i < 6; i++)
113 mac[i] = readl(&fuse->mac_addr[i]) & 0xff;
114}
115#endif
116
Stefano Babica521a772010-01-20 18:19:32 +0100117/*
118 * Initializes on-chip MMC controllers.
119 * to override, implement board_mmc_init()
120 */
121int cpu_mmc_init(bd_t *bis)
122{
123#ifdef CONFIG_FSL_ESDHC
124 return fsl_esdhc_mmc_init(bis);
125#else
126 return 0;
127#endif
128}
129
130
131void reset_cpu(ulong addr)
132{
133 __raw_writew(4, WDOG1_BASE_ADDR);
134}