mtd-xip.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #ifndef __ARCH_OMAP_MTD_XIP_H__
  14. #define __ARCH_OMAP_MTD_XIP_H__
  15. #include <mach/hardware.h>
  16. #define OMAP_MPU_TIMER_BASE (0xfffec500)
  17. #define OMAP_MPU_TIMER_OFFSET 0x100
  18. typedef struct {
  19. u32 cntl; /* CNTL_TIMER, R/W */
  20. u32 load_tim; /* LOAD_TIM, W */
  21. u32 read_tim; /* READ_TIM, R */
  22. } xip_omap_mpu_timer_regs_t;
  23. #define xip_omap_mpu_timer_base(n) \
  24. ((volatile xip_omap_mpu_timer_regs_t*)OMAP1_IO_ADDRESS(OMAP_MPU_TIMER_BASE + \
  25. (n)*OMAP_MPU_TIMER_OFFSET))
  26. static inline unsigned long xip_omap_mpu_timer_read(int nr)
  27. {
  28. volatile xip_omap_mpu_timer_regs_t* timer = xip_omap_mpu_timer_base(nr);
  29. return timer->read_tim;
  30. }
  31. #define xip_irqpending() \
  32. (omap_readl(OMAP_IH1_ITR) & ~omap_readl(OMAP_IH1_MIR))
  33. #define xip_currtime() (~xip_omap_mpu_timer_read(0))
  34. /*
  35. * It's permitted to do approximation for xip_elapsed_since macro
  36. * (see linux/mtd/xip.h)
  37. */
  38. #ifdef CONFIG_MACH_OMAP_PERSEUS2
  39. #define xip_elapsed_since(x) (signed)((~xip_omap_mpu_timer_read(0) - (x)) / 7)
  40. #else
  41. #define xip_elapsed_since(x) (signed)((~xip_omap_mpu_timer_read(0) - (x)) / 6)
  42. #endif
  43. /*
  44. * xip_cpu_idle() is used when waiting for a delay equal or larger than
  45. * the system timer tick period. This should put the CPU into idle mode
  46. * to save power and to be woken up only when some interrupts are pending.
  47. * As above, this should not rely upon standard kernel code.
  48. */
  49. #define xip_cpu_idle() asm volatile ("mcr p15, 0, %0, c7, c0, 4" :: "r" (1))
  50. #endif /* __ARCH_OMAP_MTD_XIP_H__ */