18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * OMAP cpu type detection
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2004, 2008 Nokia Corporation
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Copyright (C) 2009-11 Texas Instruments.
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * Written by Tony Lindgren <tony.lindgren@nokia.com>
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * Added OMAP4/5 specific defines - Santosh Shilimkar<santosh.shilimkar@ti.com>
128c2ecf20Sopenharmony_ci */
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#ifndef __ASM_ARCH_OMAP_CPU_H
158c2ecf20Sopenharmony_ci#define __ASM_ARCH_OMAP_CPU_H
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include <asm/irq.h>
188c2ecf20Sopenharmony_ci#include <mach/hardware.h>
198c2ecf20Sopenharmony_ci#include <mach/irqs.h>
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#include <linux/bitops.h>
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/*
268c2ecf20Sopenharmony_ci * Test if multicore OMAP support is needed
278c2ecf20Sopenharmony_ci */
288c2ecf20Sopenharmony_ci#undef MULTI_OMAP1
298c2ecf20Sopenharmony_ci#undef OMAP_NAME
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#ifdef CONFIG_ARCH_OMAP730
328c2ecf20Sopenharmony_ci# ifdef OMAP_NAME
338c2ecf20Sopenharmony_ci#  undef  MULTI_OMAP1
348c2ecf20Sopenharmony_ci#  define MULTI_OMAP1
358c2ecf20Sopenharmony_ci# else
368c2ecf20Sopenharmony_ci#  define OMAP_NAME omap730
378c2ecf20Sopenharmony_ci# endif
388c2ecf20Sopenharmony_ci#endif
398c2ecf20Sopenharmony_ci#ifdef CONFIG_ARCH_OMAP850
408c2ecf20Sopenharmony_ci# ifdef OMAP_NAME
418c2ecf20Sopenharmony_ci#  undef  MULTI_OMAP1
428c2ecf20Sopenharmony_ci#  define MULTI_OMAP1
438c2ecf20Sopenharmony_ci# else
448c2ecf20Sopenharmony_ci#  define OMAP_NAME omap850
458c2ecf20Sopenharmony_ci# endif
468c2ecf20Sopenharmony_ci#endif
478c2ecf20Sopenharmony_ci#ifdef CONFIG_ARCH_OMAP15XX
488c2ecf20Sopenharmony_ci# ifdef OMAP_NAME
498c2ecf20Sopenharmony_ci#  undef  MULTI_OMAP1
508c2ecf20Sopenharmony_ci#  define MULTI_OMAP1
518c2ecf20Sopenharmony_ci# else
528c2ecf20Sopenharmony_ci#  define OMAP_NAME omap1510
538c2ecf20Sopenharmony_ci# endif
548c2ecf20Sopenharmony_ci#endif
558c2ecf20Sopenharmony_ci#ifdef CONFIG_ARCH_OMAP16XX
568c2ecf20Sopenharmony_ci# ifdef OMAP_NAME
578c2ecf20Sopenharmony_ci#  undef  MULTI_OMAP1
588c2ecf20Sopenharmony_ci#  define MULTI_OMAP1
598c2ecf20Sopenharmony_ci# else
608c2ecf20Sopenharmony_ci#  define OMAP_NAME omap16xx
618c2ecf20Sopenharmony_ci# endif
628c2ecf20Sopenharmony_ci#endif
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci/*
658c2ecf20Sopenharmony_ci * omap_rev bits:
668c2ecf20Sopenharmony_ci * CPU id bits	(0730, 1510, 1710, 2422...)	[31:16]
678c2ecf20Sopenharmony_ci * CPU revision	(See _REV_ defined in cpu.h)	[15:08]
688c2ecf20Sopenharmony_ci * CPU class bits (15xx, 16xx, 24xx, 34xx...)	[07:00]
698c2ecf20Sopenharmony_ci */
708c2ecf20Sopenharmony_ciunsigned int omap_rev(void);
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/*
738c2ecf20Sopenharmony_ci * Get the CPU revision for OMAP devices
748c2ecf20Sopenharmony_ci */
758c2ecf20Sopenharmony_ci#define GET_OMAP_REVISION()	((omap_rev() >> 8) & 0xff)
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/*
788c2ecf20Sopenharmony_ci * Macros to group OMAP into cpu classes.
798c2ecf20Sopenharmony_ci * These can be used in most places.
808c2ecf20Sopenharmony_ci * cpu_is_omap7xx():	True for OMAP730, OMAP850
818c2ecf20Sopenharmony_ci * cpu_is_omap15xx():	True for OMAP1510, OMAP5910 and OMAP310
828c2ecf20Sopenharmony_ci * cpu_is_omap16xx():	True for OMAP1610, OMAP5912 and OMAP1710
838c2ecf20Sopenharmony_ci */
848c2ecf20Sopenharmony_ci#define GET_OMAP_CLASS	(omap_rev() & 0xff)
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#define IS_OMAP_CLASS(class, id)			\
878c2ecf20Sopenharmony_cistatic inline int is_omap ##class (void)		\
888c2ecf20Sopenharmony_ci{							\
898c2ecf20Sopenharmony_ci	return (GET_OMAP_CLASS == (id)) ? 1 : 0;	\
908c2ecf20Sopenharmony_ci}
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci#define GET_OMAP_SUBCLASS	((omap_rev() >> 20) & 0x0fff)
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci#define IS_OMAP_SUBCLASS(subclass, id)			\
958c2ecf20Sopenharmony_cistatic inline int is_omap ##subclass (void)		\
968c2ecf20Sopenharmony_ci{							\
978c2ecf20Sopenharmony_ci	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
988c2ecf20Sopenharmony_ci}
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ciIS_OMAP_CLASS(7xx, 0x07)
1018c2ecf20Sopenharmony_ciIS_OMAP_CLASS(15xx, 0x15)
1028c2ecf20Sopenharmony_ciIS_OMAP_CLASS(16xx, 0x16)
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci#define cpu_is_omap7xx()		0
1058c2ecf20Sopenharmony_ci#define cpu_is_omap15xx()		0
1068c2ecf20Sopenharmony_ci#define cpu_is_omap16xx()		0
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci#if defined(MULTI_OMAP1)
1098c2ecf20Sopenharmony_ci# if defined(CONFIG_ARCH_OMAP730)
1108c2ecf20Sopenharmony_ci#  undef  cpu_is_omap7xx
1118c2ecf20Sopenharmony_ci#  define cpu_is_omap7xx()		is_omap7xx()
1128c2ecf20Sopenharmony_ci# endif
1138c2ecf20Sopenharmony_ci# if defined(CONFIG_ARCH_OMAP850)
1148c2ecf20Sopenharmony_ci#  undef  cpu_is_omap7xx
1158c2ecf20Sopenharmony_ci#  define cpu_is_omap7xx()		is_omap7xx()
1168c2ecf20Sopenharmony_ci# endif
1178c2ecf20Sopenharmony_ci# if defined(CONFIG_ARCH_OMAP15XX)
1188c2ecf20Sopenharmony_ci#  undef  cpu_is_omap15xx
1198c2ecf20Sopenharmony_ci#  define cpu_is_omap15xx()		is_omap15xx()
1208c2ecf20Sopenharmony_ci# endif
1218c2ecf20Sopenharmony_ci# if defined(CONFIG_ARCH_OMAP16XX)
1228c2ecf20Sopenharmony_ci#  undef  cpu_is_omap16xx
1238c2ecf20Sopenharmony_ci#  define cpu_is_omap16xx()		is_omap16xx()
1248c2ecf20Sopenharmony_ci# endif
1258c2ecf20Sopenharmony_ci#else
1268c2ecf20Sopenharmony_ci# if defined(CONFIG_ARCH_OMAP730)
1278c2ecf20Sopenharmony_ci#  undef  cpu_is_omap7xx
1288c2ecf20Sopenharmony_ci#  define cpu_is_omap7xx()		1
1298c2ecf20Sopenharmony_ci# endif
1308c2ecf20Sopenharmony_ci# if defined(CONFIG_ARCH_OMAP850)
1318c2ecf20Sopenharmony_ci#  undef  cpu_is_omap7xx
1328c2ecf20Sopenharmony_ci#  define cpu_is_omap7xx()		1
1338c2ecf20Sopenharmony_ci# endif
1348c2ecf20Sopenharmony_ci# if defined(CONFIG_ARCH_OMAP15XX)
1358c2ecf20Sopenharmony_ci#  undef  cpu_is_omap15xx
1368c2ecf20Sopenharmony_ci#  define cpu_is_omap15xx()		1
1378c2ecf20Sopenharmony_ci# endif
1388c2ecf20Sopenharmony_ci# if defined(CONFIG_ARCH_OMAP16XX)
1398c2ecf20Sopenharmony_ci#  undef  cpu_is_omap16xx
1408c2ecf20Sopenharmony_ci#  define cpu_is_omap16xx()		1
1418c2ecf20Sopenharmony_ci# endif
1428c2ecf20Sopenharmony_ci#endif
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci/*
1458c2ecf20Sopenharmony_ci * Macros to detect individual cpu types.
1468c2ecf20Sopenharmony_ci * These are only rarely needed.
1478c2ecf20Sopenharmony_ci * cpu_is_omap310():	True for OMAP310
1488c2ecf20Sopenharmony_ci * cpu_is_omap1510():	True for OMAP1510
1498c2ecf20Sopenharmony_ci * cpu_is_omap1610():	True for OMAP1610
1508c2ecf20Sopenharmony_ci * cpu_is_omap1611():	True for OMAP1611
1518c2ecf20Sopenharmony_ci * cpu_is_omap5912():	True for OMAP5912
1528c2ecf20Sopenharmony_ci * cpu_is_omap1621():	True for OMAP1621
1538c2ecf20Sopenharmony_ci * cpu_is_omap1710():	True for OMAP1710
1548c2ecf20Sopenharmony_ci */
1558c2ecf20Sopenharmony_ci#define GET_OMAP_TYPE	((omap_rev() >> 16) & 0xffff)
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci#define IS_OMAP_TYPE(type, id)				\
1588c2ecf20Sopenharmony_cistatic inline int is_omap ##type (void)			\
1598c2ecf20Sopenharmony_ci{							\
1608c2ecf20Sopenharmony_ci	return (GET_OMAP_TYPE == (id)) ? 1 : 0;		\
1618c2ecf20Sopenharmony_ci}
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ciIS_OMAP_TYPE(310, 0x0310)
1648c2ecf20Sopenharmony_ciIS_OMAP_TYPE(1510, 0x1510)
1658c2ecf20Sopenharmony_ciIS_OMAP_TYPE(1610, 0x1610)
1668c2ecf20Sopenharmony_ciIS_OMAP_TYPE(1611, 0x1611)
1678c2ecf20Sopenharmony_ciIS_OMAP_TYPE(5912, 0x1611)
1688c2ecf20Sopenharmony_ciIS_OMAP_TYPE(1621, 0x1621)
1698c2ecf20Sopenharmony_ciIS_OMAP_TYPE(1710, 0x1710)
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci#define cpu_is_omap310()		0
1728c2ecf20Sopenharmony_ci#define cpu_is_omap1510()		0
1738c2ecf20Sopenharmony_ci#define cpu_is_omap1610()		0
1748c2ecf20Sopenharmony_ci#define cpu_is_omap5912()		0
1758c2ecf20Sopenharmony_ci#define cpu_is_omap1611()		0
1768c2ecf20Sopenharmony_ci#define cpu_is_omap1621()		0
1778c2ecf20Sopenharmony_ci#define cpu_is_omap1710()		0
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci/* These are needed to compile common code */
1808c2ecf20Sopenharmony_ci#ifdef CONFIG_ARCH_OMAP1
1818c2ecf20Sopenharmony_ci#define cpu_is_omap242x()		0
1828c2ecf20Sopenharmony_ci#define cpu_is_omap2430()		0
1838c2ecf20Sopenharmony_ci#define cpu_is_omap243x()		0
1848c2ecf20Sopenharmony_ci#define cpu_is_omap24xx()		0
1858c2ecf20Sopenharmony_ci#define cpu_is_omap34xx()		0
1868c2ecf20Sopenharmony_ci#define cpu_is_omap44xx()		0
1878c2ecf20Sopenharmony_ci#define soc_is_omap54xx()		0
1888c2ecf20Sopenharmony_ci#define soc_is_dra7xx()			0
1898c2ecf20Sopenharmony_ci#define soc_is_am33xx()			0
1908c2ecf20Sopenharmony_ci#define cpu_class_is_omap1()		1
1918c2ecf20Sopenharmony_ci#define cpu_class_is_omap2()		0
1928c2ecf20Sopenharmony_ci#endif
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci/*
1958c2ecf20Sopenharmony_ci * Whether we have MULTI_OMAP1 or not, we still need to distinguish
1968c2ecf20Sopenharmony_ci * between 310 vs. 1510 and 1611B/5912 vs. 1710.
1978c2ecf20Sopenharmony_ci */
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci#if defined(CONFIG_ARCH_OMAP15XX)
2008c2ecf20Sopenharmony_ci# undef  cpu_is_omap310
2018c2ecf20Sopenharmony_ci# undef  cpu_is_omap1510
2028c2ecf20Sopenharmony_ci# define cpu_is_omap310()		is_omap310()
2038c2ecf20Sopenharmony_ci# define cpu_is_omap1510()		is_omap1510()
2048c2ecf20Sopenharmony_ci#endif
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci#if defined(CONFIG_ARCH_OMAP16XX)
2078c2ecf20Sopenharmony_ci# undef  cpu_is_omap1610
2088c2ecf20Sopenharmony_ci# undef  cpu_is_omap1611
2098c2ecf20Sopenharmony_ci# undef  cpu_is_omap5912
2108c2ecf20Sopenharmony_ci# undef  cpu_is_omap1621
2118c2ecf20Sopenharmony_ci# undef  cpu_is_omap1710
2128c2ecf20Sopenharmony_ci# define cpu_is_omap1610()		is_omap1610()
2138c2ecf20Sopenharmony_ci# define cpu_is_omap1611()		is_omap1611()
2148c2ecf20Sopenharmony_ci# define cpu_is_omap5912()		is_omap5912()
2158c2ecf20Sopenharmony_ci# define cpu_is_omap1621()		is_omap1621()
2168c2ecf20Sopenharmony_ci# define cpu_is_omap1710()		is_omap1710()
2178c2ecf20Sopenharmony_ci#endif
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci#endif	/* __ASSEMBLY__ */
2208c2ecf20Sopenharmony_ci#endif
221