3 * Sascha Hauer, Pengutronix
5 * (C) Copyright 2009 Freescale Semiconductor, Inc.
7 * See file CREDITS for list of people who contributed to this
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.
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.
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,
27 #include <asm/errno.h>
29 #include <asm/arch/imx-regs.h>
30 #include <asm/arch/clock.h>
31 #include <asm/arch/sys_proto.h>
32 #include <asm/arch/crm_regs.h>
33 #include <ipu_pixfmt.h>
35 #ifdef CONFIG_FSL_ESDHC
36 #include <fsl_esdhc.h>
39 char *get_reset_cause(void)
42 struct src *src_regs = (struct src *)SRC_BASE_ADDR;
44 cause = readl(&src_regs->srsr);
45 writel(cause, &src_regs->srsr);
64 return "unknown reset";
68 #if defined(CONFIG_MX53) || defined(CONFIG_MX6)
69 #if defined(CONFIG_MX53)
70 #define MEMCTL_BASE ESDCTL_BASE_ADDR;
72 #define MEMCTL_BASE MMDC_P0_BASE_ADDR;
74 static const unsigned char col_lookup[] = {9, 10, 11, 8, 12, 9, 9, 9};
75 static const unsigned char bank_lookup[] = {3, 2};
77 struct esd_mmdc_regs {
96 #define ESD_MMDC_CTL_GET_ROW(mdctl) ((ctl >> 24) & 7)
97 #define ESD_MMDC_CTL_GET_COLUMN(mdctl) ((ctl >> 20) & 7)
98 #define ESD_MMDC_CTL_GET_WIDTH(mdctl) ((ctl >> 16) & 3)
99 #define ESD_MMDC_CTL_GET_CS1(mdctl) ((ctl >> 30) & 1)
100 #define ESD_MMDC_MISC_GET_BANK(mdmisc) ((misc >> 5) & 1)
102 unsigned imx_ddr_size(void)
104 struct esd_mmdc_regs *mem = (struct esd_mmdc_regs *)MEMCTL_BASE;
105 unsigned ctl = readl(&mem->ctl);
106 unsigned misc = readl(&mem->misc);
107 int bits = 11 + 0 + 0 + 1; /* row + col + bank + width */
109 bits += ESD_MMDC_CTL_GET_ROW(ctl);
110 bits += col_lookup[ESD_MMDC_CTL_GET_COLUMN(ctl)];
111 bits += bank_lookup[ESD_MMDC_MISC_GET_BANK(misc)];
112 bits += ESD_MMDC_CTL_GET_WIDTH(ctl);
113 bits += ESD_MMDC_CTL_GET_CS1(ctl);
118 #if defined(CONFIG_DISPLAY_CPUINFO)
120 const char *get_imx_type(u32 imxtype)
124 return "6Q"; /* Quad-core version of the mx6 */
126 return "6DL"; /* Dual Lite version of the mx6 */
127 case MXC_CPU_MX6SOLO:
128 return "6SOLO"; /* Solo version of the mx6 */
130 return "6SL"; /* Solo-Lite version of the mx6 */
140 int print_cpuinfo(void)
144 cpurev = get_cpu_rev();
146 printf("CPU: Freescale i.MX%s rev%d.%d at %d MHz\n",
147 get_imx_type((cpurev & 0xFF000) >> 12),
148 (cpurev & 0x000F0) >> 4,
149 (cpurev & 0x0000F) >> 0,
150 mxc_get_clock(MXC_ARM_CLK) / 1000000);
151 printf("Reset cause: %s\n", get_reset_cause());
156 int cpu_eth_init(bd_t *bis)
160 #if defined(CONFIG_FEC_MXC)
161 rc = fecmxc_initialize(bis);
167 #ifdef CONFIG_FSL_ESDHC
169 * Initializes on-chip MMC controllers.
170 * to override, implement board_mmc_init()
172 int cpu_mmc_init(bd_t *bis)
174 return fsl_esdhc_mmc_init(bis);
178 u32 get_ahb_clk(void)
180 struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
183 reg = __raw_readl(&imx_ccm->cbcdr);
184 reg &= MXC_CCM_CBCDR_AHB_PODF_MASK;
185 ahb_podf = reg >> MXC_CCM_CBCDR_AHB_PODF_OFFSET;
187 return get_periph_clk() / (ahb_podf + 1);
190 #if defined(CONFIG_VIDEO_IPUV3)
191 void arch_preboot_os(void)
193 /* disable video before launching O/S */