Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * MTD primitives for XIP support
0004  *
0005  * Author:  Nicolas Pitre
0006  * Created: Nov 2, 2004
0007  * Copyright:   (C) 2004 MontaVista Software, Inc.
0008  *
0009  * This XIP support for MTD has been loosely inspired
0010  * by an earlier patch authored by David Woodhouse.
0011  */
0012 
0013 #ifndef __LINUX_MTD_XIP_H__
0014 #define __LINUX_MTD_XIP_H__
0015 
0016 
0017 #ifdef CONFIG_MTD_XIP
0018 
0019 /*
0020  * We really don't want gcc to guess anything.
0021  * We absolutely _need_ proper inlining.
0022  */
0023 #include <linux/compiler.h>
0024 
0025 /*
0026  * Function that are modifying the flash state away from array mode must
0027  * obviously not be running from flash.  The __xipram is therefore marking
0028  * those functions so they get relocated to ram.
0029  */
0030 #ifdef CONFIG_XIP_KERNEL
0031 #define __xipram noinline __section(".xiptext")
0032 #endif
0033 
0034 /*
0035  * Each architecture has to provide the following macros.  They must access
0036  * the hardware directly and not rely on any other (XIP) functions since they
0037  * won't be available when used (flash not in array mode).
0038  *
0039  * xip_irqpending()
0040  *
0041  *  return non zero when any hardware interrupt is pending.
0042  *
0043  * xip_currtime()
0044  *
0045  *  return a platform specific time reference to be used with
0046  *  xip_elapsed_since().
0047  *
0048  * xip_elapsed_since(x)
0049  *
0050  *  return in usecs the elapsed timebetween now and the reference x as
0051  *  returned by xip_currtime().
0052  *
0053  *  note 1: conversion to usec can be approximated, as long as the
0054  *      returned value is <= the real elapsed time.
0055  *  note 2: this should be able to cope with a few seconds without
0056  *      overflowing.
0057  *
0058  * xip_iprefetch()
0059  *
0060  *      Macro to fill instruction prefetch
0061  *  e.g. a series of nops:  asm volatile (".rep 8; nop; .endr");
0062  */
0063 
0064 #include <asm/mtd-xip.h>
0065 
0066 #ifndef xip_irqpending
0067 
0068 #warning "missing IRQ and timer primitives for XIP MTD support"
0069 #warning "some of the XIP MTD support code will be disabled"
0070 #warning "your system will therefore be unresponsive when writing or erasing flash"
0071 
0072 #define xip_irqpending()    (0)
0073 #define xip_currtime()      (0)
0074 #define xip_elapsed_since(x)    (0)
0075 
0076 #endif
0077 
0078 #ifndef xip_iprefetch
0079 #define xip_iprefetch()     do { } while (0)
0080 #endif
0081 
0082 /*
0083  * xip_cpu_idle() is used when waiting for a delay equal or larger than
0084  * the system timer tick period.  This should put the CPU into idle mode
0085  * to save power and to be woken up only when some interrupts are pending.
0086  * This should not rely upon standard kernel code.
0087  */
0088 #ifndef xip_cpu_idle
0089 #define xip_cpu_idle()  do { } while (0)
0090 #endif
0091 
0092 #endif /* CONFIG_MTD_XIP */
0093 
0094 #ifndef __xipram
0095 #define __xipram
0096 #endif
0097 
0098 #endif /* __LINUX_MTD_XIP_H__ */