Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * MTD primitives for XIP support. Architecture specific functions.
0004  *
0005  * Do not include this file directly. It's included from linux/mtd/xip.h
0006  *
0007  * Author: Vladimir Barinov <vbarinov@embeddedalley.com>
0008  *
0009  * (c) 2005 MontaVista Software, Inc.
0010  */
0011 
0012 #ifndef __ARCH_OMAP_MTD_XIP_H__
0013 #define __ARCH_OMAP_MTD_XIP_H__
0014 
0015 #include "hardware.h"
0016 #include <linux/soc/ti/omap1-io.h>
0017 #define OMAP_MPU_TIMER_BASE (0xfffec500)
0018 #define OMAP_MPU_TIMER_OFFSET   0x100
0019 
0020 typedef struct {
0021     u32 cntl;           /* CNTL_TIMER, R/W */
0022     u32 load_tim;           /* LOAD_TIM,   W */
0023     u32 read_tim;           /* READ_TIM,   R */
0024 } xip_omap_mpu_timer_regs_t;
0025 
0026 #define xip_omap_mpu_timer_base(n)                  \
0027 ((volatile xip_omap_mpu_timer_regs_t*)OMAP1_IO_ADDRESS(OMAP_MPU_TIMER_BASE +    \
0028     (n)*OMAP_MPU_TIMER_OFFSET))
0029 
0030 static inline unsigned long xip_omap_mpu_timer_read(int nr)
0031 {
0032     volatile xip_omap_mpu_timer_regs_t* timer = xip_omap_mpu_timer_base(nr);
0033     return timer->read_tim;
0034 }
0035 
0036 #define xip_irqpending()    \
0037     (omap_readl(OMAP_IH1_ITR) & ~omap_readl(OMAP_IH1_MIR))
0038 #define xip_currtime()      (~xip_omap_mpu_timer_read(0))
0039 
0040 /*
0041  * It's permitted to do approximation for xip_elapsed_since macro
0042  * (see linux/mtd/xip.h)
0043  */
0044 
0045 #ifdef CONFIG_MACH_OMAP_PERSEUS2
0046 #define xip_elapsed_since(x)    (signed)((~xip_omap_mpu_timer_read(0) - (x)) / 7)
0047 #else
0048 #define xip_elapsed_since(x)    (signed)((~xip_omap_mpu_timer_read(0) - (x)) / 6)
0049 #endif
0050 
0051 /*
0052  * xip_cpu_idle() is used when waiting for a delay equal or larger than
0053  * the system timer tick period.  This should put the CPU into idle mode
0054  * to save power and to be woken up only when some interrupts are pending.
0055  * As above, this should not rely upon standard kernel code.
0056  */
0057 
0058 #define xip_cpu_idle()  asm volatile ("mcr p15, 0, %0, c7, c0, 4" :: "r" (1))
0059 
0060 #endif /* __ARCH_OMAP_MTD_XIP_H__ */