ide.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. #include <asm/io.h>
  30. #define EIEIO __asm__ volatile ("eieio")
  31. #define SYNC __asm__ volatile ("sync")
  32. void ide_input_swap_data(int dev, ulong *sect_buf, int words)
  33. {
  34. uchar i;
  35. volatile uchar *pbuf_even =
  36. (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  37. volatile uchar *pbuf_odd =
  38. (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
  39. ushort *dbuf = (ushort *) sect_buf;
  40. while (words--) {
  41. for (i = 0; i < 2; i++) {
  42. *(((uchar *) (dbuf)) + 1) = *pbuf_even;
  43. *(uchar *) dbuf = *pbuf_odd;
  44. dbuf += 1;
  45. }
  46. }
  47. }
  48. void ide_input_data(int dev, ulong *sect_buf, int words)
  49. {
  50. uchar *dbuf;
  51. volatile uchar *pbuf_even;
  52. volatile uchar *pbuf_odd;
  53. pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  54. pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
  55. dbuf = (uchar *) sect_buf;
  56. while (words--) {
  57. *dbuf++ = *pbuf_even;
  58. EIEIO;
  59. SYNC;
  60. *dbuf++ = *pbuf_odd;
  61. EIEIO;
  62. SYNC;
  63. *dbuf++ = *pbuf_even;
  64. EIEIO;
  65. SYNC;
  66. *dbuf++ = *pbuf_odd;
  67. EIEIO;
  68. SYNC;
  69. }
  70. }
  71. void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
  72. {
  73. uchar *dbuf;
  74. volatile uchar *pbuf_even;
  75. volatile uchar *pbuf_odd;
  76. pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  77. pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
  78. dbuf = (uchar *) sect_buf;
  79. while (shorts--) {
  80. EIEIO;
  81. *dbuf++ = *pbuf_even;
  82. EIEIO;
  83. *dbuf++ = *pbuf_odd;
  84. }
  85. }
  86. void ide_output_data(int dev, const ulong *sect_buf, int words)
  87. {
  88. uchar *dbuf;
  89. volatile uchar *pbuf_even;
  90. volatile uchar *pbuf_odd;
  91. pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  92. pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
  93. dbuf = (uchar *) sect_buf;
  94. while (words--) {
  95. EIEIO;
  96. *pbuf_even = *dbuf++;
  97. EIEIO;
  98. *pbuf_odd = *dbuf++;
  99. EIEIO;
  100. *pbuf_even = *dbuf++;
  101. EIEIO;
  102. *pbuf_odd = *dbuf++;
  103. }
  104. }
  105. void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
  106. {
  107. uchar *dbuf;
  108. volatile uchar *pbuf_even;
  109. volatile uchar *pbuf_odd;
  110. pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  111. pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
  112. dbuf = (uchar *) sect_buf;
  113. while (shorts--) {
  114. EIEIO;
  115. *pbuf_even = *dbuf++;
  116. EIEIO;
  117. *pbuf_odd = *dbuf++;
  118. }
  119. }
  120. void ide_led(uchar led, uchar status)
  121. {
  122. u_char val;
  123. /* We have one PCMCIA slot and use LED H4 for the IDE Interface */
  124. val = readb(BCSR_BASE + 0x04);
  125. if (status) /* led on */
  126. val |= B_CTRL_LED0;
  127. else
  128. val &= ~B_CTRL_LED0;
  129. writeb(val, BCSR_BASE + 0x04);
  130. }