blob: 1944e36005dee4f8eec827a4987060620e87016c [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 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
Pavel Herrmann28920b12012-10-07 05:56:09 +00009 */
10
11#include <common.h>
12#include <ide.h>
13#include <ata.h>
Pavel Herrmann0a4a64c2012-10-09 07:06:25 +000014#include <asm/io.h>
Pavel Herrmann28920b12012-10-07 05:56:09 +000015
16#define EIEIO __asm__ volatile ("eieio")
17#define SYNC __asm__ volatile ("sync")
18
19void ide_input_swap_data(int dev, ulong *sect_buf, int words)
20{
21 uchar i;
22 volatile uchar *pbuf_even =
23 (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
24 volatile uchar *pbuf_odd =
25 (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
26 ushort *dbuf = (ushort *) sect_buf;
27
28 while (words--) {
29 for (i = 0; i < 2; i++) {
30 *(((uchar *) (dbuf)) + 1) = *pbuf_even;
31 *(uchar *) dbuf = *pbuf_odd;
32 dbuf += 1;
33 }
34 }
35}
36
37void ide_input_data(int dev, ulong *sect_buf, int words)
38{
39 uchar *dbuf;
40 volatile uchar *pbuf_even;
41 volatile uchar *pbuf_odd;
42
43 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
44 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
45 dbuf = (uchar *) sect_buf;
46 while (words--) {
47 *dbuf++ = *pbuf_even;
48 EIEIO;
49 SYNC;
50 *dbuf++ = *pbuf_odd;
51 EIEIO;
52 SYNC;
53 *dbuf++ = *pbuf_even;
54 EIEIO;
55 SYNC;
56 *dbuf++ = *pbuf_odd;
57 EIEIO;
58 SYNC;
59 }
60}
61
62void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
63{
64 uchar *dbuf;
65 volatile uchar *pbuf_even;
66 volatile uchar *pbuf_odd;
67
68 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
69 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
70 dbuf = (uchar *) sect_buf;
71 while (shorts--) {
72 EIEIO;
73 *dbuf++ = *pbuf_even;
74 EIEIO;
75 *dbuf++ = *pbuf_odd;
76 }
77}
78
79void ide_output_data(int dev, const ulong *sect_buf, int words)
80{
81 uchar *dbuf;
82 volatile uchar *pbuf_even;
83 volatile uchar *pbuf_odd;
84
85 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
86 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
87 dbuf = (uchar *) sect_buf;
88 while (words--) {
89 EIEIO;
90 *pbuf_even = *dbuf++;
91 EIEIO;
92 *pbuf_odd = *dbuf++;
93 EIEIO;
94 *pbuf_even = *dbuf++;
95 EIEIO;
96 *pbuf_odd = *dbuf++;
97 }
98}
99
100void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
101{
102 uchar *dbuf;
103 volatile uchar *pbuf_even;
104 volatile uchar *pbuf_odd;
105
106 pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
107 pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
108 dbuf = (uchar *) sect_buf;
109 while (shorts--) {
110 EIEIO;
111 *pbuf_even = *dbuf++;
112 EIEIO;
113 *pbuf_odd = *dbuf++;
114 }
115}
Pavel Herrmann0a4a64c2012-10-09 07:06:25 +0000116
117void ide_led(uchar led, uchar status)
118{
119 u_char val;
120 /* We have one PCMCIA slot and use LED H4 for the IDE Interface */
121 val = readb(BCSR_BASE + 0x04);
122 if (status) /* led on */
123 val |= B_CTRL_LED0;
124 else
125 val &= ~B_CTRL_LED0;
126
127 writeb(val, BCSR_BASE + 0x04);
128}