/* SPDX-License-Identifier: GPL-2.0-only */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.h5*6* Author: Vladimir Barinov <[email protected]>7*8* (c) 2005 MontaVista Software, Inc.9*/1011#ifndef __ARCH_OMAP_MTD_XIP_H__12#define __ARCH_OMAP_MTD_XIP_H__1314#include "hardware.h"15#include <linux/soc/ti/omap1-io.h>16#define OMAP_MPU_TIMER_BASE (0xfffec500)17#define OMAP_MPU_TIMER_OFFSET 0x1001819typedef struct {20u32 cntl; /* CNTL_TIMER, R/W */21u32 load_tim; /* LOAD_TIM, W */22u32 read_tim; /* READ_TIM, R */23} xip_omap_mpu_timer_regs_t;2425#define xip_omap_mpu_timer_base(n) \26((volatile xip_omap_mpu_timer_regs_t*)OMAP1_IO_ADDRESS(OMAP_MPU_TIMER_BASE + \27(n)*OMAP_MPU_TIMER_OFFSET))2829static inline unsigned long xip_omap_mpu_timer_read(int nr)30{31volatile xip_omap_mpu_timer_regs_t* timer = xip_omap_mpu_timer_base(nr);32return timer->read_tim;33}3435#define xip_irqpending() \36(omap_readl(OMAP_IH1_ITR) & ~omap_readl(OMAP_IH1_MIR))37#define xip_currtime() (~xip_omap_mpu_timer_read(0))3839/*40* It's permitted to do approximation for xip_elapsed_since macro41* (see linux/mtd/xip.h)42*/4344#define xip_elapsed_since(x) (signed)((~xip_omap_mpu_timer_read(0) - (x)) / 6)4546/*47* xip_cpu_idle() is used when waiting for a delay equal or larger than48* the system timer tick period. This should put the CPU into idle mode49* to save power and to be woken up only when some interrupts are pending.50* As above, this should not rely upon standard kernel code.51*/5253#define xip_cpu_idle() asm volatile ("mcr p15, 0, %0, c7, c0, 4" :: "r" (1))5455#endif /* __ARCH_OMAP_MTD_XIP_H__ */565758