Linux Audio

Check our new training course

Loading...
v4.6
 
  1/*
  2 *  sata_promise.h - Promise SATA common definitions and inline funcs
  3 *
  4 *  Copyright 2003-2004 Red Hat, Inc.
  5 *
  6 *
  7 *  This program is free software; you can redistribute it and/or modify
  8 *  it under the terms of the GNU General Public License as published by
  9 *  the Free Software Foundation; either version 2, or (at your option)
 10 *  any later version.
 11 *
 12 *  This program is distributed in the hope that it will be useful,
 13 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 14 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15 *  GNU General Public License for more details.
 16 *
 17 *  You should have received a copy of the GNU General Public License
 18 *  along with this program; see the file COPYING.  If not, write to
 19 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 20 *
 21 *
 22 *  libata documentation is available via 'make {ps|pdf}docs',
 23 *  as Documentation/DocBook/libata.*
 24 *
 25 */
 26
 27#ifndef __SATA_PROMISE_H__
 28#define __SATA_PROMISE_H__
 29
 30#include <linux/ata.h>
 31
 32enum pdc_packet_bits {
 33	PDC_PKT_READ		= (1 << 2),
 34	PDC_PKT_NODATA		= (1 << 3),
 35
 36	PDC_PKT_SIZEMASK	= (1 << 7) | (1 << 6) | (1 << 5),
 37	PDC_PKT_CLEAR_BSY	= (1 << 4),
 38	PDC_PKT_WAIT_DRDY	= (1 << 3) | (1 << 4),
 39	PDC_LAST_REG		= (1 << 3),
 40
 41	PDC_REG_DEVCTL		= (1 << 3) | (1 << 2) | (1 << 1),
 42};
 43
 44static inline unsigned int pdc_pkt_header(struct ata_taskfile *tf,
 45					  dma_addr_t sg_table,
 46					  unsigned int devno, u8 *buf)
 47{
 48	u8 dev_reg;
 49	__le32 *buf32 = (__le32 *) buf;
 50
 51	/* set control bits (byte 0), zero delay seq id (byte 3),
 52	 * and seq id (byte 2)
 53	 */
 54	switch (tf->protocol) {
 55	case ATA_PROT_DMA:
 56		if (!(tf->flags & ATA_TFLAG_WRITE))
 57			buf32[0] = cpu_to_le32(PDC_PKT_READ);
 58		else
 59			buf32[0] = 0;
 60		break;
 61
 62	case ATA_PROT_NODATA:
 63		buf32[0] = cpu_to_le32(PDC_PKT_NODATA);
 64		break;
 65
 66	default:
 67		BUG();
 68		break;
 69	}
 70
 71	buf32[1] = cpu_to_le32(sg_table);	/* S/G table addr */
 72	buf32[2] = 0;				/* no next-packet */
 73
 74	if (devno == 0)
 75		dev_reg = ATA_DEVICE_OBS;
 76	else
 77		dev_reg = ATA_DEVICE_OBS | ATA_DEV1;
 78
 79	/* select device */
 80	buf[12] = (1 << 5) | PDC_PKT_CLEAR_BSY | ATA_REG_DEVICE;
 81	buf[13] = dev_reg;
 82
 83	/* device control register */
 84	buf[14] = (1 << 5) | PDC_REG_DEVCTL;
 85	buf[15] = tf->ctl;
 86
 87	return 16; 	/* offset of next byte */
 88}
 89
 90static inline unsigned int pdc_pkt_footer(struct ata_taskfile *tf, u8 *buf,
 91				  unsigned int i)
 92{
 93	if (tf->flags & ATA_TFLAG_DEVICE) {
 94		buf[i++] = (1 << 5) | ATA_REG_DEVICE;
 95		buf[i++] = tf->device;
 96	}
 97
 98	/* and finally the command itself; also includes end-of-pkt marker */
 99	buf[i++] = (1 << 5) | PDC_LAST_REG | ATA_REG_CMD;
100	buf[i++] = tf->command;
101
102	return i;
103}
104
105static inline unsigned int pdc_prep_lba28(struct ata_taskfile *tf, u8 *buf, unsigned int i)
106{
107	/* the "(1 << 5)" should be read "(count << 5)" */
108
109	/* ATA command block registers */
110	buf[i++] = (1 << 5) | ATA_REG_FEATURE;
111	buf[i++] = tf->feature;
112
113	buf[i++] = (1 << 5) | ATA_REG_NSECT;
114	buf[i++] = tf->nsect;
115
116	buf[i++] = (1 << 5) | ATA_REG_LBAL;
117	buf[i++] = tf->lbal;
118
119	buf[i++] = (1 << 5) | ATA_REG_LBAM;
120	buf[i++] = tf->lbam;
121
122	buf[i++] = (1 << 5) | ATA_REG_LBAH;
123	buf[i++] = tf->lbah;
124
125	return i;
126}
127
128static inline unsigned int pdc_prep_lba48(struct ata_taskfile *tf, u8 *buf, unsigned int i)
129{
130	/* the "(2 << 5)" should be read "(count << 5)" */
131
132	/* ATA command block registers */
133	buf[i++] = (2 << 5) | ATA_REG_FEATURE;
134	buf[i++] = tf->hob_feature;
135	buf[i++] = tf->feature;
136
137	buf[i++] = (2 << 5) | ATA_REG_NSECT;
138	buf[i++] = tf->hob_nsect;
139	buf[i++] = tf->nsect;
140
141	buf[i++] = (2 << 5) | ATA_REG_LBAL;
142	buf[i++] = tf->hob_lbal;
143	buf[i++] = tf->lbal;
144
145	buf[i++] = (2 << 5) | ATA_REG_LBAM;
146	buf[i++] = tf->hob_lbam;
147	buf[i++] = tf->lbam;
148
149	buf[i++] = (2 << 5) | ATA_REG_LBAH;
150	buf[i++] = tf->hob_lbah;
151	buf[i++] = tf->lbah;
152
153	return i;
154}
155
156
157#endif /* __SATA_PROMISE_H__ */
v5.4
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/*
  3 *  sata_promise.h - Promise SATA common definitions and inline funcs
  4 *
  5 *  Copyright 2003-2004 Red Hat, Inc.
  6 *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  7 *  libata documentation is available via 'make {ps|pdf}docs',
  8 *  as Documentation/driver-api/libata.rst
 
  9 */
 10
 11#ifndef __SATA_PROMISE_H__
 12#define __SATA_PROMISE_H__
 13
 14#include <linux/ata.h>
 15
 16enum pdc_packet_bits {
 17	PDC_PKT_READ		= (1 << 2),
 18	PDC_PKT_NODATA		= (1 << 3),
 19
 20	PDC_PKT_SIZEMASK	= (1 << 7) | (1 << 6) | (1 << 5),
 21	PDC_PKT_CLEAR_BSY	= (1 << 4),
 22	PDC_PKT_WAIT_DRDY	= (1 << 3) | (1 << 4),
 23	PDC_LAST_REG		= (1 << 3),
 24
 25	PDC_REG_DEVCTL		= (1 << 3) | (1 << 2) | (1 << 1),
 26};
 27
 28static inline unsigned int pdc_pkt_header(struct ata_taskfile *tf,
 29					  dma_addr_t sg_table,
 30					  unsigned int devno, u8 *buf)
 31{
 32	u8 dev_reg;
 33	__le32 *buf32 = (__le32 *) buf;
 34
 35	/* set control bits (byte 0), zero delay seq id (byte 3),
 36	 * and seq id (byte 2)
 37	 */
 38	switch (tf->protocol) {
 39	case ATA_PROT_DMA:
 40		if (!(tf->flags & ATA_TFLAG_WRITE))
 41			buf32[0] = cpu_to_le32(PDC_PKT_READ);
 42		else
 43			buf32[0] = 0;
 44		break;
 45
 46	case ATA_PROT_NODATA:
 47		buf32[0] = cpu_to_le32(PDC_PKT_NODATA);
 48		break;
 49
 50	default:
 51		BUG();
 52		break;
 53	}
 54
 55	buf32[1] = cpu_to_le32(sg_table);	/* S/G table addr */
 56	buf32[2] = 0;				/* no next-packet */
 57
 58	if (devno == 0)
 59		dev_reg = ATA_DEVICE_OBS;
 60	else
 61		dev_reg = ATA_DEVICE_OBS | ATA_DEV1;
 62
 63	/* select device */
 64	buf[12] = (1 << 5) | PDC_PKT_CLEAR_BSY | ATA_REG_DEVICE;
 65	buf[13] = dev_reg;
 66
 67	/* device control register */
 68	buf[14] = (1 << 5) | PDC_REG_DEVCTL;
 69	buf[15] = tf->ctl;
 70
 71	return 16; 	/* offset of next byte */
 72}
 73
 74static inline unsigned int pdc_pkt_footer(struct ata_taskfile *tf, u8 *buf,
 75				  unsigned int i)
 76{
 77	if (tf->flags & ATA_TFLAG_DEVICE) {
 78		buf[i++] = (1 << 5) | ATA_REG_DEVICE;
 79		buf[i++] = tf->device;
 80	}
 81
 82	/* and finally the command itself; also includes end-of-pkt marker */
 83	buf[i++] = (1 << 5) | PDC_LAST_REG | ATA_REG_CMD;
 84	buf[i++] = tf->command;
 85
 86	return i;
 87}
 88
 89static inline unsigned int pdc_prep_lba28(struct ata_taskfile *tf, u8 *buf, unsigned int i)
 90{
 91	/* the "(1 << 5)" should be read "(count << 5)" */
 92
 93	/* ATA command block registers */
 94	buf[i++] = (1 << 5) | ATA_REG_FEATURE;
 95	buf[i++] = tf->feature;
 96
 97	buf[i++] = (1 << 5) | ATA_REG_NSECT;
 98	buf[i++] = tf->nsect;
 99
100	buf[i++] = (1 << 5) | ATA_REG_LBAL;
101	buf[i++] = tf->lbal;
102
103	buf[i++] = (1 << 5) | ATA_REG_LBAM;
104	buf[i++] = tf->lbam;
105
106	buf[i++] = (1 << 5) | ATA_REG_LBAH;
107	buf[i++] = tf->lbah;
108
109	return i;
110}
111
112static inline unsigned int pdc_prep_lba48(struct ata_taskfile *tf, u8 *buf, unsigned int i)
113{
114	/* the "(2 << 5)" should be read "(count << 5)" */
115
116	/* ATA command block registers */
117	buf[i++] = (2 << 5) | ATA_REG_FEATURE;
118	buf[i++] = tf->hob_feature;
119	buf[i++] = tf->feature;
120
121	buf[i++] = (2 << 5) | ATA_REG_NSECT;
122	buf[i++] = tf->hob_nsect;
123	buf[i++] = tf->nsect;
124
125	buf[i++] = (2 << 5) | ATA_REG_LBAL;
126	buf[i++] = tf->hob_lbal;
127	buf[i++] = tf->lbal;
128
129	buf[i++] = (2 << 5) | ATA_REG_LBAM;
130	buf[i++] = tf->hob_lbam;
131	buf[i++] = tf->lbam;
132
133	buf[i++] = (2 << 5) | ATA_REG_LBAH;
134	buf[i++] = tf->hob_lbah;
135	buf[i++] = tf->lbah;
136
137	return i;
138}
139
140
141#endif /* __SATA_PROMISE_H__ */