io.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef _H8300_IO_H
  2. #define _H8300_IO_H
  3. #ifdef __KERNEL__
  4. #include <asm-generic/io.h>
  5. /* H8/300 internal I/O functions */
  6. static inline unsigned char ctrl_inb(unsigned long addr)
  7. {
  8. return *(volatile unsigned char *)addr;
  9. }
  10. static inline unsigned short ctrl_inw(unsigned long addr)
  11. {
  12. return *(volatile unsigned short *)addr;
  13. }
  14. static inline unsigned long ctrl_inl(unsigned long addr)
  15. {
  16. return *(volatile unsigned long *)addr;
  17. }
  18. static inline void ctrl_outb(unsigned char b, unsigned long addr)
  19. {
  20. *(volatile unsigned char *)addr = b;
  21. }
  22. static inline void ctrl_outw(unsigned short b, unsigned long addr)
  23. {
  24. *(volatile unsigned short *)addr = b;
  25. }
  26. static inline void ctrl_outl(unsigned long b, unsigned long addr)
  27. {
  28. *(volatile unsigned long *)addr = b;
  29. }
  30. static inline void ctrl_bclr(int b, unsigned char *addr)
  31. {
  32. if (__builtin_constant_p(b))
  33. __asm__("bclr %1,%0" : "+WU"(*addr): "i"(b));
  34. else
  35. __asm__("bclr %w1,%0" : "+WU"(*addr): "r"(b));
  36. }
  37. static inline void ctrl_bset(int b, unsigned char *addr)
  38. {
  39. if (__builtin_constant_p(b))
  40. __asm__("bset %1,%0" : "+WU"(*addr): "i"(b));
  41. else
  42. __asm__("bset %w1,%0" : "+WU"(*addr): "r"(b));
  43. }
  44. #endif /* __KERNEL__ */
  45. #endif /* _H8300_IO_H */