ide.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * (C) Copyright 2001
  3. * Rob Taylor, Flying Pig Systems. robt@flyingpig.com.
  4. *
  5. * (C) Copyright 2000-2011
  6. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <ide.h>
  28. #include <ata.h>
  29. #define EIEIO __asm__ volatile ("eieio")
  30. #define SYNC __asm__ volatile ("sync")
  31. void ide_input_swap_data(int dev, ulong *sect_buf, int words)
  32. {
  33. uchar i;
  34. volatile uchar *pbuf_even =
  35. (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  36. volatile uchar *pbuf_odd =
  37. (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
  38. ushort *dbuf = (ushort *) sect_buf;
  39. while (words--) {
  40. for (i = 0; i < 2; i++) {
  41. *(((uchar *) (dbuf)) + 1) = *pbuf_even;
  42. *(uchar *) dbuf = *pbuf_odd;
  43. dbuf += 1;
  44. }
  45. }
  46. }
  47. void ide_input_data(int dev, ulong *sect_buf, int words)
  48. {
  49. uchar *dbuf;
  50. volatile uchar *pbuf_even;
  51. volatile uchar *pbuf_odd;
  52. pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  53. pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
  54. dbuf = (uchar *) sect_buf;
  55. while (words--) {
  56. *dbuf++ = *pbuf_even;
  57. EIEIO;
  58. SYNC;
  59. *dbuf++ = *pbuf_odd;
  60. EIEIO;
  61. SYNC;
  62. *dbuf++ = *pbuf_even;
  63. EIEIO;
  64. SYNC;
  65. *dbuf++ = *pbuf_odd;
  66. EIEIO;
  67. SYNC;
  68. }
  69. }
  70. void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
  71. {
  72. uchar *dbuf;
  73. volatile uchar *pbuf_even;
  74. volatile uchar *pbuf_odd;
  75. pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  76. pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
  77. dbuf = (uchar *) sect_buf;
  78. while (shorts--) {
  79. EIEIO;
  80. *dbuf++ = *pbuf_even;
  81. EIEIO;
  82. *dbuf++ = *pbuf_odd;
  83. }
  84. }
  85. void ide_output_data(int dev, const ulong *sect_buf, int words)
  86. {
  87. uchar *dbuf;
  88. volatile uchar *pbuf_even;
  89. volatile uchar *pbuf_odd;
  90. pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  91. pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
  92. dbuf = (uchar *) sect_buf;
  93. while (words--) {
  94. EIEIO;
  95. *pbuf_even = *dbuf++;
  96. EIEIO;
  97. *pbuf_odd = *dbuf++;
  98. EIEIO;
  99. *pbuf_even = *dbuf++;
  100. EIEIO;
  101. *pbuf_odd = *dbuf++;
  102. }
  103. }
  104. void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
  105. {
  106. uchar *dbuf;
  107. volatile uchar *pbuf_even;
  108. volatile uchar *pbuf_odd;
  109. pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  110. pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
  111. dbuf = (uchar *) sect_buf;
  112. while (shorts--) {
  113. EIEIO;
  114. *pbuf_even = *dbuf++;
  115. EIEIO;
  116. *pbuf_odd = *dbuf++;
  117. }
  118. }