io.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * I/O access functions for Hexagon
  3. *
  4. * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 and
  8. * only version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA.
  19. */
  20. #include <asm/io.h>
  21. /* These are all FIFO routines! */
  22. /*
  23. * __raw_readsw - read words a short at a time
  24. * @addr: source address
  25. * @data: data address
  26. * @len: number of shorts to read
  27. */
  28. void __raw_readsw(const void __iomem *addr, void *data, int len)
  29. {
  30. const volatile short int *src = (short int *) addr;
  31. short int *dst = (short int *) data;
  32. if ((u32)data & 0x1)
  33. panic("unaligned pointer to readsw");
  34. while (len-- > 0)
  35. *dst++ = *src;
  36. }
  37. /*
  38. * __raw_writesw - read words a short at a time
  39. * @addr: source address
  40. * @data: data address
  41. * @len: number of shorts to read
  42. */
  43. void __raw_writesw(void __iomem *addr, const void *data, int len)
  44. {
  45. const short int *src = (short int *)data;
  46. volatile short int *dst = (short int *)addr;
  47. if ((u32)data & 0x1)
  48. panic("unaligned pointer to writesw");
  49. while (len-- > 0)
  50. *dst = *src++;
  51. }
  52. /* Pretty sure len is pre-adjusted for the length of the access already */
  53. void __raw_readsl(const void __iomem *addr, void *data, int len)
  54. {
  55. const volatile long *src = (long *) addr;
  56. long *dst = (long *) data;
  57. if ((u32)data & 0x3)
  58. panic("unaligned pointer to readsl");
  59. while (len-- > 0)
  60. *dst++ = *src;
  61. }
  62. void __raw_writesl(void __iomem *addr, const void *data, int len)
  63. {
  64. const long *src = (long *)data;
  65. volatile long *dst = (long *)addr;
  66. if ((u32)data & 0x3)
  67. panic("unaligned pointer to writesl");
  68. while (len-- > 0)
  69. *dst = *src++;
  70. }