1de70d0e9SA.s. Dong // SPDX-License-Identifier: GPL-2.0+ 2de70d0e9SA.s. Dong /* 3de70d0e9SA.s. Dong * Copyright (C) 2016 Freescale Semiconductor, Inc. 4de70d0e9SA.s. Dong * Copyright 2017-2018 NXP 5de70d0e9SA.s. Dong * Author: Dong Aisheng <aisheng.dong@nxp.com> 6de70d0e9SA.s. Dong */ 7de70d0e9SA.s. Dong 8de70d0e9SA.s. Dong #include <linux/irqchip.h> 99edf908aSAnson Huang #include <linux/mfd/syscon.h> 10de70d0e9SA.s. Dong #include <linux/of_platform.h> 119edf908aSAnson Huang #include <linux/regmap.h> 12de70d0e9SA.s. Dong #include <asm/mach/arch.h> 13de70d0e9SA.s. Dong 14de70d0e9SA.s. Dong #include "common.h" 156d45a402SAnson Huang #include "cpuidle.h" 16de70d0e9SA.s. Dong #include "hardware.h" 17de70d0e9SA.s. Dong 189edf908aSAnson Huang #define SIM_JTAG_ID_REG 0x8c 199edf908aSAnson Huang 209edf908aSAnson Huang static void __init imx7ulp_set_revision(void) 219edf908aSAnson Huang { 229edf908aSAnson Huang struct regmap *sim; 239edf908aSAnson Huang u32 revision; 249edf908aSAnson Huang 259edf908aSAnson Huang sim = syscon_regmap_lookup_by_compatible("fsl,imx7ulp-sim"); 269edf908aSAnson Huang if (IS_ERR(sim)) { 279edf908aSAnson Huang pr_warn("failed to find fsl,imx7ulp-sim regmap!\n"); 289edf908aSAnson Huang return; 299edf908aSAnson Huang } 309edf908aSAnson Huang 319edf908aSAnson Huang if (regmap_read(sim, SIM_JTAG_ID_REG, &revision)) { 329edf908aSAnson Huang pr_warn("failed to read sim regmap!\n"); 339edf908aSAnson Huang return; 349edf908aSAnson Huang } 359edf908aSAnson Huang 369edf908aSAnson Huang /* 379edf908aSAnson Huang * bit[31:28] of JTAG_ID register defines revision as below from B0: 389edf908aSAnson Huang * 0001 B0 399edf908aSAnson Huang * 0010 B1 40*7544bfc0SFabio Estevam * 0011 B2 419edf908aSAnson Huang */ 429edf908aSAnson Huang switch (revision >> 28) { 439edf908aSAnson Huang case 1: 449edf908aSAnson Huang imx_set_soc_revision(IMX_CHIP_REVISION_2_0); 459edf908aSAnson Huang break; 469edf908aSAnson Huang case 2: 479edf908aSAnson Huang imx_set_soc_revision(IMX_CHIP_REVISION_2_1); 489edf908aSAnson Huang break; 492f4ac2d7SAnson Huang case 3: 502f4ac2d7SAnson Huang imx_set_soc_revision(IMX_CHIP_REVISION_2_2); 512f4ac2d7SAnson Huang break; 529edf908aSAnson Huang default: 539edf908aSAnson Huang imx_set_soc_revision(IMX_CHIP_REVISION_1_0); 549edf908aSAnson Huang break; 559edf908aSAnson Huang } 569edf908aSAnson Huang } 579edf908aSAnson Huang 58de70d0e9SA.s. Dong static void __init imx7ulp_init_machine(void) 59de70d0e9SA.s. Dong { 60de70d0e9SA.s. Dong imx7ulp_pm_init(); 61de70d0e9SA.s. Dong 62de70d0e9SA.s. Dong mxc_set_cpu_type(MXC_CPU_IMX7ULP); 639edf908aSAnson Huang imx7ulp_set_revision(); 64d2199b34SPeng Fan of_platform_default_populate(NULL, NULL, NULL); 65de70d0e9SA.s. Dong } 66de70d0e9SA.s. Dong 67de70d0e9SA.s. Dong static const char *const imx7ulp_dt_compat[] __initconst = { 68de70d0e9SA.s. Dong "fsl,imx7ulp", 69de70d0e9SA.s. Dong NULL, 70de70d0e9SA.s. Dong }; 71de70d0e9SA.s. Dong 726d45a402SAnson Huang static void __init imx7ulp_init_late(void) 736d45a402SAnson Huang { 74cf4ff961SPeng Fan if (IS_ENABLED(CONFIG_ARM_IMX_CPUFREQ_DT)) 75cf4ff961SPeng Fan platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0); 76cf4ff961SPeng Fan 776d45a402SAnson Huang imx7ulp_cpuidle_init(); 786d45a402SAnson Huang } 796d45a402SAnson Huang 80de70d0e9SA.s. Dong DT_MACHINE_START(IMX7ulp, "Freescale i.MX7ULP (Device Tree)") 81de70d0e9SA.s. Dong .init_machine = imx7ulp_init_machine, 82de70d0e9SA.s. Dong .dt_compat = imx7ulp_dt_compat, 836d45a402SAnson Huang .init_late = imx7ulp_init_late, 84de70d0e9SA.s. Dong MACHINE_END 85