Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  sata_promise.h - Promise SATA common definitions and inline funcs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright 2003-2004 Red Hat, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *  libata documentation is available via 'make {ps|pdf}docs',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *  as Documentation/driver-api/libata.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #ifndef __SATA_PROMISE_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #define __SATA_PROMISE_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/ata.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) enum pdc_packet_bits {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	PDC_PKT_READ		= (1 << 2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	PDC_PKT_NODATA		= (1 << 3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	PDC_PKT_SIZEMASK	= (1 << 7) | (1 << 6) | (1 << 5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	PDC_PKT_CLEAR_BSY	= (1 << 4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	PDC_PKT_WAIT_DRDY	= (1 << 3) | (1 << 4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	PDC_LAST_REG		= (1 << 3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	PDC_REG_DEVCTL		= (1 << 3) | (1 << 2) | (1 << 1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) static inline unsigned int pdc_pkt_header(struct ata_taskfile *tf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 					  dma_addr_t sg_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 					  unsigned int devno, u8 *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	u8 dev_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	__le32 *buf32 = (__le32 *) buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	/* set control bits (byte 0), zero delay seq id (byte 3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	 * and seq id (byte 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	switch (tf->protocol) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	case ATA_PROT_DMA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		if (!(tf->flags & ATA_TFLAG_WRITE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 			buf32[0] = cpu_to_le32(PDC_PKT_READ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 			buf32[0] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	case ATA_PROT_NODATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		buf32[0] = cpu_to_le32(PDC_PKT_NODATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	buf32[1] = cpu_to_le32(sg_table);	/* S/G table addr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	buf32[2] = 0;				/* no next-packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	if (devno == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		dev_reg = ATA_DEVICE_OBS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		dev_reg = ATA_DEVICE_OBS | ATA_DEV1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	/* select device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	buf[12] = (1 << 5) | PDC_PKT_CLEAR_BSY | ATA_REG_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	buf[13] = dev_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	/* device control register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	buf[14] = (1 << 5) | PDC_REG_DEVCTL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	buf[15] = tf->ctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	return 16; 	/* offset of next byte */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) static inline unsigned int pdc_pkt_footer(struct ata_taskfile *tf, u8 *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 				  unsigned int i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	if (tf->flags & ATA_TFLAG_DEVICE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		buf[i++] = (1 << 5) | ATA_REG_DEVICE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		buf[i++] = tf->device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	/* and finally the command itself; also includes end-of-pkt marker */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	buf[i++] = (1 << 5) | PDC_LAST_REG | ATA_REG_CMD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	buf[i++] = tf->command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) static inline unsigned int pdc_prep_lba28(struct ata_taskfile *tf, u8 *buf, unsigned int i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	/* the "(1 << 5)" should be read "(count << 5)" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	/* ATA command block registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	buf[i++] = (1 << 5) | ATA_REG_FEATURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	buf[i++] = tf->feature;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	buf[i++] = (1 << 5) | ATA_REG_NSECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	buf[i++] = tf->nsect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	buf[i++] = (1 << 5) | ATA_REG_LBAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	buf[i++] = tf->lbal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	buf[i++] = (1 << 5) | ATA_REG_LBAM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	buf[i++] = tf->lbam;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	buf[i++] = (1 << 5) | ATA_REG_LBAH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	buf[i++] = tf->lbah;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static inline unsigned int pdc_prep_lba48(struct ata_taskfile *tf, u8 *buf, unsigned int i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	/* the "(2 << 5)" should be read "(count << 5)" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	/* ATA command block registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	buf[i++] = (2 << 5) | ATA_REG_FEATURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	buf[i++] = tf->hob_feature;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	buf[i++] = tf->feature;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	buf[i++] = (2 << 5) | ATA_REG_NSECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	buf[i++] = tf->hob_nsect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	buf[i++] = tf->nsect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	buf[i++] = (2 << 5) | ATA_REG_LBAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	buf[i++] = tf->hob_lbal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	buf[i++] = tf->lbal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	buf[i++] = (2 << 5) | ATA_REG_LBAM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	buf[i++] = tf->hob_lbam;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	buf[i++] = tf->lbam;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	buf[i++] = (2 << 5) | ATA_REG_LBAH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	buf[i++] = tf->hob_lbah;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	buf[i++] = tf->lbah;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #endif /* __SATA_PROMISE_H__ */