mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
c82ee6d3be
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program see the file copying if not write to the free software foundation 675 mass ave cambridge ma 02139 usa extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 52 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Jilayne Lovejoy <opensource@jilayne.com> Reviewed-by: Steve Winslow <swinslow@gmail.com> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190519154042.342335923@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
142 lines
3.1 KiB
C
142 lines
3.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* sata_promise.h - Promise SATA common definitions and inline funcs
|
|
*
|
|
* Copyright 2003-2004 Red Hat, Inc.
|
|
*
|
|
* libata documentation is available via 'make {ps|pdf}docs',
|
|
* as Documentation/driver-api/libata.rst
|
|
*/
|
|
|
|
#ifndef __SATA_PROMISE_H__
|
|
#define __SATA_PROMISE_H__
|
|
|
|
#include <linux/ata.h>
|
|
|
|
enum pdc_packet_bits {
|
|
PDC_PKT_READ = (1 << 2),
|
|
PDC_PKT_NODATA = (1 << 3),
|
|
|
|
PDC_PKT_SIZEMASK = (1 << 7) | (1 << 6) | (1 << 5),
|
|
PDC_PKT_CLEAR_BSY = (1 << 4),
|
|
PDC_PKT_WAIT_DRDY = (1 << 3) | (1 << 4),
|
|
PDC_LAST_REG = (1 << 3),
|
|
|
|
PDC_REG_DEVCTL = (1 << 3) | (1 << 2) | (1 << 1),
|
|
};
|
|
|
|
static inline unsigned int pdc_pkt_header(struct ata_taskfile *tf,
|
|
dma_addr_t sg_table,
|
|
unsigned int devno, u8 *buf)
|
|
{
|
|
u8 dev_reg;
|
|
__le32 *buf32 = (__le32 *) buf;
|
|
|
|
/* set control bits (byte 0), zero delay seq id (byte 3),
|
|
* and seq id (byte 2)
|
|
*/
|
|
switch (tf->protocol) {
|
|
case ATA_PROT_DMA:
|
|
if (!(tf->flags & ATA_TFLAG_WRITE))
|
|
buf32[0] = cpu_to_le32(PDC_PKT_READ);
|
|
else
|
|
buf32[0] = 0;
|
|
break;
|
|
|
|
case ATA_PROT_NODATA:
|
|
buf32[0] = cpu_to_le32(PDC_PKT_NODATA);
|
|
break;
|
|
|
|
default:
|
|
BUG();
|
|
break;
|
|
}
|
|
|
|
buf32[1] = cpu_to_le32(sg_table); /* S/G table addr */
|
|
buf32[2] = 0; /* no next-packet */
|
|
|
|
if (devno == 0)
|
|
dev_reg = ATA_DEVICE_OBS;
|
|
else
|
|
dev_reg = ATA_DEVICE_OBS | ATA_DEV1;
|
|
|
|
/* select device */
|
|
buf[12] = (1 << 5) | PDC_PKT_CLEAR_BSY | ATA_REG_DEVICE;
|
|
buf[13] = dev_reg;
|
|
|
|
/* device control register */
|
|
buf[14] = (1 << 5) | PDC_REG_DEVCTL;
|
|
buf[15] = tf->ctl;
|
|
|
|
return 16; /* offset of next byte */
|
|
}
|
|
|
|
static inline unsigned int pdc_pkt_footer(struct ata_taskfile *tf, u8 *buf,
|
|
unsigned int i)
|
|
{
|
|
if (tf->flags & ATA_TFLAG_DEVICE) {
|
|
buf[i++] = (1 << 5) | ATA_REG_DEVICE;
|
|
buf[i++] = tf->device;
|
|
}
|
|
|
|
/* and finally the command itself; also includes end-of-pkt marker */
|
|
buf[i++] = (1 << 5) | PDC_LAST_REG | ATA_REG_CMD;
|
|
buf[i++] = tf->command;
|
|
|
|
return i;
|
|
}
|
|
|
|
static inline unsigned int pdc_prep_lba28(struct ata_taskfile *tf, u8 *buf, unsigned int i)
|
|
{
|
|
/* the "(1 << 5)" should be read "(count << 5)" */
|
|
|
|
/* ATA command block registers */
|
|
buf[i++] = (1 << 5) | ATA_REG_FEATURE;
|
|
buf[i++] = tf->feature;
|
|
|
|
buf[i++] = (1 << 5) | ATA_REG_NSECT;
|
|
buf[i++] = tf->nsect;
|
|
|
|
buf[i++] = (1 << 5) | ATA_REG_LBAL;
|
|
buf[i++] = tf->lbal;
|
|
|
|
buf[i++] = (1 << 5) | ATA_REG_LBAM;
|
|
buf[i++] = tf->lbam;
|
|
|
|
buf[i++] = (1 << 5) | ATA_REG_LBAH;
|
|
buf[i++] = tf->lbah;
|
|
|
|
return i;
|
|
}
|
|
|
|
static inline unsigned int pdc_prep_lba48(struct ata_taskfile *tf, u8 *buf, unsigned int i)
|
|
{
|
|
/* the "(2 << 5)" should be read "(count << 5)" */
|
|
|
|
/* ATA command block registers */
|
|
buf[i++] = (2 << 5) | ATA_REG_FEATURE;
|
|
buf[i++] = tf->hob_feature;
|
|
buf[i++] = tf->feature;
|
|
|
|
buf[i++] = (2 << 5) | ATA_REG_NSECT;
|
|
buf[i++] = tf->hob_nsect;
|
|
buf[i++] = tf->nsect;
|
|
|
|
buf[i++] = (2 << 5) | ATA_REG_LBAL;
|
|
buf[i++] = tf->hob_lbal;
|
|
buf[i++] = tf->lbal;
|
|
|
|
buf[i++] = (2 << 5) | ATA_REG_LBAM;
|
|
buf[i++] = tf->hob_lbam;
|
|
buf[i++] = tf->lbam;
|
|
|
|
buf[i++] = (2 << 5) | ATA_REG_LBAH;
|
|
buf[i++] = tf->hob_lbah;
|
|
buf[i++] = tf->lbah;
|
|
|
|
return i;
|
|
}
|
|
|
|
|
|
#endif /* __SATA_PROMISE_H__ */
|