xio.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * xio.h
  3. *
  4. * Defines XIo functions for Xilinx OCP in terms of Linux primitives
  5. *
  6. * Author: MontaVista Software, Inc.
  7. * source@mvista.com
  8. *
  9. * 2002 (c) MontaVista, Software, Inc. This file is licensed under the terms
  10. * of the GNU General Public License version 2. This program is licensed
  11. * "as is" without any warranty of any kind, whether express or implied.
  12. */
  13. #ifndef XIO_H
  14. #define XIO_H
  15. #include "xbasic_types.h"
  16. #include <asm/io.h>
  17. typedef u32 XIo_Address;
  18. extern inline u8
  19. XIo_In8(XIo_Address InAddress)
  20. {
  21. return (u8) in_8((volatile unsigned char *) InAddress);
  22. }
  23. extern inline u16
  24. XIo_In16(XIo_Address InAddress)
  25. {
  26. return (u16) in_be16((volatile unsigned short *) InAddress);
  27. }
  28. extern inline u32
  29. XIo_In32(XIo_Address InAddress)
  30. {
  31. return (u32) in_be32((volatile unsigned *) InAddress);
  32. }
  33. extern inline void
  34. XIo_Out8(XIo_Address OutAddress, u8 Value)
  35. {
  36. out_8((volatile unsigned char *) OutAddress, Value);
  37. }
  38. extern inline void
  39. XIo_Out16(XIo_Address OutAddress, u16 Value)
  40. {
  41. out_be16((volatile unsigned short *) OutAddress, Value);
  42. }
  43. extern inline void
  44. XIo_Out32(XIo_Address OutAddress, u32 Value)
  45. {
  46. out_be32((volatile unsigned *) OutAddress, Value);
  47. }
  48. #define XIo_ToLittleEndian16(s,d) (*(u16*)(d) = cpu_to_le16((u16)(s)))
  49. #define XIo_ToLittleEndian32(s,d) (*(u32*)(d) = cpu_to_le32((u32)(s)))
  50. #define XIo_ToBigEndian16(s,d) (*(u16*)(d) = cpu_to_be16((u16)(s)))
  51. #define XIo_ToBigEndian32(s,d) (*(u32*)(d) = cpu_to_be32((u32)(s)))
  52. #define XIo_FromLittleEndian16(s,d) (*(u16*)(d) = le16_to_cpu((u16)(s)))
  53. #define XIo_FromLittleEndian32(s,d) (*(u32*)(d) = le32_to_cpu((u32)(s)))
  54. #define XIo_FromBigEndian16(s,d) (*(u16*)(d) = be16_to_cpu((u16)(s)))
  55. #define XIo_FromBigEndian32(s,d) (*(u32*)(d) = be32_to_cpu((u32)(s)))
  56. #endif /* XIO_H */