xref: /optee_os/core/arch/arm/plat-imx/imx-common.c (revision 64de482ec1a4cab6835e439729bac08ab8ef6651)
1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright (C) 2016 Freescale Semiconductor, Inc.
4  * Copyright 2017-2019 NXP
5  *
6  * Peng Fan <peng.fan@nxp.com>
7  */
8 
9 #include <console.h>
10 #include <io.h>
11 #include <imx.h>
12 #include <mm/core_mmu.h>
13 #include <mm/core_memprot.h>
14 #include <platform_config.h>
15 
16 static uint32_t imx_digproc(void)
17 {
18 	static uint32_t reg;
19 	vaddr_t anatop_addr;
20 
21 	if (!reg) {
22 		anatop_addr = core_mmu_get_va(ANATOP_BASE, MEM_AREA_IO_SEC);
23 
24 #if defined(CFG_MX7)
25 		reg = io_read32(anatop_addr + OFFSET_DIGPROG_IMX7D);
26 #elif defined(CFG_MX6SL)
27 		reg = io_read32(anatop_addr + OFFSET_DIGPROG_IMX6SL);
28 #else
29 		reg = io_read32(anatop_addr + OFFSET_DIGPROG);
30 #endif
31 	}
32 
33 	return reg;
34 }
35 
36 static uint32_t imx_soc_rev_major(void)
37 {
38 	return ((imx_digproc() & 0xff00) >> 8) + 1;
39 }
40 
41 uint32_t imx_soc_type(void)
42 {
43 	return (imx_digproc() >> 16) & 0xff;
44 }
45 
46 bool soc_is_imx6sl(void)
47 {
48 	return imx_soc_type() == SOC_MX6SL;
49 }
50 
51 bool soc_is_imx6sx(void)
52 {
53 	return imx_soc_type() == SOC_MX6SX;
54 }
55 
56 bool soc_is_imx6ul(void)
57 {
58 	return imx_soc_type() == SOC_MX6UL;
59 }
60 
61 bool soc_is_imx6ull(void)
62 {
63 	return imx_soc_type() == SOC_MX6ULL;
64 }
65 
66 bool soc_is_imx6sdl(void)
67 {
68 	return imx_soc_type() == SOC_MX6DL;
69 }
70 
71 bool soc_is_imx6dq(void)
72 {
73 	return (imx_soc_type() == SOC_MX6Q) && (imx_soc_rev_major() == 1);
74 }
75 
76 bool soc_is_imx6dqp(void)
77 {
78 	return (imx_soc_type() == SOC_MX6Q) && (imx_soc_rev_major() == 2);
79 }
80 
81 bool soc_is_imx6(void)
82 {
83 	return ((imx_soc_type() == SOC_MX6SX) ||
84 			(imx_soc_type() == SOC_MX6UL) ||
85 			(imx_soc_type() == SOC_MX6ULL) ||
86 			(imx_soc_type() == SOC_MX6DL) ||
87 			(imx_soc_type() == SOC_MX6Q));
88 }
89 
90 bool soc_is_imx7ds(void)
91 {
92 	return imx_soc_type() == SOC_MX7D;
93 }
94 
95