xref: /openbmc/linux/arch/arm/mach-omap1/mtd-xip.h (revision c494a447)
1 /*
2  * MTD primitives for XIP support. Architecture specific functions.
3  *
4  * Do not include this file directly. It's included from linux/mtd/xip.h
5  *
6  * Author: Vladimir Barinov <vbarinov@embeddedalley.com>
7  *
8  * (c) 2005 MontaVista Software, Inc.  This file is licensed under the
9  * terms of the GNU General Public License version 2.  This program is
10  * licensed "as is" without any warranty of any kind, whether express or
11  * implied.
12  */
13 
14 #ifndef __ARCH_OMAP_MTD_XIP_H__
15 #define __ARCH_OMAP_MTD_XIP_H__
16 
17 #include "hardware.h"
18 #include <linux/soc/ti/omap1-io.h>
19 #define OMAP_MPU_TIMER_BASE	(0xfffec500)
20 #define OMAP_MPU_TIMER_OFFSET	0x100
21 
22 typedef struct {
23 	u32 cntl;			/* CNTL_TIMER, R/W */
24 	u32 load_tim;			/* LOAD_TIM,   W */
25 	u32 read_tim;			/* READ_TIM,   R */
26 } xip_omap_mpu_timer_regs_t;
27 
28 #define xip_omap_mpu_timer_base(n)					\
29 ((volatile xip_omap_mpu_timer_regs_t*)OMAP1_IO_ADDRESS(OMAP_MPU_TIMER_BASE +	\
30 	(n)*OMAP_MPU_TIMER_OFFSET))
31 
32 static inline unsigned long xip_omap_mpu_timer_read(int nr)
33 {
34 	volatile xip_omap_mpu_timer_regs_t* timer = xip_omap_mpu_timer_base(nr);
35 	return timer->read_tim;
36 }
37 
38 #define xip_irqpending()	\
39 	(omap_readl(OMAP_IH1_ITR) & ~omap_readl(OMAP_IH1_MIR))
40 #define xip_currtime()		(~xip_omap_mpu_timer_read(0))
41 
42 /*
43  * It's permitted to do approximation for xip_elapsed_since macro
44  * (see linux/mtd/xip.h)
45  */
46 
47 #ifdef CONFIG_MACH_OMAP_PERSEUS2
48 #define xip_elapsed_since(x)	(signed)((~xip_omap_mpu_timer_read(0) - (x)) / 7)
49 #else
50 #define xip_elapsed_since(x)	(signed)((~xip_omap_mpu_timer_read(0) - (x)) / 6)
51 #endif
52 
53 /*
54  * xip_cpu_idle() is used when waiting for a delay equal or larger than
55  * the system timer tick period.  This should put the CPU into idle mode
56  * to save power and to be woken up only when some interrupts are pending.
57  * As above, this should not rely upon standard kernel code.
58  */
59 
60 #define xip_cpu_idle()  asm volatile ("mcr p15, 0, %0, c7, c0, 4" :: "r" (1))
61 
62 #endif /* __ARCH_OMAP_MTD_XIP_H__ */
63