blob: 8b748a1854d796b0a18b4375d39e157e9a5b3915 [file] [log] [blame]
Thomas Gleixnerfcaf2032019-05-27 08:55:08 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Shawn Guo9daaf31a2011-10-17 08:42:17 +08002/*
3 * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
4 * Copyright 2011 Linaro Ltd.
Shawn Guo9daaf31a2011-10-17 08:42:17 +08005 */
6
Shawn Guoff4ab232014-05-20 15:34:06 +08007#include <linux/io.h>
Shawn Guo9daaf31a2011-10-17 08:42:17 +08008#include <linux/irq.h>
Fabio Estevam11d973d2018-07-09 15:19:15 -03009#include <linux/of_address.h>
Shawn Guo9daaf31a2011-10-17 08:42:17 +080010#include <linux/of_irq.h>
11#include <linux/of_platform.h>
12#include <asm/mach/arch.h>
13#include <asm/mach/time.h>
Shawn Guo9daaf31a2011-10-17 08:42:17 +080014
Shawn Guoe3372472012-09-13 21:01:00 +080015#include "common.h"
Shawn Guoff4ab232014-05-20 15:34:06 +080016#include "hardware.h"
Shawn Guoe3372472012-09-13 21:01:00 +080017
Shawn Guoff4ab232014-05-20 15:34:06 +080018static void __init imx51_init_early(void)
19{
20 mxc_set_cpu_type(MXC_CPU_MX51);
21}
22
23/*
24 * The MIPI HSC unit has been removed from the i.MX51 Reference Manual by
25 * the Freescale marketing division. However this did not remove the
26 * hardware from the chip which still needs to be configured for proper
27 * IPU support.
28 */
29#define MX51_MIPI_HSC_BASE 0x83fdc000
30static void __init imx51_ipu_mipi_setup(void)
31{
32 void __iomem *hsc_addr;
33
34 hsc_addr = ioremap(MX51_MIPI_HSC_BASE, SZ_16K);
35 WARN_ON(!hsc_addr);
36
37 /* setup MIPI module to legacy mode */
Johannes Bergc5531382016-01-27 17:59:35 +010038 imx_writel(0xf00, hsc_addr);
Shawn Guoff4ab232014-05-20 15:34:06 +080039
40 /* CSI mode: reserved; DI control mode: legacy (from Freescale BSP) */
Johannes Bergc5531382016-01-27 17:59:35 +010041 imx_writel(imx_readl(hsc_addr + 0x800) | 0x30ff, hsc_addr + 0x800);
Shawn Guoff4ab232014-05-20 15:34:06 +080042
43 iounmap(hsc_addr);
44}
45
Fabio Estevam11d973d2018-07-09 15:19:15 -030046static void __init imx51_m4if_setup(void)
47{
48 void __iomem *m4if_base;
49 struct device_node *np;
50
51 np = of_find_compatible_node(NULL, NULL, "fsl,imx51-m4if");
52 if (!np)
53 return;
54
55 m4if_base = of_iomap(np, 0);
Wen Yang0c17e832019-03-01 16:56:46 +080056 of_node_put(np);
Fabio Estevam11d973d2018-07-09 15:19:15 -030057 if (!m4if_base) {
58 pr_err("Unable to map M4IF registers\n");
59 return;
60 }
61
62 /*
63 * Configure VPU and IPU with higher priorities
64 * in order to avoid artifacts during video playback
65 */
66 writel_relaxed(0x00000203, m4if_base + 0x40);
67 writel_relaxed(0x00000000, m4if_base + 0x44);
68 writel_relaxed(0x00120125, m4if_base + 0x9c);
69 writel_relaxed(0x001901A3, m4if_base + 0x48);
70 iounmap(m4if_base);
71}
72
Shawn Guo9daaf31a2011-10-17 08:42:17 +080073static void __init imx51_dt_init(void)
74{
Shawn Guoff4ab232014-05-20 15:34:06 +080075 imx51_ipu_mipi_setup();
76 imx_src_init();
Fabio Estevam11d973d2018-07-09 15:19:15 -030077 imx51_m4if_setup();
Fabio Estevam26b754f2018-07-10 13:31:48 -030078 imx5_pmu_init();
Alexander Shiyan463f90f2016-06-25 08:26:15 +030079 imx_aips_allow_unprivileged_access("fsl,imx51-aipstz");
Shawn Guo9daaf31a2011-10-17 08:42:17 +080080}
81
Shawn Guoff4ab232014-05-20 15:34:06 +080082static void __init imx51_init_late(void)
83{
84 mx51_neon_fixup();
85 imx51_pm_init();
86}
87
Shawn Guo8756dd92014-07-01 16:03:00 +080088static const char * const imx51_dt_board_compat[] __initconst = {
Sascha Hauer3f8976d2012-02-17 12:07:00 +010089 "fsl,imx51",
Shawn Guo9daaf31a2011-10-17 08:42:17 +080090 NULL
91};
92
93DT_MACHINE_START(IMX51_DT, "Freescale i.MX51 (Device Tree Support)")
Shawn Guo9daaf31a2011-10-17 08:42:17 +080094 .init_early = imx51_init_early,
Shawn Guo9daaf31a2011-10-17 08:42:17 +080095 .init_machine = imx51_dt_init,
Shawn Guo8321b752012-04-26 11:42:34 +080096 .init_late = imx51_init_late,
Shawn Guo9daaf31a2011-10-17 08:42:17 +080097 .dt_compat = imx51_dt_board_compat,
Shawn Guo9daaf31a2011-10-17 08:42:17 +080098MACHINE_END