18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved. 48c2ecf20Sopenharmony_ci * Copyright 2011 Linaro Ltd. 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <linux/io.h> 88c2ecf20Sopenharmony_ci#include <linux/irq.h> 98c2ecf20Sopenharmony_ci#include <linux/of_address.h> 108c2ecf20Sopenharmony_ci#include <linux/of_irq.h> 118c2ecf20Sopenharmony_ci#include <linux/of_platform.h> 128c2ecf20Sopenharmony_ci#include <asm/mach/arch.h> 138c2ecf20Sopenharmony_ci#include <asm/mach/time.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include "common.h" 168c2ecf20Sopenharmony_ci#include "hardware.h" 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistatic void __init imx51_init_early(void) 198c2ecf20Sopenharmony_ci{ 208c2ecf20Sopenharmony_ci mxc_set_cpu_type(MXC_CPU_MX51); 218c2ecf20Sopenharmony_ci} 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* 248c2ecf20Sopenharmony_ci * The MIPI HSC unit has been removed from the i.MX51 Reference Manual by 258c2ecf20Sopenharmony_ci * the Freescale marketing division. However this did not remove the 268c2ecf20Sopenharmony_ci * hardware from the chip which still needs to be configured for proper 278c2ecf20Sopenharmony_ci * IPU support. 288c2ecf20Sopenharmony_ci */ 298c2ecf20Sopenharmony_ci#define MX51_MIPI_HSC_BASE 0x83fdc000 308c2ecf20Sopenharmony_cistatic void __init imx51_ipu_mipi_setup(void) 318c2ecf20Sopenharmony_ci{ 328c2ecf20Sopenharmony_ci void __iomem *hsc_addr; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci hsc_addr = ioremap(MX51_MIPI_HSC_BASE, SZ_16K); 358c2ecf20Sopenharmony_ci WARN_ON(!hsc_addr); 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci /* setup MIPI module to legacy mode */ 388c2ecf20Sopenharmony_ci imx_writel(0xf00, hsc_addr); 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci /* CSI mode: reserved; DI control mode: legacy (from Freescale BSP) */ 418c2ecf20Sopenharmony_ci imx_writel(imx_readl(hsc_addr + 0x800) | 0x30ff, hsc_addr + 0x800); 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci iounmap(hsc_addr); 448c2ecf20Sopenharmony_ci} 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cistatic void __init imx51_m4if_setup(void) 478c2ecf20Sopenharmony_ci{ 488c2ecf20Sopenharmony_ci void __iomem *m4if_base; 498c2ecf20Sopenharmony_ci struct device_node *np; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci np = of_find_compatible_node(NULL, NULL, "fsl,imx51-m4if"); 528c2ecf20Sopenharmony_ci if (!np) 538c2ecf20Sopenharmony_ci return; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci m4if_base = of_iomap(np, 0); 568c2ecf20Sopenharmony_ci of_node_put(np); 578c2ecf20Sopenharmony_ci if (!m4if_base) { 588c2ecf20Sopenharmony_ci pr_err("Unable to map M4IF registers\n"); 598c2ecf20Sopenharmony_ci return; 608c2ecf20Sopenharmony_ci } 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci /* 638c2ecf20Sopenharmony_ci * Configure VPU and IPU with higher priorities 648c2ecf20Sopenharmony_ci * in order to avoid artifacts during video playback 658c2ecf20Sopenharmony_ci */ 668c2ecf20Sopenharmony_ci writel_relaxed(0x00000203, m4if_base + 0x40); 678c2ecf20Sopenharmony_ci writel_relaxed(0x00000000, m4if_base + 0x44); 688c2ecf20Sopenharmony_ci writel_relaxed(0x00120125, m4if_base + 0x9c); 698c2ecf20Sopenharmony_ci writel_relaxed(0x001901A3, m4if_base + 0x48); 708c2ecf20Sopenharmony_ci iounmap(m4if_base); 718c2ecf20Sopenharmony_ci} 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_cistatic void __init imx51_dt_init(void) 748c2ecf20Sopenharmony_ci{ 758c2ecf20Sopenharmony_ci imx51_ipu_mipi_setup(); 768c2ecf20Sopenharmony_ci imx_src_init(); 778c2ecf20Sopenharmony_ci imx51_m4if_setup(); 788c2ecf20Sopenharmony_ci imx5_pmu_init(); 798c2ecf20Sopenharmony_ci imx_aips_allow_unprivileged_access("fsl,imx51-aipstz"); 808c2ecf20Sopenharmony_ci} 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_cistatic void __init imx51_init_late(void) 838c2ecf20Sopenharmony_ci{ 848c2ecf20Sopenharmony_ci mx51_neon_fixup(); 858c2ecf20Sopenharmony_ci imx51_pm_init(); 868c2ecf20Sopenharmony_ci} 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_cistatic const char * const imx51_dt_board_compat[] __initconst = { 898c2ecf20Sopenharmony_ci "fsl,imx51", 908c2ecf20Sopenharmony_ci NULL 918c2ecf20Sopenharmony_ci}; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ciDT_MACHINE_START(IMX51_DT, "Freescale i.MX51 (Device Tree Support)") 948c2ecf20Sopenharmony_ci .init_early = imx51_init_early, 958c2ecf20Sopenharmony_ci .init_machine = imx51_dt_init, 968c2ecf20Sopenharmony_ci .init_late = imx51_init_late, 978c2ecf20Sopenharmony_ci .dt_compat = imx51_dt_board_compat, 988c2ecf20Sopenharmony_ciMACHINE_END 99