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 * Added DRA7xxx specific defines - Sricharan R<r.sricharan@ti.com>
138c2ecf20Sopenharmony_ci */
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include "omap24xx.h"
168c2ecf20Sopenharmony_ci#include "omap34xx.h"
178c2ecf20Sopenharmony_ci#include "omap44xx.h"
188c2ecf20Sopenharmony_ci#include "ti81xx.h"
198c2ecf20Sopenharmony_ci#include "am33xx.h"
208c2ecf20Sopenharmony_ci#include "omap54xx.h"
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#include <linux/bitops.h>
258c2ecf20Sopenharmony_ci#include <linux/of.h>
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/*
288c2ecf20Sopenharmony_ci * OMAP2+ is always defined as ARCH_MULTIPLATFORM in Kconfig
298c2ecf20Sopenharmony_ci */
308c2ecf20Sopenharmony_ci#undef MULTI_OMAP2
318c2ecf20Sopenharmony_ci#define MULTI_OMAP2
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/*
348c2ecf20Sopenharmony_ci * Omap device type i.e. EMU/HS/TST/GP/BAD
358c2ecf20Sopenharmony_ci */
368c2ecf20Sopenharmony_ci#define OMAP2_DEVICE_TYPE_TEST		0
378c2ecf20Sopenharmony_ci#define OMAP2_DEVICE_TYPE_EMU		1
388c2ecf20Sopenharmony_ci#define OMAP2_DEVICE_TYPE_SEC		2
398c2ecf20Sopenharmony_ci#define OMAP2_DEVICE_TYPE_GP		3
408c2ecf20Sopenharmony_ci#define OMAP2_DEVICE_TYPE_BAD		4
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ciint omap_type(void);
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci/*
458c2ecf20Sopenharmony_ci * omap_rev bits:
468c2ecf20Sopenharmony_ci * SoC id bits	(0730, 1510, 1710, 2422...)	[31:16]
478c2ecf20Sopenharmony_ci * SoC revision	(See _REV_ defined in cpu.h)	[15:08]
488c2ecf20Sopenharmony_ci * SoC class bits (15xx, 16xx, 24xx, 34xx...)	[07:00]
498c2ecf20Sopenharmony_ci */
508c2ecf20Sopenharmony_ciunsigned int omap_rev(void);
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistatic inline int soc_is_omap(void)
538c2ecf20Sopenharmony_ci{
548c2ecf20Sopenharmony_ci	return omap_rev() != 0;
558c2ecf20Sopenharmony_ci}
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/*
588c2ecf20Sopenharmony_ci * Get the SoC revision for OMAP devices
598c2ecf20Sopenharmony_ci */
608c2ecf20Sopenharmony_ci#define GET_OMAP_REVISION()	((omap_rev() >> 8) & 0xff)
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci/*
638c2ecf20Sopenharmony_ci * Macros to group OMAP into cpu classes.
648c2ecf20Sopenharmony_ci * These can be used in most places.
658c2ecf20Sopenharmony_ci * soc_is_omap24xx():	True for OMAP2420, OMAP2422, OMAP2423, OMAP2430
668c2ecf20Sopenharmony_ci * soc_is_omap242x():	True for OMAP2420, OMAP2422, OMAP2423
678c2ecf20Sopenharmony_ci * soc_is_omap243x():	True for OMAP2430
688c2ecf20Sopenharmony_ci * soc_is_omap343x():	True for OMAP3430
698c2ecf20Sopenharmony_ci * soc_is_omap443x():	True for OMAP4430
708c2ecf20Sopenharmony_ci * soc_is_omap446x():	True for OMAP4460
718c2ecf20Sopenharmony_ci * soc_is_omap447x():	True for OMAP4470
728c2ecf20Sopenharmony_ci * soc_is_omap543x():	True for OMAP5430, OMAP5432
738c2ecf20Sopenharmony_ci */
748c2ecf20Sopenharmony_ci#define GET_OMAP_CLASS	(omap_rev() & 0xff)
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#define IS_OMAP_CLASS(class, id)			\
778c2ecf20Sopenharmony_cistatic inline int is_omap ##class (void)		\
788c2ecf20Sopenharmony_ci{							\
798c2ecf20Sopenharmony_ci	return (GET_OMAP_CLASS == (id)) ? 1 : 0;	\
808c2ecf20Sopenharmony_ci}
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci#define GET_AM_CLASS	((omap_rev() >> 24) & 0xff)
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#define IS_AM_CLASS(class, id)				\
858c2ecf20Sopenharmony_cistatic inline int is_am ##class (void)			\
868c2ecf20Sopenharmony_ci{							\
878c2ecf20Sopenharmony_ci	return (GET_AM_CLASS == (id)) ? 1 : 0;		\
888c2ecf20Sopenharmony_ci}
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci#define GET_TI_CLASS	((omap_rev() >> 24) & 0xff)
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci#define IS_TI_CLASS(class, id)			\
938c2ecf20Sopenharmony_cistatic inline int is_ti ##class (void)		\
948c2ecf20Sopenharmony_ci{							\
958c2ecf20Sopenharmony_ci	return (GET_TI_CLASS == (id)) ? 1 : 0;	\
968c2ecf20Sopenharmony_ci}
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define GET_DRA_CLASS	((omap_rev() >> 24) & 0xff)
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci#define IS_DRA_CLASS(class, id)				\
1018c2ecf20Sopenharmony_cistatic inline int is_dra ##class (void)			\
1028c2ecf20Sopenharmony_ci{							\
1038c2ecf20Sopenharmony_ci	return (GET_DRA_CLASS == (id)) ? 1 : 0;		\
1048c2ecf20Sopenharmony_ci}
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci#define GET_OMAP_SUBCLASS	((omap_rev() >> 20) & 0x0fff)
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci#define IS_OMAP_SUBCLASS(subclass, id)			\
1098c2ecf20Sopenharmony_cistatic inline int is_omap ##subclass (void)		\
1108c2ecf20Sopenharmony_ci{							\
1118c2ecf20Sopenharmony_ci	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
1128c2ecf20Sopenharmony_ci}
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#define IS_TI_SUBCLASS(subclass, id)			\
1158c2ecf20Sopenharmony_cistatic inline int is_ti ##subclass (void)		\
1168c2ecf20Sopenharmony_ci{							\
1178c2ecf20Sopenharmony_ci	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
1188c2ecf20Sopenharmony_ci}
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#define IS_AM_SUBCLASS(subclass, id)			\
1218c2ecf20Sopenharmony_cistatic inline int is_am ##subclass (void)		\
1228c2ecf20Sopenharmony_ci{							\
1238c2ecf20Sopenharmony_ci	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
1248c2ecf20Sopenharmony_ci}
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci#define IS_DRA_SUBCLASS(subclass, id)			\
1278c2ecf20Sopenharmony_cistatic inline int is_dra ##subclass (void)		\
1288c2ecf20Sopenharmony_ci{							\
1298c2ecf20Sopenharmony_ci	return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0;	\
1308c2ecf20Sopenharmony_ci}
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#define GET_DRA_PACKAGE		(omap_rev() & 0xff)
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci#define IS_DRA_SUBCLASS_PACKAGE(subclass, package, id)			\
1358c2ecf20Sopenharmony_cistatic inline int is_dra ##subclass ##_ ##package (void)		\
1368c2ecf20Sopenharmony_ci{									\
1378c2ecf20Sopenharmony_ci	return (is_dra ##subclass () && GET_DRA_PACKAGE == id) ? 1 : 0;	\
1388c2ecf20Sopenharmony_ci}
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ciIS_OMAP_CLASS(24xx, 0x24)
1418c2ecf20Sopenharmony_ciIS_OMAP_CLASS(34xx, 0x34)
1428c2ecf20Sopenharmony_ciIS_OMAP_CLASS(44xx, 0x44)
1438c2ecf20Sopenharmony_ciIS_AM_CLASS(35xx, 0x35)
1448c2ecf20Sopenharmony_ciIS_OMAP_CLASS(54xx, 0x54)
1458c2ecf20Sopenharmony_ciIS_AM_CLASS(33xx, 0x33)
1468c2ecf20Sopenharmony_ciIS_AM_CLASS(43xx, 0x43)
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ciIS_TI_CLASS(81xx, 0x81)
1498c2ecf20Sopenharmony_ciIS_DRA_CLASS(7xx, 0x7)
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ciIS_OMAP_SUBCLASS(242x, 0x242)
1528c2ecf20Sopenharmony_ciIS_OMAP_SUBCLASS(243x, 0x243)
1538c2ecf20Sopenharmony_ciIS_OMAP_SUBCLASS(343x, 0x343)
1548c2ecf20Sopenharmony_ciIS_OMAP_SUBCLASS(363x, 0x363)
1558c2ecf20Sopenharmony_ciIS_OMAP_SUBCLASS(443x, 0x443)
1568c2ecf20Sopenharmony_ciIS_OMAP_SUBCLASS(446x, 0x446)
1578c2ecf20Sopenharmony_ciIS_OMAP_SUBCLASS(447x, 0x447)
1588c2ecf20Sopenharmony_ciIS_OMAP_SUBCLASS(543x, 0x543)
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ciIS_TI_SUBCLASS(816x, 0x816)
1618c2ecf20Sopenharmony_ciIS_TI_SUBCLASS(814x, 0x814)
1628c2ecf20Sopenharmony_ciIS_AM_SUBCLASS(335x, 0x335)
1638c2ecf20Sopenharmony_ciIS_AM_SUBCLASS(437x, 0x437)
1648c2ecf20Sopenharmony_ciIS_DRA_SUBCLASS(76x, 0x76)
1658c2ecf20Sopenharmony_ciIS_DRA_SUBCLASS_PACKAGE(76x, abz, 2)
1668c2ecf20Sopenharmony_ciIS_DRA_SUBCLASS_PACKAGE(76x, acd, 3)
1678c2ecf20Sopenharmony_ciIS_DRA_SUBCLASS(75x, 0x75)
1688c2ecf20Sopenharmony_ciIS_DRA_SUBCLASS(72x, 0x72)
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci#define soc_is_ti81xx()			0
1718c2ecf20Sopenharmony_ci#define soc_is_ti816x()			0
1728c2ecf20Sopenharmony_ci#define soc_is_ti814x()			0
1738c2ecf20Sopenharmony_ci#define soc_is_am35xx()			0
1748c2ecf20Sopenharmony_ci#define soc_is_am33xx()			0
1758c2ecf20Sopenharmony_ci#define soc_is_am335x()			0
1768c2ecf20Sopenharmony_ci#define soc_is_am43xx()			0
1778c2ecf20Sopenharmony_ci#define soc_is_am437x()			0
1788c2ecf20Sopenharmony_ci#define soc_is_omap44xx()		0
1798c2ecf20Sopenharmony_ci#define soc_is_omap443x()		0
1808c2ecf20Sopenharmony_ci#define soc_is_omap446x()		0
1818c2ecf20Sopenharmony_ci#define soc_is_omap447x()		0
1828c2ecf20Sopenharmony_ci#define soc_is_omap54xx()		0
1838c2ecf20Sopenharmony_ci#define soc_is_omap543x()		0
1848c2ecf20Sopenharmony_ci#define soc_is_dra7xx()			0
1858c2ecf20Sopenharmony_ci#define soc_is_dra76x()			0
1868c2ecf20Sopenharmony_ci#define soc_is_dra74x()			0
1878c2ecf20Sopenharmony_ci#define soc_is_dra72x()			0
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci#if defined(CONFIG_ARCH_OMAP2)
1908c2ecf20Sopenharmony_ci# define soc_is_omap24xx()		is_omap24xx()
1918c2ecf20Sopenharmony_ci#else
1928c2ecf20Sopenharmony_ci# define soc_is_omap24xx()		0
1938c2ecf20Sopenharmony_ci#endif
1948c2ecf20Sopenharmony_ci#if defined(CONFIG_SOC_OMAP2420)
1958c2ecf20Sopenharmony_ci# define soc_is_omap242x()		is_omap242x()
1968c2ecf20Sopenharmony_ci#else
1978c2ecf20Sopenharmony_ci# define soc_is_omap242x()		0
1988c2ecf20Sopenharmony_ci#endif
1998c2ecf20Sopenharmony_ci#if defined(CONFIG_SOC_OMAP2430)
2008c2ecf20Sopenharmony_ci# define soc_is_omap243x()		is_omap243x()
2018c2ecf20Sopenharmony_ci#else
2028c2ecf20Sopenharmony_ci# define soc_is_omap243x()		0
2038c2ecf20Sopenharmony_ci#endif
2048c2ecf20Sopenharmony_ci#if defined(CONFIG_ARCH_OMAP3)
2058c2ecf20Sopenharmony_ci# define soc_is_omap34xx()		is_omap34xx()
2068c2ecf20Sopenharmony_ci# define soc_is_omap343x()		is_omap343x()
2078c2ecf20Sopenharmony_ci#else
2088c2ecf20Sopenharmony_ci# define soc_is_omap34xx()		0
2098c2ecf20Sopenharmony_ci# define soc_is_omap343x()		0
2108c2ecf20Sopenharmony_ci#endif
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_ci/*
2138c2ecf20Sopenharmony_ci * Macros to detect individual cpu types.
2148c2ecf20Sopenharmony_ci * These are only rarely needed.
2158c2ecf20Sopenharmony_ci * soc_is_omap2420():	True for OMAP2420
2168c2ecf20Sopenharmony_ci * soc_is_omap2422():	True for OMAP2422
2178c2ecf20Sopenharmony_ci * soc_is_omap2423():	True for OMAP2423
2188c2ecf20Sopenharmony_ci * soc_is_omap2430():	True for OMAP2430
2198c2ecf20Sopenharmony_ci * soc_is_omap3430():	True for OMAP3430
2208c2ecf20Sopenharmony_ci */
2218c2ecf20Sopenharmony_ci#define GET_OMAP_TYPE	((omap_rev() >> 16) & 0xffff)
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci#define IS_OMAP_TYPE(type, id)				\
2248c2ecf20Sopenharmony_cistatic inline int is_omap ##type (void)			\
2258c2ecf20Sopenharmony_ci{							\
2268c2ecf20Sopenharmony_ci	return (GET_OMAP_TYPE == (id)) ? 1 : 0;		\
2278c2ecf20Sopenharmony_ci}
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ciIS_OMAP_TYPE(2420, 0x2420)
2308c2ecf20Sopenharmony_ciIS_OMAP_TYPE(2422, 0x2422)
2318c2ecf20Sopenharmony_ciIS_OMAP_TYPE(2423, 0x2423)
2328c2ecf20Sopenharmony_ciIS_OMAP_TYPE(2430, 0x2430)
2338c2ecf20Sopenharmony_ciIS_OMAP_TYPE(3430, 0x3430)
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci#define soc_is_omap2420()		0
2368c2ecf20Sopenharmony_ci#define soc_is_omap2422()		0
2378c2ecf20Sopenharmony_ci#define soc_is_omap2423()		0
2388c2ecf20Sopenharmony_ci#define soc_is_omap2430()		0
2398c2ecf20Sopenharmony_ci#define soc_is_omap3430()		0
2408c2ecf20Sopenharmony_ci#define soc_is_omap3630()		0
2418c2ecf20Sopenharmony_ci#define soc_is_omap5430()		0
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci/* These are needed for the common code */
2448c2ecf20Sopenharmony_ci#define soc_is_omap7xx()		0
2458c2ecf20Sopenharmony_ci#define soc_is_omap15xx()		0
2468c2ecf20Sopenharmony_ci#define soc_is_omap16xx()		0
2478c2ecf20Sopenharmony_ci#define soc_is_omap1510()		0
2488c2ecf20Sopenharmony_ci#define soc_is_omap1610()		0
2498c2ecf20Sopenharmony_ci#define soc_is_omap1611()		0
2508c2ecf20Sopenharmony_ci#define soc_is_omap1621()		0
2518c2ecf20Sopenharmony_ci#define soc_is_omap1710()		0
2528c2ecf20Sopenharmony_ci#define cpu_class_is_omap1()		0
2538c2ecf20Sopenharmony_ci#define cpu_class_is_omap2()		1
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci#if defined(CONFIG_ARCH_OMAP2)
2568c2ecf20Sopenharmony_ci# undef  soc_is_omap2420
2578c2ecf20Sopenharmony_ci# undef  soc_is_omap2422
2588c2ecf20Sopenharmony_ci# undef  soc_is_omap2423
2598c2ecf20Sopenharmony_ci# undef  soc_is_omap2430
2608c2ecf20Sopenharmony_ci# define soc_is_omap2420()		is_omap2420()
2618c2ecf20Sopenharmony_ci# define soc_is_omap2422()		is_omap2422()
2628c2ecf20Sopenharmony_ci# define soc_is_omap2423()		is_omap2423()
2638c2ecf20Sopenharmony_ci# define soc_is_omap2430()		is_omap2430()
2648c2ecf20Sopenharmony_ci#endif
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci#if defined(CONFIG_ARCH_OMAP3)
2678c2ecf20Sopenharmony_ci# undef soc_is_omap3430
2688c2ecf20Sopenharmony_ci# undef soc_is_ti81xx
2698c2ecf20Sopenharmony_ci# undef soc_is_ti816x
2708c2ecf20Sopenharmony_ci# undef soc_is_ti814x
2718c2ecf20Sopenharmony_ci# undef soc_is_am35xx
2728c2ecf20Sopenharmony_ci# define soc_is_omap3430()		is_omap3430()
2738c2ecf20Sopenharmony_ci# undef soc_is_omap3630
2748c2ecf20Sopenharmony_ci# define soc_is_omap3630()		is_omap363x()
2758c2ecf20Sopenharmony_ci# define soc_is_ti81xx()		is_ti81xx()
2768c2ecf20Sopenharmony_ci# define soc_is_ti816x()		is_ti816x()
2778c2ecf20Sopenharmony_ci# define soc_is_ti814x()		is_ti814x()
2788c2ecf20Sopenharmony_ci# define soc_is_am35xx()		is_am35xx()
2798c2ecf20Sopenharmony_ci#endif
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci# if defined(CONFIG_SOC_AM33XX)
2828c2ecf20Sopenharmony_ci# undef soc_is_am33xx
2838c2ecf20Sopenharmony_ci# undef soc_is_am335x
2848c2ecf20Sopenharmony_ci# define soc_is_am33xx()		is_am33xx()
2858c2ecf20Sopenharmony_ci# define soc_is_am335x()		is_am335x()
2868c2ecf20Sopenharmony_ci#endif
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci#ifdef	CONFIG_SOC_AM43XX
2898c2ecf20Sopenharmony_ci# undef soc_is_am43xx
2908c2ecf20Sopenharmony_ci# undef soc_is_am437x
2918c2ecf20Sopenharmony_ci# define soc_is_am43xx()		is_am43xx()
2928c2ecf20Sopenharmony_ci# define soc_is_am437x()		is_am437x()
2938c2ecf20Sopenharmony_ci#endif
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_ci# if defined(CONFIG_ARCH_OMAP4)
2968c2ecf20Sopenharmony_ci# undef soc_is_omap44xx
2978c2ecf20Sopenharmony_ci# undef soc_is_omap443x
2988c2ecf20Sopenharmony_ci# undef soc_is_omap446x
2998c2ecf20Sopenharmony_ci# undef soc_is_omap447x
3008c2ecf20Sopenharmony_ci# define soc_is_omap44xx()		is_omap44xx()
3018c2ecf20Sopenharmony_ci# define soc_is_omap443x()		is_omap443x()
3028c2ecf20Sopenharmony_ci# define soc_is_omap446x()		is_omap446x()
3038c2ecf20Sopenharmony_ci# define soc_is_omap447x()		is_omap447x()
3048c2ecf20Sopenharmony_ci# endif
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci# if defined(CONFIG_SOC_OMAP5)
3078c2ecf20Sopenharmony_ci# undef soc_is_omap54xx
3088c2ecf20Sopenharmony_ci# undef soc_is_omap543x
3098c2ecf20Sopenharmony_ci# define soc_is_omap54xx()		is_omap54xx()
3108c2ecf20Sopenharmony_ci# define soc_is_omap543x()		is_omap543x()
3118c2ecf20Sopenharmony_ci#endif
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci#if defined(CONFIG_SOC_DRA7XX)
3148c2ecf20Sopenharmony_ci#undef soc_is_dra7xx
3158c2ecf20Sopenharmony_ci#undef soc_is_dra76x
3168c2ecf20Sopenharmony_ci#undef soc_is_dra76x_abz
3178c2ecf20Sopenharmony_ci#undef soc_is_dra76x_acd
3188c2ecf20Sopenharmony_ci#undef soc_is_dra74x
3198c2ecf20Sopenharmony_ci#undef soc_is_dra72x
3208c2ecf20Sopenharmony_ci#define soc_is_dra7xx()	is_dra7xx()
3218c2ecf20Sopenharmony_ci#define soc_is_dra76x()	is_dra76x()
3228c2ecf20Sopenharmony_ci#define soc_is_dra76x_abz()	is_dra76x_abz()
3238c2ecf20Sopenharmony_ci#define soc_is_dra76x_acd()	is_dra76x_acd()
3248c2ecf20Sopenharmony_ci#define soc_is_dra74x()	is_dra75x()
3258c2ecf20Sopenharmony_ci#define soc_is_dra72x()	is_dra72x()
3268c2ecf20Sopenharmony_ci#endif
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci/* Various silicon revisions for omap2 */
3298c2ecf20Sopenharmony_ci#define OMAP242X_CLASS		0x24200024
3308c2ecf20Sopenharmony_ci#define OMAP2420_REV_ES1_0	OMAP242X_CLASS
3318c2ecf20Sopenharmony_ci#define OMAP2420_REV_ES2_0	(OMAP242X_CLASS | (0x1 << 8))
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci#define OMAP243X_CLASS		0x24300024
3348c2ecf20Sopenharmony_ci#define OMAP2430_REV_ES1_0	OMAP243X_CLASS
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ci#define OMAP343X_CLASS		0x34300034
3378c2ecf20Sopenharmony_ci#define OMAP3430_REV_ES1_0	OMAP343X_CLASS
3388c2ecf20Sopenharmony_ci#define OMAP3430_REV_ES2_0	(OMAP343X_CLASS | (0x1 << 8))
3398c2ecf20Sopenharmony_ci#define OMAP3430_REV_ES2_1	(OMAP343X_CLASS | (0x2 << 8))
3408c2ecf20Sopenharmony_ci#define OMAP3430_REV_ES3_0	(OMAP343X_CLASS | (0x3 << 8))
3418c2ecf20Sopenharmony_ci#define OMAP3430_REV_ES3_1	(OMAP343X_CLASS | (0x4 << 8))
3428c2ecf20Sopenharmony_ci#define OMAP3430_REV_ES3_1_2	(OMAP343X_CLASS | (0x5 << 8))
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci#define OMAP363X_CLASS		0x36300034
3458c2ecf20Sopenharmony_ci#define OMAP3630_REV_ES1_0	OMAP363X_CLASS
3468c2ecf20Sopenharmony_ci#define OMAP3630_REV_ES1_1	(OMAP363X_CLASS | (0x1 << 8))
3478c2ecf20Sopenharmony_ci#define OMAP3630_REV_ES1_2	(OMAP363X_CLASS | (0x2 << 8))
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_ci#define TI816X_CLASS		0x81600081
3508c2ecf20Sopenharmony_ci#define TI8168_REV_ES1_0	TI816X_CLASS
3518c2ecf20Sopenharmony_ci#define TI8168_REV_ES1_1	(TI816X_CLASS | (0x1 << 8))
3528c2ecf20Sopenharmony_ci#define TI8168_REV_ES2_0	(TI816X_CLASS | (0x2 << 8))
3538c2ecf20Sopenharmony_ci#define TI8168_REV_ES2_1	(TI816X_CLASS | (0x3 << 8))
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_ci#define TI814X_CLASS		0x81400081
3568c2ecf20Sopenharmony_ci#define TI8148_REV_ES1_0	TI814X_CLASS
3578c2ecf20Sopenharmony_ci#define TI8148_REV_ES2_0	(TI814X_CLASS | (0x1 << 8))
3588c2ecf20Sopenharmony_ci#define TI8148_REV_ES2_1	(TI814X_CLASS | (0x2 << 8))
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci#define AM35XX_CLASS		0x35170034
3618c2ecf20Sopenharmony_ci#define AM35XX_REV_ES1_0	AM35XX_CLASS
3628c2ecf20Sopenharmony_ci#define AM35XX_REV_ES1_1	(AM35XX_CLASS | (0x1 << 8))
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci#define AM335X_CLASS		0x33500033
3658c2ecf20Sopenharmony_ci#define AM335X_REV_ES1_0	AM335X_CLASS
3668c2ecf20Sopenharmony_ci#define AM335X_REV_ES2_0	(AM335X_CLASS | (0x1 << 8))
3678c2ecf20Sopenharmony_ci#define AM335X_REV_ES2_1	(AM335X_CLASS | (0x2 << 8))
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_ci#define AM437X_CLASS		0x43700000
3708c2ecf20Sopenharmony_ci#define AM437X_REV_ES1_0	(AM437X_CLASS | (0x10 << 8))
3718c2ecf20Sopenharmony_ci#define AM437X_REV_ES1_1	(AM437X_CLASS | (0x11 << 8))
3728c2ecf20Sopenharmony_ci#define AM437X_REV_ES1_2	(AM437X_CLASS | (0x12 << 8))
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci#define OMAP443X_CLASS		0x44300044
3758c2ecf20Sopenharmony_ci#define OMAP4430_REV_ES1_0	(OMAP443X_CLASS | (0x10 << 8))
3768c2ecf20Sopenharmony_ci#define OMAP4430_REV_ES2_0	(OMAP443X_CLASS | (0x20 << 8))
3778c2ecf20Sopenharmony_ci#define OMAP4430_REV_ES2_1	(OMAP443X_CLASS | (0x21 << 8))
3788c2ecf20Sopenharmony_ci#define OMAP4430_REV_ES2_2	(OMAP443X_CLASS | (0x22 << 8))
3798c2ecf20Sopenharmony_ci#define OMAP4430_REV_ES2_3	(OMAP443X_CLASS | (0x23 << 8))
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci#define OMAP446X_CLASS		0x44600044
3828c2ecf20Sopenharmony_ci#define OMAP4460_REV_ES1_0	(OMAP446X_CLASS | (0x10 << 8))
3838c2ecf20Sopenharmony_ci#define OMAP4460_REV_ES1_1	(OMAP446X_CLASS | (0x11 << 8))
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_ci#define OMAP447X_CLASS		0x44700044
3868c2ecf20Sopenharmony_ci#define OMAP4470_REV_ES1_0	(OMAP447X_CLASS | (0x10 << 8))
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_ci#define OMAP54XX_CLASS		0x54000054
3898c2ecf20Sopenharmony_ci#define OMAP5430_REV_ES2_0	(OMAP54XX_CLASS | (0x30 << 16) | (0x20 << 8))
3908c2ecf20Sopenharmony_ci#define OMAP5432_REV_ES2_0	(OMAP54XX_CLASS | (0x32 << 16) | (0x20 << 8))
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci#define DRA7XX_CLASS		0x07000000
3938c2ecf20Sopenharmony_ci#define DRA762_REV_ES1_0	(DRA7XX_CLASS | (0x62 << 16) | (0x10 << 8))
3948c2ecf20Sopenharmony_ci#define DRA762_ABZ_REV_ES1_0	(DRA762_REV_ES1_0 | (2 << 0))
3958c2ecf20Sopenharmony_ci#define DRA762_ACD_REV_ES1_0	(DRA762_REV_ES1_0 | (3 << 0))
3968c2ecf20Sopenharmony_ci#define DRA752_REV_ES1_0	(DRA7XX_CLASS | (0x52 << 16) | (0x10 << 8))
3978c2ecf20Sopenharmony_ci#define DRA752_REV_ES1_1	(DRA7XX_CLASS | (0x52 << 16) | (0x11 << 8))
3988c2ecf20Sopenharmony_ci#define DRA752_REV_ES2_0	(DRA7XX_CLASS | (0x52 << 16) | (0x20 << 8))
3998c2ecf20Sopenharmony_ci#define DRA722_REV_ES1_0	(DRA7XX_CLASS | (0x22 << 16) | (0x10 << 8))
4008c2ecf20Sopenharmony_ci#define DRA722_REV_ES2_0	(DRA7XX_CLASS | (0x22 << 16) | (0x20 << 8))
4018c2ecf20Sopenharmony_ci#define DRA722_REV_ES2_1	(DRA7XX_CLASS | (0x22 << 16) | (0x21 << 8))
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_civoid omap2xxx_check_revision(void);
4048c2ecf20Sopenharmony_civoid omap3xxx_check_revision(void);
4058c2ecf20Sopenharmony_civoid omap4xxx_check_revision(void);
4068c2ecf20Sopenharmony_civoid omap5xxx_check_revision(void);
4078c2ecf20Sopenharmony_civoid dra7xxx_check_revision(void);
4088c2ecf20Sopenharmony_civoid omap3xxx_check_features(void);
4098c2ecf20Sopenharmony_civoid ti81xx_check_features(void);
4108c2ecf20Sopenharmony_civoid am33xx_check_features(void);
4118c2ecf20Sopenharmony_civoid omap4xxx_check_features(void);
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_ci/*
4148c2ecf20Sopenharmony_ci * Runtime detection of OMAP3 features
4158c2ecf20Sopenharmony_ci *
4168c2ecf20Sopenharmony_ci * OMAP3_HAS_IO_CHAIN_CTRL: Some later members of the OMAP3 chip
4178c2ecf20Sopenharmony_ci *    family have OS-level control over the I/O chain clock.  This is
4188c2ecf20Sopenharmony_ci *    to avoid a window during which wakeups could potentially be lost
4198c2ecf20Sopenharmony_ci *    during powerdomain transitions.  If this bit is set, it
4208c2ecf20Sopenharmony_ci *    indicates that the chip does support OS-level control of this
4218c2ecf20Sopenharmony_ci *    feature.
4228c2ecf20Sopenharmony_ci */
4238c2ecf20Sopenharmony_ciextern u32 omap_features;
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_ci#define OMAP3_HAS_L2CACHE		BIT(0)
4268c2ecf20Sopenharmony_ci#define OMAP3_HAS_IVA			BIT(1)
4278c2ecf20Sopenharmony_ci#define OMAP3_HAS_SGX			BIT(2)
4288c2ecf20Sopenharmony_ci#define OMAP3_HAS_NEON			BIT(3)
4298c2ecf20Sopenharmony_ci#define OMAP3_HAS_ISP			BIT(4)
4308c2ecf20Sopenharmony_ci#define OMAP3_HAS_192MHZ_CLK		BIT(5)
4318c2ecf20Sopenharmony_ci#define OMAP3_HAS_IO_WAKEUP		BIT(6)
4328c2ecf20Sopenharmony_ci#define OMAP3_HAS_SDRC			BIT(7)
4338c2ecf20Sopenharmony_ci#define OMAP3_HAS_IO_CHAIN_CTRL		BIT(8)
4348c2ecf20Sopenharmony_ci#define OMAP4_HAS_PERF_SILICON		BIT(9)
4358c2ecf20Sopenharmony_ci
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ci#define OMAP3_HAS_FEATURE(feat,flag)			\
4388c2ecf20Sopenharmony_cistatic inline unsigned int omap3_has_ ##feat(void)	\
4398c2ecf20Sopenharmony_ci{							\
4408c2ecf20Sopenharmony_ci	return omap_features & OMAP3_HAS_ ##flag;	\
4418c2ecf20Sopenharmony_ci}							\
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ciOMAP3_HAS_FEATURE(l2cache, L2CACHE)
4448c2ecf20Sopenharmony_ciOMAP3_HAS_FEATURE(sgx, SGX)
4458c2ecf20Sopenharmony_ciOMAP3_HAS_FEATURE(iva, IVA)
4468c2ecf20Sopenharmony_ciOMAP3_HAS_FEATURE(neon, NEON)
4478c2ecf20Sopenharmony_ciOMAP3_HAS_FEATURE(isp, ISP)
4488c2ecf20Sopenharmony_ciOMAP3_HAS_FEATURE(192mhz_clk, 192MHZ_CLK)
4498c2ecf20Sopenharmony_ciOMAP3_HAS_FEATURE(io_wakeup, IO_WAKEUP)
4508c2ecf20Sopenharmony_ciOMAP3_HAS_FEATURE(sdrc, SDRC)
4518c2ecf20Sopenharmony_ciOMAP3_HAS_FEATURE(io_chain_ctrl, IO_CHAIN_CTRL)
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_ci/*
4548c2ecf20Sopenharmony_ci * Runtime detection of OMAP4 features
4558c2ecf20Sopenharmony_ci */
4568c2ecf20Sopenharmony_ci#define OMAP4_HAS_FEATURE(feat, flag)			\
4578c2ecf20Sopenharmony_cistatic inline unsigned int omap4_has_ ##feat(void)	\
4588c2ecf20Sopenharmony_ci{							\
4598c2ecf20Sopenharmony_ci	return omap_features & OMAP4_HAS_ ##flag;	\
4608c2ecf20Sopenharmony_ci}							\
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_ciOMAP4_HAS_FEATURE(perf_silicon, PERF_SILICON)
4638c2ecf20Sopenharmony_ci
4648c2ecf20Sopenharmony_ci/*
4658c2ecf20Sopenharmony_ci * We need to make sure omap initcalls don't run when
4668c2ecf20Sopenharmony_ci * multiplatform kernels are booted on other SoCs.
4678c2ecf20Sopenharmony_ci */
4688c2ecf20Sopenharmony_ci#define omap_initcall(level, fn)		\
4698c2ecf20Sopenharmony_cistatic int __init __used __##fn(void)		\
4708c2ecf20Sopenharmony_ci{						\
4718c2ecf20Sopenharmony_ci	if (!soc_is_omap())			\
4728c2ecf20Sopenharmony_ci		return 0;			\
4738c2ecf20Sopenharmony_ci	return fn();				\
4748c2ecf20Sopenharmony_ci}						\
4758c2ecf20Sopenharmony_cilevel(__##fn);
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_ci#define omap_early_initcall(fn)		omap_initcall(early_initcall, fn)
4788c2ecf20Sopenharmony_ci#define omap_core_initcall(fn)		omap_initcall(core_initcall, fn)
4798c2ecf20Sopenharmony_ci#define omap_postcore_initcall(fn)	omap_initcall(postcore_initcall, fn)
4808c2ecf20Sopenharmony_ci#define omap_arch_initcall(fn)		omap_initcall(arch_initcall, fn)
4818c2ecf20Sopenharmony_ci#define omap_subsys_initcall(fn)	omap_initcall(subsys_initcall, fn)
4828c2ecf20Sopenharmony_ci#define omap_device_initcall(fn)	omap_initcall(device_initcall, fn)
4838c2ecf20Sopenharmony_ci#define omap_late_initcall(fn)		omap_initcall(late_initcall, fn)
4848c2ecf20Sopenharmony_ci#define omap_late_initcall_sync(fn)	omap_initcall(late_initcall_sync, fn)
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci/* Legacy defines, these can be removed when users are removed */
4878c2ecf20Sopenharmony_ci#define cpu_is_omap2420()	soc_is_omap2420()
4888c2ecf20Sopenharmony_ci#define cpu_is_omap2422()	soc_is_omap2422()
4898c2ecf20Sopenharmony_ci#define cpu_is_omap242x()	soc_is_omap242x()
4908c2ecf20Sopenharmony_ci#define cpu_is_omap2430()	soc_is_omap2430()
4918c2ecf20Sopenharmony_ci#define cpu_is_omap243x()	soc_is_omap243x()
4928c2ecf20Sopenharmony_ci#define cpu_is_omap24xx()	soc_is_omap24xx()
4938c2ecf20Sopenharmony_ci#define cpu_is_omap3430()	soc_is_omap3430()
4948c2ecf20Sopenharmony_ci#define cpu_is_omap343x()	soc_is_omap343x()
4958c2ecf20Sopenharmony_ci#define cpu_is_omap34xx()	soc_is_omap34xx()
4968c2ecf20Sopenharmony_ci#define cpu_is_omap3630()	soc_is_omap3630()
4978c2ecf20Sopenharmony_ci#define cpu_is_omap443x()	soc_is_omap443x()
4988c2ecf20Sopenharmony_ci#define cpu_is_omap446x()	soc_is_omap446x()
4998c2ecf20Sopenharmony_ci#define cpu_is_omap44xx()	soc_is_omap44xx()
5008c2ecf20Sopenharmony_ci#define cpu_is_ti814x()		soc_is_ti814x()
5018c2ecf20Sopenharmony_ci#define cpu_is_ti816x()		soc_is_ti816x()
5028c2ecf20Sopenharmony_ci#define cpu_is_ti81xx()		soc_is_ti81xx()
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_ci#endif	/* __ASSEMBLY__ */
505