18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  arch/arm/mach-pxa/include/mach/hardware.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Author:	Nicolas Pitre
68c2ecf20Sopenharmony_ci *  Created:	Jun 15, 2001
78c2ecf20Sopenharmony_ci *  Copyright:	MontaVista Software Inc.
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef __ASM_ARCH_HARDWARE_H
118c2ecf20Sopenharmony_ci#define __ASM_ARCH_HARDWARE_H
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <mach/addr-map.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci/*
168c2ecf20Sopenharmony_ci * Workarounds for at least 2 errata so far require this.
178c2ecf20Sopenharmony_ci * The mapping is set in mach-pxa/generic.c.
188c2ecf20Sopenharmony_ci */
198c2ecf20Sopenharmony_ci#define UNCACHED_PHYS_0		0xfe000000
208c2ecf20Sopenharmony_ci#define UNCACHED_PHYS_0_SIZE	0x00100000
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/*
238c2ecf20Sopenharmony_ci * Intel PXA2xx internal register mapping:
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci * 0x40000000 - 0x41ffffff <--> 0xf2000000 - 0xf3ffffff
268c2ecf20Sopenharmony_ci * 0x44000000 - 0x45ffffff <--> 0xf4000000 - 0xf5ffffff
278c2ecf20Sopenharmony_ci * 0x48000000 - 0x49ffffff <--> 0xf6000000 - 0xf7ffffff
288c2ecf20Sopenharmony_ci * 0x4c000000 - 0x4dffffff <--> 0xf8000000 - 0xf9ffffff
298c2ecf20Sopenharmony_ci * 0x50000000 - 0x51ffffff <--> 0xfa000000 - 0xfbffffff
308c2ecf20Sopenharmony_ci * 0x54000000 - 0x55ffffff <--> 0xfc000000 - 0xfdffffff
318c2ecf20Sopenharmony_ci * 0x58000000 - 0x59ffffff <--> 0xfe000000 - 0xffffffff
328c2ecf20Sopenharmony_ci *
338c2ecf20Sopenharmony_ci * Note that not all PXA2xx chips implement all those addresses, and the
348c2ecf20Sopenharmony_ci * kernel only maps the minimum needed range of this mapping.
358c2ecf20Sopenharmony_ci */
368c2ecf20Sopenharmony_ci#define io_v2p(x) (0x3c000000 + ((x) & 0x01ffffff) + (((x) & 0x0e000000) << 1))
378c2ecf20Sopenharmony_ci#define io_p2v(x) IOMEM(0xf2000000 + ((x) & 0x01ffffff) + (((x) & 0x1c000000) >> 1))
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
408c2ecf20Sopenharmony_ci# define __REG(x)	(*((volatile u32 __iomem *)io_p2v(x)))
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci/* With indexed regs we don't want to feed the index through io_p2v()
438c2ecf20Sopenharmony_ci   especially if it is a variable, otherwise horrible code will result. */
448c2ecf20Sopenharmony_ci# define __REG2(x,y)	\
458c2ecf20Sopenharmony_ci	(*(volatile u32 __iomem*)((u32)&__REG(x) + (y)))
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci# define __PREG(x)	(io_v2p((u32)&(x)))
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#else
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci# define __REG(x)	io_p2v(x)
528c2ecf20Sopenharmony_ci# define __PREG(x)	io_v2p(x)
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#endif
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci#include <asm/cputype.h>
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/*
618c2ecf20Sopenharmony_ci *   CPU     Stepping     CPU_ID         JTAG_ID
628c2ecf20Sopenharmony_ci *
638c2ecf20Sopenharmony_ci *  PXA210	B0	0x69052922	0x2926C013
648c2ecf20Sopenharmony_ci *  PXA210	B1	0x69052923	0x3926C013
658c2ecf20Sopenharmony_ci *  PXA210	B2	0x69052924	0x4926C013
668c2ecf20Sopenharmony_ci *  PXA210	C0	0x69052D25	0x5926C013
678c2ecf20Sopenharmony_ci *
688c2ecf20Sopenharmony_ci *  PXA250	A0	0x69052100	0x09264013
698c2ecf20Sopenharmony_ci *  PXA250	A1	0x69052101	0x19264013
708c2ecf20Sopenharmony_ci *  PXA250	B0	0x69052902	0x29264013
718c2ecf20Sopenharmony_ci *  PXA250	B1	0x69052903	0x39264013
728c2ecf20Sopenharmony_ci *  PXA250	B2	0x69052904	0x49264013
738c2ecf20Sopenharmony_ci *  PXA250	C0	0x69052D05	0x59264013
748c2ecf20Sopenharmony_ci *
758c2ecf20Sopenharmony_ci *  PXA255	A0	0x69052D06	0x69264013
768c2ecf20Sopenharmony_ci *
778c2ecf20Sopenharmony_ci *  PXA26x	A0	0x69052903	0x39264013
788c2ecf20Sopenharmony_ci *  PXA26x	B0	0x69052D05	0x59264013
798c2ecf20Sopenharmony_ci *
808c2ecf20Sopenharmony_ci *  PXA27x	A0	0x69054110	0x09265013
818c2ecf20Sopenharmony_ci *  PXA27x	A1	0x69054111	0x19265013
828c2ecf20Sopenharmony_ci *  PXA27x	B0	0x69054112	0x29265013
838c2ecf20Sopenharmony_ci *  PXA27x	B1	0x69054113	0x39265013
848c2ecf20Sopenharmony_ci *  PXA27x	C0	0x69054114	0x49265013
858c2ecf20Sopenharmony_ci *  PXA27x	C5	0x69054117	0x79265013
868c2ecf20Sopenharmony_ci *
878c2ecf20Sopenharmony_ci *  PXA30x	A0	0x69056880	0x0E648013
888c2ecf20Sopenharmony_ci *  PXA30x	A1	0x69056881	0x1E648013
898c2ecf20Sopenharmony_ci *  PXA31x	A0	0x69056890	0x0E649013
908c2ecf20Sopenharmony_ci *  PXA31x	A1	0x69056891	0x1E649013
918c2ecf20Sopenharmony_ci *  PXA31x	A2	0x69056892	0x2E649013
928c2ecf20Sopenharmony_ci *  PXA32x	B1	0x69056825	0x5E642013
938c2ecf20Sopenharmony_ci *  PXA32x	B2	0x69056826	0x6E642013
948c2ecf20Sopenharmony_ci *
958c2ecf20Sopenharmony_ci *  PXA930	B0	0x69056835	0x5E643013
968c2ecf20Sopenharmony_ci *  PXA930	B1	0x69056837	0x7E643013
978c2ecf20Sopenharmony_ci *  PXA930	B2	0x69056838	0x8E643013
988c2ecf20Sopenharmony_ci *
998c2ecf20Sopenharmony_ci *  PXA935	A0	0x56056931	0x1E653013
1008c2ecf20Sopenharmony_ci *  PXA935	B0	0x56056936	0x6E653013
1018c2ecf20Sopenharmony_ci *  PXA935	B1	0x56056938	0x8E653013
1028c2ecf20Sopenharmony_ci */
1038c2ecf20Sopenharmony_ci#ifdef CONFIG_PXA25x
1048c2ecf20Sopenharmony_ci#define __cpu_is_pxa210(id)				\
1058c2ecf20Sopenharmony_ci	({						\
1068c2ecf20Sopenharmony_ci		unsigned int _id = (id) & 0xf3f0;	\
1078c2ecf20Sopenharmony_ci		_id == 0x2120;				\
1088c2ecf20Sopenharmony_ci	})
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#define __cpu_is_pxa250(id)				\
1118c2ecf20Sopenharmony_ci	({						\
1128c2ecf20Sopenharmony_ci		unsigned int _id = (id) & 0xf3ff;	\
1138c2ecf20Sopenharmony_ci		_id <= 0x2105;				\
1148c2ecf20Sopenharmony_ci	})
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#define __cpu_is_pxa255(id)				\
1178c2ecf20Sopenharmony_ci	({						\
1188c2ecf20Sopenharmony_ci		unsigned int _id = (id) & 0xffff;	\
1198c2ecf20Sopenharmony_ci		_id == 0x2d06;				\
1208c2ecf20Sopenharmony_ci	})
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci#define __cpu_is_pxa25x(id)				\
1238c2ecf20Sopenharmony_ci	({						\
1248c2ecf20Sopenharmony_ci		unsigned int _id = (id) & 0xf300;	\
1258c2ecf20Sopenharmony_ci		_id == 0x2100;				\
1268c2ecf20Sopenharmony_ci	})
1278c2ecf20Sopenharmony_ci#else
1288c2ecf20Sopenharmony_ci#define __cpu_is_pxa210(id)	(0)
1298c2ecf20Sopenharmony_ci#define __cpu_is_pxa250(id)	(0)
1308c2ecf20Sopenharmony_ci#define __cpu_is_pxa255(id)	(0)
1318c2ecf20Sopenharmony_ci#define __cpu_is_pxa25x(id)	(0)
1328c2ecf20Sopenharmony_ci#endif
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci#ifdef CONFIG_PXA27x
1358c2ecf20Sopenharmony_ci#define __cpu_is_pxa27x(id)				\
1368c2ecf20Sopenharmony_ci	({						\
1378c2ecf20Sopenharmony_ci		unsigned int _id = (id) >> 4 & 0xfff;	\
1388c2ecf20Sopenharmony_ci		_id == 0x411;				\
1398c2ecf20Sopenharmony_ci	})
1408c2ecf20Sopenharmony_ci#else
1418c2ecf20Sopenharmony_ci#define __cpu_is_pxa27x(id)	(0)
1428c2ecf20Sopenharmony_ci#endif
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_PXA300
1458c2ecf20Sopenharmony_ci#define __cpu_is_pxa300(id)				\
1468c2ecf20Sopenharmony_ci	({						\
1478c2ecf20Sopenharmony_ci		unsigned int _id = (id) >> 4 & 0xfff;	\
1488c2ecf20Sopenharmony_ci		_id == 0x688;				\
1498c2ecf20Sopenharmony_ci	 })
1508c2ecf20Sopenharmony_ci#else
1518c2ecf20Sopenharmony_ci#define __cpu_is_pxa300(id)	(0)
1528c2ecf20Sopenharmony_ci#endif
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_PXA310
1558c2ecf20Sopenharmony_ci#define __cpu_is_pxa310(id)				\
1568c2ecf20Sopenharmony_ci	({						\
1578c2ecf20Sopenharmony_ci		unsigned int _id = (id) >> 4 & 0xfff;	\
1588c2ecf20Sopenharmony_ci		_id == 0x689;				\
1598c2ecf20Sopenharmony_ci	 })
1608c2ecf20Sopenharmony_ci#else
1618c2ecf20Sopenharmony_ci#define __cpu_is_pxa310(id)	(0)
1628c2ecf20Sopenharmony_ci#endif
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_PXA320
1658c2ecf20Sopenharmony_ci#define __cpu_is_pxa320(id)				\
1668c2ecf20Sopenharmony_ci	({						\
1678c2ecf20Sopenharmony_ci		unsigned int _id = (id) >> 4 & 0xfff;	\
1688c2ecf20Sopenharmony_ci		_id == 0x603 || _id == 0x682;		\
1698c2ecf20Sopenharmony_ci	 })
1708c2ecf20Sopenharmony_ci#else
1718c2ecf20Sopenharmony_ci#define __cpu_is_pxa320(id)	(0)
1728c2ecf20Sopenharmony_ci#endif
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_PXA930
1758c2ecf20Sopenharmony_ci#define __cpu_is_pxa930(id)				\
1768c2ecf20Sopenharmony_ci	({						\
1778c2ecf20Sopenharmony_ci		unsigned int _id = (id) >> 4 & 0xfff;	\
1788c2ecf20Sopenharmony_ci		_id == 0x683;				\
1798c2ecf20Sopenharmony_ci	 })
1808c2ecf20Sopenharmony_ci#else
1818c2ecf20Sopenharmony_ci#define __cpu_is_pxa930(id)	(0)
1828c2ecf20Sopenharmony_ci#endif
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_PXA935
1858c2ecf20Sopenharmony_ci#define __cpu_is_pxa935(id)				\
1868c2ecf20Sopenharmony_ci	({						\
1878c2ecf20Sopenharmony_ci		unsigned int _id = (id) >> 4 & 0xfff;	\
1888c2ecf20Sopenharmony_ci		_id == 0x693;				\
1898c2ecf20Sopenharmony_ci	 })
1908c2ecf20Sopenharmony_ci#else
1918c2ecf20Sopenharmony_ci#define __cpu_is_pxa935(id)	(0)
1928c2ecf20Sopenharmony_ci#endif
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci#define cpu_is_pxa210()					\
1958c2ecf20Sopenharmony_ci	({						\
1968c2ecf20Sopenharmony_ci		__cpu_is_pxa210(read_cpuid_id());	\
1978c2ecf20Sopenharmony_ci	})
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci#define cpu_is_pxa250()					\
2008c2ecf20Sopenharmony_ci	({						\
2018c2ecf20Sopenharmony_ci		__cpu_is_pxa250(read_cpuid_id());	\
2028c2ecf20Sopenharmony_ci	})
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci#define cpu_is_pxa255()                                 \
2058c2ecf20Sopenharmony_ci	({                                              \
2068c2ecf20Sopenharmony_ci		__cpu_is_pxa255(read_cpuid_id());       \
2078c2ecf20Sopenharmony_ci	})
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci#define cpu_is_pxa25x()					\
2108c2ecf20Sopenharmony_ci	({						\
2118c2ecf20Sopenharmony_ci		__cpu_is_pxa25x(read_cpuid_id());	\
2128c2ecf20Sopenharmony_ci	})
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci#define cpu_is_pxa27x()					\
2158c2ecf20Sopenharmony_ci	({						\
2168c2ecf20Sopenharmony_ci		__cpu_is_pxa27x(read_cpuid_id());	\
2178c2ecf20Sopenharmony_ci	})
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci#define cpu_is_pxa300()					\
2208c2ecf20Sopenharmony_ci	({						\
2218c2ecf20Sopenharmony_ci		__cpu_is_pxa300(read_cpuid_id());	\
2228c2ecf20Sopenharmony_ci	 })
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci#define cpu_is_pxa310()					\
2258c2ecf20Sopenharmony_ci	({						\
2268c2ecf20Sopenharmony_ci		__cpu_is_pxa310(read_cpuid_id());	\
2278c2ecf20Sopenharmony_ci	 })
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci#define cpu_is_pxa320()					\
2308c2ecf20Sopenharmony_ci	({						\
2318c2ecf20Sopenharmony_ci		__cpu_is_pxa320(read_cpuid_id());	\
2328c2ecf20Sopenharmony_ci	 })
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci#define cpu_is_pxa930()					\
2358c2ecf20Sopenharmony_ci	({						\
2368c2ecf20Sopenharmony_ci		__cpu_is_pxa930(read_cpuid_id());	\
2378c2ecf20Sopenharmony_ci	 })
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci#define cpu_is_pxa935()					\
2408c2ecf20Sopenharmony_ci	({						\
2418c2ecf20Sopenharmony_ci		__cpu_is_pxa935(read_cpuid_id());	\
2428c2ecf20Sopenharmony_ci	 })
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci/*
2478c2ecf20Sopenharmony_ci * CPUID Core Generation Bit
2488c2ecf20Sopenharmony_ci * <= 0x2 for pxa21x/pxa25x/pxa26x/pxa27x
2498c2ecf20Sopenharmony_ci */
2508c2ecf20Sopenharmony_ci#if defined(CONFIG_PXA25x) || defined(CONFIG_PXA27x)
2518c2ecf20Sopenharmony_ci#define __cpu_is_pxa2xx(id)				\
2528c2ecf20Sopenharmony_ci	({						\
2538c2ecf20Sopenharmony_ci		unsigned int _id = (id) >> 13 & 0x7;	\
2548c2ecf20Sopenharmony_ci		_id <= 0x2;				\
2558c2ecf20Sopenharmony_ci	 })
2568c2ecf20Sopenharmony_ci#else
2578c2ecf20Sopenharmony_ci#define __cpu_is_pxa2xx(id)	(0)
2588c2ecf20Sopenharmony_ci#endif
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci#ifdef CONFIG_PXA3xx
2618c2ecf20Sopenharmony_ci#define __cpu_is_pxa3xx(id)				\
2628c2ecf20Sopenharmony_ci	({						\
2638c2ecf20Sopenharmony_ci		__cpu_is_pxa300(id)			\
2648c2ecf20Sopenharmony_ci			|| __cpu_is_pxa310(id)		\
2658c2ecf20Sopenharmony_ci			|| __cpu_is_pxa320(id)		\
2668c2ecf20Sopenharmony_ci			|| __cpu_is_pxa93x(id);		\
2678c2ecf20Sopenharmony_ci	 })
2688c2ecf20Sopenharmony_ci#else
2698c2ecf20Sopenharmony_ci#define __cpu_is_pxa3xx(id)	(0)
2708c2ecf20Sopenharmony_ci#endif
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci#if defined(CONFIG_CPU_PXA930) || defined(CONFIG_CPU_PXA935)
2738c2ecf20Sopenharmony_ci#define __cpu_is_pxa93x(id)				\
2748c2ecf20Sopenharmony_ci	({						\
2758c2ecf20Sopenharmony_ci		__cpu_is_pxa930(id)			\
2768c2ecf20Sopenharmony_ci			|| __cpu_is_pxa935(id);		\
2778c2ecf20Sopenharmony_ci	 })
2788c2ecf20Sopenharmony_ci#else
2798c2ecf20Sopenharmony_ci#define __cpu_is_pxa93x(id)	(0)
2808c2ecf20Sopenharmony_ci#endif
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci#define cpu_is_pxa2xx()					\
2838c2ecf20Sopenharmony_ci	({						\
2848c2ecf20Sopenharmony_ci		__cpu_is_pxa2xx(read_cpuid_id());	\
2858c2ecf20Sopenharmony_ci	 })
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci#define cpu_is_pxa3xx()					\
2888c2ecf20Sopenharmony_ci	({						\
2898c2ecf20Sopenharmony_ci		__cpu_is_pxa3xx(read_cpuid_id());	\
2908c2ecf20Sopenharmony_ci	 })
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci#define cpu_is_pxa93x()					\
2938c2ecf20Sopenharmony_ci	({						\
2948c2ecf20Sopenharmony_ci		__cpu_is_pxa93x(read_cpuid_id());	\
2958c2ecf20Sopenharmony_ci	 })
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci/*
2998c2ecf20Sopenharmony_ci * return current memory and LCD clock frequency in units of 10kHz
3008c2ecf20Sopenharmony_ci */
3018c2ecf20Sopenharmony_ciextern unsigned int get_memclk_frequency_10khz(void);
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci#endif
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci#endif  /* _ASM_ARCH_HARDWARE_H */
306