summaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-06-06 09:19:05 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-06-06 09:42:16 +0200
commit05002a942c511ce176ab4e47f992f0f71dd5bf94 (patch)
tree49d654777b0a839866e26ed67a40b50b2eb4c09b /drivers/ata
parent7ffc9df31d560efd1a76036bec465c1e93a5bb26 (diff)
downloadbarebox-05002a942c511ce176ab4e47f992f0f71dd5bf94.tar.gz
barebox-05002a942c511ce176ab4e47f992f0f71dd5bf94.tar.xz
ata: ahci: only use lba48 on drives which support it
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/ahci.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 7def9a093b..19d445a596 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -224,13 +224,19 @@ static int ahci_rw(struct ata_port *ata, void *rbuf, const void *wbuf,
struct ahci_port *ahci = container_of(ata, struct ahci_port, ata);
u8 fis[20];
int ret;
+ int lba48 = ata_id_has_lba48(ata->id);
memset(fis, 0, sizeof(fis));
/* Construct the FIS */
fis[0] = 0x27; /* Host to device FIS. */
fis[1] = 1 << 7; /* Command FIS. */
- fis[2] = wbuf ? ATA_CMD_WRITE_EXT : ATA_CMD_READ_EXT; /* Command byte. */
+
+ /* Command byte. */
+ if (lba48)
+ fis[2] = wbuf ? ATA_CMD_WRITE_EXT : ATA_CMD_READ_EXT;
+ else
+ fis[2] = wbuf ? ATA_CMD_WRITE : ATA_CMD_READ;
while (num_blocks) {
int now;
@@ -240,9 +246,14 @@ static int ahci_rw(struct ata_port *ata, void *rbuf, const void *wbuf,
fis[4] = (block >> 0) & 0xff;
fis[5] = (block >> 8) & 0xff;
fis[6] = (block >> 16) & 0xff;
- fis[7] = 1 << 6; /* device reg: set LBA mode */
- fis[8] = ((block >> 24) & 0xff);
- fis[3] = 0xe0; /* features */
+
+ if (lba48) {
+ fis[7] = 1 << 6; /* device reg: set LBA mode */
+ fis[8] = ((block >> 24) & 0xff);
+ fis[3] = 0xe0; /* features */
+ } else {
+ fis[7] = ((block >> 24) & 0xf) | 0xe0;
+ }
/* Block (sector) count */
fis[12] = (now >> 0) & 0xff;