linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH libata-dev-2.6 1/3] Add CHS support
@ 2005-02-06  6:02 Albert Lee
  2005-02-06  6:26 ` Jeff Garzik
  2005-02-18 23:40 ` Jeff Garzik
  0 siblings, 2 replies; 28+ messages in thread
From: Albert Lee @ 2005-02-06  6:02 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Bartlomiej Zolnierkiewicz, Doug Maxey, IDE Linux

[-- Attachment #1: Type: text/plain, Size: 2897 bytes --]

Hi Jeff,

  These are the patches for libata CHS support. Tested OK with my old 1994 ST-5850A hardddisk.

Changes:
1. Add the flags, utility function and CHS fields to the <linux/ata.h> and <linux/libata.h> headers.

2. ata_dev_identify() pathed to report and initialize CHS fields in ata_device.
    ata_qc_new_init() patched to initialize the ATA_TFLAG_LBA to the ata_taskfile.

3. ata_scsi_verify_xlat(), ata_scsi_rw_xlat() patched to support CHS translation.
    ata_scsiop_read_cap() patched to report capacity for CHS-only drives.

  Attached please find the patch 1/3 against the libata-dev-2.6 tree for your review. Thanks.

Albert

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
----------------------------------------------------------------------------------------------
diff -Nru libata-dev-2.6/include/linux/ata.h libata-dev-2.6-mod/include/linux/ata.h
--- libata-dev-2.6/include/linux/ata.h 2005-02-05 10:42:06.000000000 +0800
+++ libata-dev-2.6-mod/include/linux/ata.h 2005-02-05 11:04:33.000000000 +0800
@@ -172,6 +172,7 @@
  ATA_TFLAG_ISADDR = (1 << 1), /* enable r/w to nsect/lba regs */
  ATA_TFLAG_DEVICE = (1 << 2), /* enable r/w to device reg */
  ATA_TFLAG_WRITE  = (1 << 3), /* data dir: host->dev==1 (write) */
+ ATA_TFLAG_LBA  = (1 << 4), /* enable LBA */
 };
 
 enum ata_tf_protocols {
@@ -241,6 +242,18 @@
    ((u64) (id)[(n) + 1] << 16) | \
    ((u64) (id)[(n) + 0]) )
 
+static inline int ata_id_current_chs_valid(u16 *id)
+{
+ /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command 
+    has not been issued to the device then the values of 
+    id[54] to id[56] are vendor specific. */
+ return (id[53] & 0x01) && /* Current translation valid */
+  id[54] &&  /* cylinders in current translation */
+  id[55] &&  /* heads in current translation */
+  id[55] <= 16 &&
+  id[56];    /* sectors in current translation */
+}
+
 static inline int atapi_cdb_len(u16 *dev_id)
 {
  u16 tmp = dev_id[0] & 0x3;
diff -Nru libata-dev-2.6/include/linux/libata.h libata-dev-2.6-mod/include/linux/libata.h
--- libata-dev-2.6/include/linux/libata.h 2005-02-05 10:42:07.000000000 +0800
+++ libata-dev-2.6-mod/include/linux/libata.h 2005-02-05 11:05:58.000000000 +0800
@@ -95,6 +95,7 @@
  ATA_DFLAG_LBA48  = (1 << 0), /* device supports LBA48 */
  ATA_DFLAG_PIO  = (1 << 1), /* device currently in PIO mode */
  ATA_DFLAG_LOCK_SECTORS = (1 << 2), /* don't adjust max_sectors */
+ ATA_DFLAG_LBA  = (1 << 3), /* device supports LBA */
 
  ATA_DEV_UNKNOWN  = 0, /* unknown device */
  ATA_DEV_ATA  = 1, /* ATA device */
@@ -279,6 +280,11 @@
  u8   xfer_protocol; /* taskfile xfer protocol */
  u8   read_cmd; /* opcode to use on read */
  u8   write_cmd; /* opcode to use on write */
+
+ /* for CHS addressing */
+ u16   cylinders; /* Number of cylinders */
+ u16   heads;  /* Number of heads */
+ u16   sectors; /* Number of sectors per track */
 };
 
 struct ata_port {

[-- Attachment #2: chs1.diff --]
[-- Type: application/octet-stream, Size: 2166 bytes --]

diff -Nru libata-dev-2.6/include/linux/ata.h libata-dev-2.6-mod/include/linux/ata.h
--- libata-dev-2.6/include/linux/ata.h	2005-02-05 10:42:06.000000000 +0800
+++ libata-dev-2.6-mod/include/linux/ata.h	2005-02-05 11:04:33.000000000 +0800
@@ -172,6 +172,7 @@
 	ATA_TFLAG_ISADDR	= (1 << 1), /* enable r/w to nsect/lba regs */
 	ATA_TFLAG_DEVICE	= (1 << 2), /* enable r/w to device reg */
 	ATA_TFLAG_WRITE		= (1 << 3), /* data dir: host->dev==1 (write) */
+	ATA_TFLAG_LBA		= (1 << 4), /* enable LBA */
 };
 
 enum ata_tf_protocols {
@@ -241,6 +242,18 @@
 	  ((u64) (id)[(n) + 1] << 16) |	\
 	  ((u64) (id)[(n) + 0]) )
 
+static inline int ata_id_current_chs_valid(u16 *id)
+{
+	/* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command 
+	   has not been issued to the device then the values of 
+	   id[54] to id[56] are vendor specific. */
+	return (id[53] & 0x01) && /* Current translation valid */
+		id[54] &&  /* cylinders in current translation */
+		id[55] &&  /* heads in current translation */
+		id[55] <= 16 &&
+		id[56];    /* sectors in current translation */
+}
+
 static inline int atapi_cdb_len(u16 *dev_id)
 {
 	u16 tmp = dev_id[0] & 0x3;
diff -Nru libata-dev-2.6/include/linux/libata.h libata-dev-2.6-mod/include/linux/libata.h
--- libata-dev-2.6/include/linux/libata.h	2005-02-05 10:42:07.000000000 +0800
+++ libata-dev-2.6-mod/include/linux/libata.h	2005-02-05 11:05:58.000000000 +0800
@@ -95,6 +95,7 @@
 	ATA_DFLAG_LBA48		= (1 << 0), /* device supports LBA48 */
 	ATA_DFLAG_PIO		= (1 << 1), /* device currently in PIO mode */
 	ATA_DFLAG_LOCK_SECTORS	= (1 << 2), /* don't adjust max_sectors */
+	ATA_DFLAG_LBA		= (1 << 3), /* device supports LBA */
 
 	ATA_DEV_UNKNOWN		= 0,	/* unknown device */
 	ATA_DEV_ATA		= 1,	/* ATA device */
@@ -279,6 +280,11 @@
 	u8			xfer_protocol;	/* taskfile xfer protocol */
 	u8			read_cmd;	/* opcode to use on read */
 	u8			write_cmd;	/* opcode to use on write */
+
+	/* for CHS addressing */
+	u16			cylinders;	/* Number of cylinders */
+	u16			heads;		/* Number of heads */
+	u16			sectors;	/* Number of sectors per track */
 };
 
 struct ata_port {

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2005-02-25  5:40 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-06  6:02 [PATCH libata-dev-2.6 1/3] Add CHS support Albert Lee
2005-02-06  6:26 ` Jeff Garzik
2005-02-06 14:41   ` Mark Lord
2005-02-06 15:00     ` Jeff Garzik
2005-02-06 22:02       ` Mark Lord
2005-02-14 11:09   ` Albert Lee
2005-02-14 11:17     ` Albert Lee
2005-02-14 11:23       ` Albert Lee
2005-02-18 23:40 ` Jeff Garzik
2005-02-22  3:35   ` Albert Lee
2005-02-23 11:25   ` [PATCH libata-dev-2.6] Issue INITIALIZE DEVICE PARAMETERS for CHS only devices Albert Lee
2005-02-23 14:48     ` Mark Lord
2005-02-24  2:36       ` Albert Lee
2005-02-24  2:53         ` Jeff Garzik
2005-02-24  5:29           ` Albert Lee
2005-02-24  5:35             ` Jeff Garzik
2005-02-24  6:41               ` Albert Lee
2005-02-24  6:48                 ` Jeff Garzik
2005-02-24  7:01                   ` Albert Lee
2005-02-24  7:48                     ` Jeff Garzik
2005-02-25  5:01                       ` Albert Lee
2005-02-25  5:22                         ` Albert Lee
2005-02-25  5:40                         ` Jeff Garzik
2005-02-24  3:10         ` Mark Lord
2005-02-24  3:15           ` Jeff Garzik
2005-02-24  3:35             ` Mark Lord
2005-02-23 16:50     ` Bartlomiej Zolnierkiewicz
2005-02-24  3:05       ` Albert Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).