io.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * File : io.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://openlab.rt-thread.com/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2011-01-13 weety first version
  13. */
  14. #ifndef __ASM_ARCH_IO_H
  15. #define __ASM_ARCH_IO_H
  16. #define AT91_BASE_SYS 0xffffe800
  17. #define IO_SPACE_LIMIT 0xFFFFFFFF
  18. #define readb(a) (*(volatile unsigned char *)(a))
  19. #define readw(a) (*(volatile unsigned short *)(a))
  20. #define readl(a) (*(volatile unsigned int *)(a))
  21. #define writeb(v,a) (*(volatile unsigned char *)(a) = (v))
  22. #define writew(v,a) (*(volatile unsigned short *)(a) = (v))
  23. #define writel(v,a) (*(volatile unsigned int *)(a) = (v))
  24. static inline unsigned int at91_sys_read(unsigned int reg_offset)
  25. {
  26. void *addr = (void *)AT91_BASE_SYS;
  27. return readl(addr + reg_offset);
  28. }
  29. static inline void at91_sys_write(unsigned int reg_offset, unsigned long value)
  30. {
  31. void *addr = (void *)AT91_BASE_SYS;
  32. writel(value, addr + reg_offset);
  33. }
  34. #endif