xref: /OK3568_Linux_fs/kernel/arch/arm/mach-pxa/include/mach/mtd-xip.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * MTD primitives for XIP support. Architecture specific functions
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Do not include this file directly. It's included from linux/mtd/xip.h
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Author:	Nicolas Pitre
8*4882a593Smuzhiyun  * Created:	Nov 2, 2004
9*4882a593Smuzhiyun  * Copyright:	(C) 2004 MontaVista Software, Inc.
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #ifndef __ARCH_PXA_MTD_XIP_H__
13*4882a593Smuzhiyun #define __ARCH_PXA_MTD_XIP_H__
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #include <mach/regs-ost.h>
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun /* restored July 2017, this did not build since 2011! */
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #define ICIP			io_p2v(0x40d00000)
20*4882a593Smuzhiyun #define ICMR			io_p2v(0x40d00004)
21*4882a593Smuzhiyun #define xip_irqpending()	(readl(ICIP) & readl(ICMR))
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun /* we sample OSCR and convert desired delta to usec (1/4 ~= 1000000/3686400) */
24*4882a593Smuzhiyun #define xip_currtime()		readl(OSCR)
25*4882a593Smuzhiyun #define xip_elapsed_since(x)	(signed)((readl(OSCR) - (x)) / 4)
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun /*
28*4882a593Smuzhiyun  * xip_cpu_idle() is used when waiting for a delay equal or larger than
29*4882a593Smuzhiyun  * the system timer tick period.  This should put the CPU into idle mode
30*4882a593Smuzhiyun  * to save power and to be woken up only when some interrupts are pending.
31*4882a593Smuzhiyun  * As above, this should not rely upon standard kernel code.
32*4882a593Smuzhiyun  */
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun #define xip_cpu_idle()  asm volatile ("mcr p14, 0, %0, c7, c0, 0" :: "r" (1))
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun #endif /* __ARCH_PXA_MTD_XIP_H__ */
37