io.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * I/O access functions for Hexagon
  4. *
  5. * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
  6. */
  7. #include <asm/io.h>
  8. /* These are all FIFO routines! */
  9. /*
  10. * __raw_readsw - read words a short at a time
  11. * @addr: source address
  12. * @data: data address
  13. * @len: number of shorts to read
  14. */
  15. void __raw_readsw(const void __iomem *addr, void *data, int len)
  16. {
  17. const volatile short int *src = (short int *) addr;
  18. short int *dst = (short int *) data;
  19. if ((u32)data & 0x1)
  20. panic("unaligned pointer to readsw");
  21. while (len-- > 0)
  22. *dst++ = *src;
  23. }
  24. EXPORT_SYMBOL(__raw_readsw);
  25. /*
  26. * __raw_writesw - read words a short at a time
  27. * @addr: source address
  28. * @data: data address
  29. * @len: number of shorts to read
  30. */
  31. void __raw_writesw(void __iomem *addr, const void *data, int len)
  32. {
  33. const short int *src = (short int *)data;
  34. volatile short int *dst = (short int *)addr;
  35. if ((u32)data & 0x1)
  36. panic("unaligned pointer to writesw");
  37. while (len-- > 0)
  38. *dst = *src++;
  39. }
  40. EXPORT_SYMBOL(__raw_writesw);
  41. /* Pretty sure len is pre-adjusted for the length of the access already */
  42. void __raw_readsl(const void __iomem *addr, void *data, int len)
  43. {
  44. const volatile long *src = (long *) addr;
  45. long *dst = (long *) data;
  46. if ((u32)data & 0x3)
  47. panic("unaligned pointer to readsl");
  48. while (len-- > 0)
  49. *dst++ = *src;
  50. }
  51. EXPORT_SYMBOL(__raw_readsl);
  52. void __raw_writesl(void __iomem *addr, const void *data, int len)
  53. {
  54. const long *src = (long *)data;
  55. volatile long *dst = (long *)addr;
  56. if ((u32)data & 0x3)
  57. panic("unaligned pointer to writesl");
  58. while (len-- > 0)
  59. *dst = *src++;
  60. }
  61. EXPORT_SYMBOL(__raw_writesl);