]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/mx5/soc.c
Merge branch 'master' of git://git.denx.de/u-boot-arm
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / mx5 / soc.c
1 /*
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>
28 #include <asm/arch/clock.h>
29 #include <asm/errno.h>
30 #include <asm/io.h>
31
32 #ifdef CONFIG_FSL_ESDHC
33 #include <fsl_esdhc.h>
34 #endif
35
36 #if !(defined(CONFIG_MX51) || defined(CONFIG_MX53))
37 #error "CPU_TYPE not defined"
38 #endif
39
40 u32 get_cpu_rev(void)
41 {
42 #ifdef CONFIG_MX51
43         int system_rev = 0x51000;
44 #else
45         int system_rev = 0x53000;
46 #endif
47         int reg = __raw_readl(ROM_SI_REV);
48
49 #if defined(CONFIG_MX51)
50         switch (reg) {
51         case 0x02:
52                 system_rev |= CHIP_REV_1_1;
53                 break;
54         case 0x10:
55                 if ((__raw_readl(GPIO1_BASE_ADDR + 0x0) & (0x1 << 22)) == 0)
56                         system_rev |= CHIP_REV_2_5;
57                 else
58                         system_rev |= CHIP_REV_2_0;
59                 break;
60         case 0x20:
61                 system_rev |= CHIP_REV_3_0;
62                 break;
63         default:
64                 system_rev |= CHIP_REV_1_0;
65                 break;
66         }
67 #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
77         return system_rev;
78 }
79
80 static char *get_reset_cause(void)
81 {
82         u32 cause;
83         struct src *src_regs = (struct src *)SRC_BASE_ADDR;
84
85         cause = readl(&src_regs->srsr);
86         writel(cause, &src_regs->srsr);
87
88         switch (cause) {
89         case 0x00001:
90                 return "POR";
91         case 0x00004:
92                 return "CSU";
93         case 0x00008:
94                 return "IPP USER";
95         case 0x00010:
96                 return "WDOG";
97         case 0x00020:
98                 return "JTAG HIGH-Z";
99         case 0x00040:
100                 return "JTAG SW";
101         case 0x10000:
102                 return "WARM BOOT";
103         default:
104                 return "unknown reset";
105         }
106 }
107
108 #if defined(CONFIG_DISPLAY_CPUINFO)
109 int print_cpuinfo(void)
110 {
111         u32 cpurev;
112
113         cpurev = get_cpu_rev();
114         printf("CPU:   Freescale i.MX%x family rev%d.%d at %d MHz\n",
115                 (cpurev & 0xFF000) >> 12,
116                 (cpurev & 0x000F0) >> 4,
117                 (cpurev & 0x0000F) >> 0,
118                 mxc_get_clock(MXC_ARM_CLK) / 1000000);
119         printf("Reset cause: %s\n", get_reset_cause());
120         return 0;
121 }
122 #endif
123
124 /*
125  * Initializes on-chip ethernet controllers.
126  * to override, implement board_eth_init()
127  */
128 #if defined(CONFIG_FEC_MXC)
129 extern int fecmxc_initialize(bd_t *bis);
130 #endif
131
132 int cpu_eth_init(bd_t *bis)
133 {
134         int rc = -ENODEV;
135
136 #if defined(CONFIG_FEC_MXC)
137         rc = fecmxc_initialize(bis);
138 #endif
139
140         return rc;
141 }
142
143 #if defined(CONFIG_FEC_MXC)
144 void imx_get_mac_from_fuse(unsigned char *mac)
145 {
146         int i;
147         struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
148         struct fuse_bank *bank = &iim->bank[1];
149         struct fuse_bank1_regs *fuse =
150                         (struct fuse_bank1_regs *)bank->fuse_regs;
151
152         for (i = 0; i < 6; i++)
153                 mac[i] = readl(&fuse->mac_addr[i]) & 0xff;
154 }
155 #endif
156
157 /*
158  * Initializes on-chip MMC controllers.
159  * to override, implement board_mmc_init()
160  */
161 int cpu_mmc_init(bd_t *bis)
162 {
163 #ifdef CONFIG_FSL_ESDHC
164         return fsl_esdhc_mmc_init(bis);
165 #else
166         return 0;
167 #endif
168 }
169
170
171 void reset_cpu(ulong addr)
172 {
173         __raw_writew(4, WDOG1_BASE_ADDR);
174 }