blob: 08c7892866c2df48732d15b9aa64329d0b009b75 [file] [log] [blame]
Shawn Guo9daaf31a2011-10-17 08:42:17 +08001/*
2 * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright 2011 Linaro Ltd.
4 *
5 * The code contained herein is licensed under the GNU General Public
6 * License. You may obtain a copy of the GNU General Public License
7 * Version 2 or later at the following locations:
8 *
9 * http://www.opensource.org/licenses/gpl-license.html
10 * http://www.gnu.org/copyleft/gpl.html
11 */
12
Shawn Guoff4ab232014-05-20 15:34:06 +080013#include <linux/io.h>
Shawn Guo9daaf31a2011-10-17 08:42:17 +080014#include <linux/irq.h>
Fabio Estevam11d973d2018-07-09 15:19:15 -030015#include <linux/of_address.h>
Shawn Guo9daaf31a2011-10-17 08:42:17 +080016#include <linux/of_irq.h>
17#include <linux/of_platform.h>
18#include <asm/mach/arch.h>
19#include <asm/mach/time.h>
Shawn Guo9daaf31a2011-10-17 08:42:17 +080020
Shawn Guoe3372472012-09-13 21:01:00 +080021#include "common.h"
Shawn Guoff4ab232014-05-20 15:34:06 +080022#include "hardware.h"
Shawn Guoe3372472012-09-13 21:01:00 +080023
Shawn Guoff4ab232014-05-20 15:34:06 +080024static void __init imx51_init_early(void)
25{
26 mxc_set_cpu_type(MXC_CPU_MX51);
27}
28
29/*
30 * The MIPI HSC unit has been removed from the i.MX51 Reference Manual by
31 * the Freescale marketing division. However this did not remove the
32 * hardware from the chip which still needs to be configured for proper
33 * IPU support.
34 */
35#define MX51_MIPI_HSC_BASE 0x83fdc000
36static void __init imx51_ipu_mipi_setup(void)
37{
38 void __iomem *hsc_addr;
39
40 hsc_addr = ioremap(MX51_MIPI_HSC_BASE, SZ_16K);
41 WARN_ON(!hsc_addr);
42
43 /* setup MIPI module to legacy mode */
Johannes Bergc5531382016-01-27 17:59:35 +010044 imx_writel(0xf00, hsc_addr);
Shawn Guoff4ab232014-05-20 15:34:06 +080045
46 /* CSI mode: reserved; DI control mode: legacy (from Freescale BSP) */
Johannes Bergc5531382016-01-27 17:59:35 +010047 imx_writel(imx_readl(hsc_addr + 0x800) | 0x30ff, hsc_addr + 0x800);
Shawn Guoff4ab232014-05-20 15:34:06 +080048
49 iounmap(hsc_addr);
50}
51
Fabio Estevam11d973d2018-07-09 15:19:15 -030052static void __init imx51_m4if_setup(void)
53{
54 void __iomem *m4if_base;
55 struct device_node *np;
56
57 np = of_find_compatible_node(NULL, NULL, "fsl,imx51-m4if");
58 if (!np)
59 return;
60
61 m4if_base = of_iomap(np, 0);
Wen Yang0c17e832019-03-01 16:56:46 +080062 of_node_put(np);
Fabio Estevam11d973d2018-07-09 15:19:15 -030063 if (!m4if_base) {
64 pr_err("Unable to map M4IF registers\n");
65 return;
66 }
67
68 /*
69 * Configure VPU and IPU with higher priorities
70 * in order to avoid artifacts during video playback
71 */
72 writel_relaxed(0x00000203, m4if_base + 0x40);
73 writel_relaxed(0x00000000, m4if_base + 0x44);
74 writel_relaxed(0x00120125, m4if_base + 0x9c);
75 writel_relaxed(0x001901A3, m4if_base + 0x48);
76 iounmap(m4if_base);
77}
78
Shawn Guo9daaf31a2011-10-17 08:42:17 +080079static void __init imx51_dt_init(void)
80{
Shawn Guoff4ab232014-05-20 15:34:06 +080081 imx51_ipu_mipi_setup();
82 imx_src_init();
Fabio Estevam11d973d2018-07-09 15:19:15 -030083 imx51_m4if_setup();
Fabio Estevam26b754f2018-07-10 13:31:48 -030084 imx5_pmu_init();
Alexander Shiyan463f90f2016-06-25 08:26:15 +030085 imx_aips_allow_unprivileged_access("fsl,imx51-aipstz");
Shawn Guo9daaf31a2011-10-17 08:42:17 +080086}
87
Shawn Guoff4ab232014-05-20 15:34:06 +080088static void __init imx51_init_late(void)
89{
90 mx51_neon_fixup();
91 imx51_pm_init();
92}
93
Shawn Guo8756dd92014-07-01 16:03:00 +080094static const char * const imx51_dt_board_compat[] __initconst = {
Sascha Hauer3f8976d2012-02-17 12:07:00 +010095 "fsl,imx51",
Shawn Guo9daaf31a2011-10-17 08:42:17 +080096 NULL
97};
98
99DT_MACHINE_START(IMX51_DT, "Freescale i.MX51 (Device Tree Support)")
Shawn Guo9daaf31a2011-10-17 08:42:17 +0800100 .init_early = imx51_init_early,
Shawn Guo9daaf31a2011-10-17 08:42:17 +0800101 .init_machine = imx51_dt_init,
Shawn Guo8321b752012-04-26 11:42:34 +0800102 .init_late = imx51_init_late,
Shawn Guo9daaf31a2011-10-17 08:42:17 +0800103 .dt_compat = imx51_dt_board_compat,
Shawn Guo9daaf31a2011-10-17 08:42:17 +0800104MACHINE_END