blob: 7b7237b908d19337e1ab7c883aaba008ee017cb1 [file] [log] [blame]
Pavel Herrmann28920b12012-10-07 05:56:09 +00001/*
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
27#include <common.h>
28#include <ide.h>
29#include <ata.h>
30
31#define EIEIO __asm__ volatile ("eieio")
32#define SYNC __asm__ volatile ("sync")
33
34void ide_input_swap_data(int dev, ulong *sect_buf, int words)
35{
36 uchar i;
37 volatile uchar *pbuf_even =
38 (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
39 volatile uchar *pbuf_odd =
40 (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
41 ushort *dbuf = (ushort *) sect_buf;
42
43 while (words--) {
44 for (i = 0; i < 2; i++) {
45 *(((uchar *) (dbuf)) + 1) = *pbuf_even;
46 *(uchar *) dbuf = *pbuf_odd;
47 dbuf += 1;
48 }
49 }
50}
51
52void ide_input_data(int dev, ulong *sect_buf, int words)
53{
54 uchar *dbuf;
55 volatile uchar *pbuf_even;
56 volatile uchar *pbuf_odd;
57
58 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
59 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
60 dbuf = (uchar *) sect_buf;
61 while (words--) {
62 *dbuf++ = *pbuf_even;
63 EIEIO;
64 SYNC;
65 *dbuf++ = *pbuf_odd;
66 EIEIO;
67 SYNC;
68 *dbuf++ = *pbuf_even;
69 EIEIO;
70 SYNC;
71 *dbuf++ = *pbuf_odd;
72 EIEIO;
73 SYNC;
74 }
75}
76
77void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
78{
79 uchar *dbuf;
80 volatile uchar *pbuf_even;
81 volatile uchar *pbuf_odd;
82
83 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
84 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
85 dbuf = (uchar *) sect_buf;
86 while (shorts--) {
87 EIEIO;
88 *dbuf++ = *pbuf_even;
89 EIEIO;
90 *dbuf++ = *pbuf_odd;
91 }
92}
93
94void ide_output_data(int dev, const ulong *sect_buf, int words)
95{
96 uchar *dbuf;
97 volatile uchar *pbuf_even;
98 volatile uchar *pbuf_odd;
99
100 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
101 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
102 dbuf = (uchar *) sect_buf;
103 while (words--) {
104 EIEIO;
105 *pbuf_even = *dbuf++;
106 EIEIO;
107 *pbuf_odd = *dbuf++;
108 EIEIO;
109 *pbuf_even = *dbuf++;
110 EIEIO;
111 *pbuf_odd = *dbuf++;
112 }
113}
114
115void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
116{
117 uchar *dbuf;
118 volatile uchar *pbuf_even;
119 volatile uchar *pbuf_odd;
120
121 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
122 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
123 dbuf = (uchar *) sect_buf;
124 while (shorts--) {
125 EIEIO;
126 *pbuf_even = *dbuf++;
127 EIEIO;
128 *pbuf_odd = *dbuf++;
129 }
130}