xref: /linux/arch/arm/mach-imx/mach-imx7ulp.c (revision cf4ff9618d2363362e89d52a595918d565b13bf3)
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
409edf908aSAnson Huang 	 */
419edf908aSAnson Huang 	switch (revision >> 28) {
429edf908aSAnson Huang 	case 1:
439edf908aSAnson Huang 		imx_set_soc_revision(IMX_CHIP_REVISION_2_0);
449edf908aSAnson Huang 		break;
459edf908aSAnson Huang 	case 2:
469edf908aSAnson Huang 		imx_set_soc_revision(IMX_CHIP_REVISION_2_1);
479edf908aSAnson Huang 		break;
489edf908aSAnson Huang 	default:
499edf908aSAnson Huang 		imx_set_soc_revision(IMX_CHIP_REVISION_1_0);
509edf908aSAnson Huang 		break;
519edf908aSAnson Huang 	}
529edf908aSAnson Huang }
539edf908aSAnson Huang 
54de70d0e9SA.s. Dong static void __init imx7ulp_init_machine(void)
55de70d0e9SA.s. Dong {
56de70d0e9SA.s. Dong 	imx7ulp_pm_init();
57de70d0e9SA.s. Dong 
58de70d0e9SA.s. Dong 	mxc_set_cpu_type(MXC_CPU_IMX7ULP);
599edf908aSAnson Huang 	imx7ulp_set_revision();
60d2199b34SPeng Fan 	of_platform_default_populate(NULL, NULL, NULL);
61de70d0e9SA.s. Dong }
62de70d0e9SA.s. Dong 
63de70d0e9SA.s. Dong static const char *const imx7ulp_dt_compat[] __initconst = {
64de70d0e9SA.s. Dong 	"fsl,imx7ulp",
65de70d0e9SA.s. Dong 	NULL,
66de70d0e9SA.s. Dong };
67de70d0e9SA.s. Dong 
686d45a402SAnson Huang static void __init imx7ulp_init_late(void)
696d45a402SAnson Huang {
70*cf4ff961SPeng Fan 	if (IS_ENABLED(CONFIG_ARM_IMX_CPUFREQ_DT))
71*cf4ff961SPeng Fan 		platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0);
72*cf4ff961SPeng Fan 
736d45a402SAnson Huang 	imx7ulp_cpuidle_init();
746d45a402SAnson Huang }
756d45a402SAnson Huang 
76de70d0e9SA.s. Dong DT_MACHINE_START(IMX7ulp, "Freescale i.MX7ULP (Device Tree)")
77de70d0e9SA.s. Dong 	.init_machine	= imx7ulp_init_machine,
78de70d0e9SA.s. Dong 	.dt_compat	= imx7ulp_dt_compat,
796d45a402SAnson Huang 	.init_late	= imx7ulp_init_late,
80de70d0e9SA.s. Dong MACHINE_END
81