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