18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * MTD primitives for XIP support. Architecture specific functions
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Do not include this file directly. It's included from linux/mtd/xip.h
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Author:	Nicolas Pitre
88c2ecf20Sopenharmony_ci * Created:	Nov 2, 2004
98c2ecf20Sopenharmony_ci * Copyright:	(C) 2004 MontaVista Software, Inc.
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef __ARCH_PXA_MTD_XIP_H__
138c2ecf20Sopenharmony_ci#define __ARCH_PXA_MTD_XIP_H__
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <mach/regs-ost.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/* restored July 2017, this did not build since 2011! */
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define ICIP			io_p2v(0x40d00000)
208c2ecf20Sopenharmony_ci#define ICMR			io_p2v(0x40d00004)
218c2ecf20Sopenharmony_ci#define xip_irqpending()	(readl(ICIP) & readl(ICMR))
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/* we sample OSCR and convert desired delta to usec (1/4 ~= 1000000/3686400) */
248c2ecf20Sopenharmony_ci#define xip_currtime()		readl(OSCR)
258c2ecf20Sopenharmony_ci#define xip_elapsed_since(x)	(signed)((readl(OSCR) - (x)) / 4)
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/*
288c2ecf20Sopenharmony_ci * xip_cpu_idle() is used when waiting for a delay equal or larger than
298c2ecf20Sopenharmony_ci * the system timer tick period.  This should put the CPU into idle mode
308c2ecf20Sopenharmony_ci * to save power and to be woken up only when some interrupts are pending.
318c2ecf20Sopenharmony_ci * As above, this should not rely upon standard kernel code.
328c2ecf20Sopenharmony_ci */
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#define xip_cpu_idle()  asm volatile ("mcr p14, 0, %0, c7, c0, 0" :: "r" (1))
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#endif /* __ARCH_PXA_MTD_XIP_H__ */
37