io.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * arch/sh/lib/io.c - SH32 optimized I/O routines
  3. *
  4. * Copyright (C) 2000 Stuart Menefy
  5. * Copyright (C) 2005 Paul Mundt
  6. *
  7. * Provide real functions which expand to whatever the header file defined.
  8. * Also definitions of machine independent IO functions.
  9. *
  10. * This file is subject to the terms and conditions of the GNU General Public
  11. * License. See the file "COPYING" in the main directory of this archive
  12. * for more details.
  13. */
  14. #include <linux/module.h>
  15. #include <linux/io.h>
  16. void __raw_readsl(const void __iomem *addr, void *datap, int len)
  17. {
  18. u32 *data;
  19. for (data = datap; (len != 0) && (((u32)data & 0x1f) != 0); len--)
  20. *data++ = __raw_readl(addr);
  21. if (likely(len >= (0x20 >> 2))) {
  22. int tmp2, tmp3, tmp4, tmp5, tmp6;
  23. __asm__ __volatile__(
  24. "1: \n\t"
  25. "mov.l @%7, r0 \n\t"
  26. "mov.l @%7, %2 \n\t"
  27. #ifdef CONFIG_CPU_SH4
  28. "movca.l r0, @%0 \n\t"
  29. #else
  30. "mov.l r0, @%0 \n\t"
  31. #endif
  32. "mov.l @%7, %3 \n\t"
  33. "mov.l @%7, %4 \n\t"
  34. "mov.l @%7, %5 \n\t"
  35. "mov.l @%7, %6 \n\t"
  36. "mov.l @%7, r7 \n\t"
  37. "mov.l @%7, r0 \n\t"
  38. "mov.l %2, @(0x04,%0) \n\t"
  39. "mov #0x20>>2, %2 \n\t"
  40. "mov.l %3, @(0x08,%0) \n\t"
  41. "sub %2, %1 \n\t"
  42. "mov.l %4, @(0x0c,%0) \n\t"
  43. "cmp/hi %1, %2 ! T if 32 > len \n\t"
  44. "mov.l %5, @(0x10,%0) \n\t"
  45. "mov.l %6, @(0x14,%0) \n\t"
  46. "mov.l r7, @(0x18,%0) \n\t"
  47. "mov.l r0, @(0x1c,%0) \n\t"
  48. "bf.s 1b \n\t"
  49. " add #0x20, %0 \n\t"
  50. : "=&r" (data), "=&r" (len),
  51. "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4),
  52. "=&r" (tmp5), "=&r" (tmp6)
  53. : "r"(addr), "0" (data), "1" (len)
  54. : "r0", "r7", "t", "memory");
  55. }
  56. for (; len != 0; len--)
  57. *data++ = __raw_readl(addr);
  58. }
  59. EXPORT_SYMBOL(__raw_readsl);
  60. void __raw_writesl(void __iomem *addr, const void *data, int len)
  61. {
  62. if (likely(len != 0)) {
  63. int tmp1;
  64. __asm__ __volatile__ (
  65. "1: \n\t"
  66. "mov.l @%0+, %1 \n\t"
  67. "dt %3 \n\t"
  68. "bf.s 1b \n\t"
  69. " mov.l %1, @%4 \n\t"
  70. : "=&r" (data), "=&r" (tmp1)
  71. : "0" (data), "r" (len), "r"(addr)
  72. : "t", "memory");
  73. }
  74. }
  75. EXPORT_SYMBOL(__raw_writesl);