blob: a10d12d97dcdc9739de53e66db9e15cfadbb54f2 [file] [log] [blame]
Jason Liu18936ee2011-11-25 00:18:01 +00001/*
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/errno.h>
28#include <asm/io.h>
29#include <asm/arch/imx-regs.h>
30#include <asm/arch/clock.h>
31#include <asm/arch/sys_proto.h>
Fabio Estevam6a376042012-04-29 08:11:13 +000032#include <asm/arch/crm_regs.h>
Eric Nelsone1eb75b2012-09-23 07:30:55 +000033#include <ipu_pixfmt.h>
Jason Liu18936ee2011-11-25 00:18:01 +000034
35#ifdef CONFIG_FSL_ESDHC
36#include <fsl_esdhc.h>
37#endif
38
Fabio Estevam1fc56f12012-04-30 08:12:03 +000039char *get_reset_cause(void)
Jason Liu18936ee2011-11-25 00:18:01 +000040{
41 u32 cause;
42 struct src *src_regs = (struct src *)SRC_BASE_ADDR;
43
44 cause = readl(&src_regs->srsr);
45 writel(cause, &src_regs->srsr);
46
47 switch (cause) {
48 case 0x00001:
Fabio Estevamcece2622012-03-13 07:26:48 +000049 case 0x00011:
Jason Liu18936ee2011-11-25 00:18:01 +000050 return "POR";
51 case 0x00004:
52 return "CSU";
53 case 0x00008:
54 return "IPP USER";
55 case 0x00010:
56 return "WDOG";
57 case 0x00020:
58 return "JTAG HIGH-Z";
59 case 0x00040:
60 return "JTAG SW";
61 case 0x10000:
62 return "WARM BOOT";
63 default:
64 return "unknown reset";
65 }
66}
67
68#if defined(CONFIG_DISPLAY_CPUINFO)
Fabio Estevama7683862012-03-20 04:21:45 +000069
Otavio Salvadore972d722012-06-30 05:07:32 +000070static const char *get_imx_type(u32 imxtype)
Fabio Estevama7683862012-03-20 04:21:45 +000071{
72 switch (imxtype) {
73 case 0x63:
74 return "6Q"; /* Quad-core version of the mx6 */
75 case 0x61:
76 return "6DS"; /* Dual/Solo version of the mx6 */
77 case 0x60:
78 return "6SL"; /* Solo-Lite version of the mx6 */
79 case 0x51:
80 return "51";
81 case 0x53:
82 return "53";
83 default:
Otavio Salvadore972d722012-06-30 05:07:32 +000084 return "??";
Fabio Estevama7683862012-03-20 04:21:45 +000085 }
86}
87
Jason Liu18936ee2011-11-25 00:18:01 +000088int print_cpuinfo(void)
89{
90 u32 cpurev;
91
92 cpurev = get_cpu_rev();
Fabio Estevama7683862012-03-20 04:21:45 +000093
94 printf("CPU: Freescale i.MX%s rev%d.%d at %d MHz\n",
95 get_imx_type((cpurev & 0xFF000) >> 12),
Jason Liu18936ee2011-11-25 00:18:01 +000096 (cpurev & 0x000F0) >> 4,
97 (cpurev & 0x0000F) >> 0,
98 mxc_get_clock(MXC_ARM_CLK) / 1000000);
99 printf("Reset cause: %s\n", get_reset_cause());
100 return 0;
101}
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
Benoît Thébaudeauecb0f312012-08-17 10:42:55 +0000115#ifdef CONFIG_FSL_ESDHC
Jason Liu18936ee2011-11-25 00:18:01 +0000116/*
117 * Initializes on-chip MMC controllers.
118 * to override, implement board_mmc_init()
119 */
120int cpu_mmc_init(bd_t *bis)
121{
Jason Liu18936ee2011-11-25 00:18:01 +0000122 return fsl_esdhc_mmc_init(bis);
Jason Liu18936ee2011-11-25 00:18:01 +0000123}
Benoît Thébaudeauecb0f312012-08-17 10:42:55 +0000124#endif
Jason Liu18936ee2011-11-25 00:18:01 +0000125
126void reset_cpu(ulong addr)
127{
128 __raw_writew(4, WDOG1_BASE_ADDR);
129}
Fabio Estevam6a376042012-04-29 08:11:13 +0000130
131u32 get_ahb_clk(void)
132{
133 struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
134 u32 reg, ahb_podf;
135
136 reg = __raw_readl(&imx_ccm->cbcdr);
137 reg &= MXC_CCM_CBCDR_AHB_PODF_MASK;
138 ahb_podf = reg >> MXC_CCM_CBCDR_AHB_PODF_OFFSET;
139
140 return get_periph_clk() / (ahb_podf + 1);
141}
Eric Nelsone1eb75b2012-09-23 07:30:55 +0000142
143#if defined(CONFIG_VIDEO_IPUV3)
144void arch_preboot_os(void)
145{
146 /* disable video before launching O/S */
147 ipuv3_fb_shutdown();
148}
149#endif