xref: /linux/arch/arm/mach-imx/mach-imx7ulp.c (revision d2199b34871b859d33cd08398af5f1530241cb4e)
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();
60*d2199b34SPeng 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 {
706d45a402SAnson Huang 	imx7ulp_cpuidle_init();
716d45a402SAnson Huang }
726d45a402SAnson Huang 
73de70d0e9SA.s. Dong DT_MACHINE_START(IMX7ulp, "Freescale i.MX7ULP (Device Tree)")
74de70d0e9SA.s. Dong 	.init_machine	= imx7ulp_init_machine,
75de70d0e9SA.s. Dong 	.dt_compat	= imx7ulp_dt_compat,
766d45a402SAnson Huang 	.init_late	= imx7ulp_init_late,
77de70d0e9SA.s. Dong MACHINE_END
78