public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH v1 2/5] ATA: Add the libata support
@ 2008-03-16  8:33 Dave Liu
  2008-03-17 21:55 ` Tor Krill
  2008-03-19  9:35 ` Tor Krill
  0 siblings, 2 replies; 8+ messages in thread
From: Dave Liu @ 2008-03-16  8:33 UTC (permalink / raw)
  To: u-boot

add simple libata support in u-boot

Signed-off-by: Dave Liu <daveliu@freescale.com>
---
 drivers/block/Makefile |    1 +
 drivers/block/libata.c |  158 ++++++++++++++++++++++++++++++++++++++
 include/libata.h       |  197 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 356 insertions(+), 0 deletions(-)
 create mode 100644 drivers/block/libata.c
 create mode 100644 include/libata.h

diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index e069969..d63ca2d 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -27,6 +27,7 @@ LIB 	:= $(obj)libblock.a
 
 COBJS-y += ahci.o
 COBJS-y += ata_piix.o
+COBJS-$(CONFIG_LIBATA) += libata.o
 COBJS-y += sil680.o
 COBJS-y += sym53c8xx.o
 COBJS-y += systemace.o
diff --git a/drivers/block/libata.c b/drivers/block/libata.c
new file mode 100644
index 0000000..aed5be3
--- /dev/null
+++ b/drivers/block/libata.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2008 Freescale Semiconductor, Inc.
+ *		Dave Liu <daveliu@freescale.com>
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * with the reference to libata of kernel
+ */
+
+#include <libata.h>
+
+u64 ata_id_n_sectors(u16 *id)
+{
+	if (ata_id_has_lba(id)) {
+		if (ata_id_has_lba48(id))
+			return ata_id_u64(id, ATA_ID_LBA48_SECTORS);
+		else
+			return ata_id_u32(id, ATA_ID_LBA_SECTORS);
+	} else {
+		return 0;
+	}
+}
+
+u32 ata_dev_classify(u32 sig)
+{
+	u8 lbam, lbah;
+
+	lbam = (sig >> 16) & 0xff;
+	lbah = (sig >> 24) & 0xff;
+
+	if (((lbam == 0) && (lbah == 0)) ||
+		((lbam == 0x3c) && (lbah == 0xc3)))
+		return ATA_DEV_ATA;
+
+	if ((lbam == 0x14) && (lbah == 0xeb))
+		return ATA_DEV_ATAPI;
+
+	if ((lbam == 0x69) && (lbah == 0x96))
+		return ATA_DEV_PMP;
+
+	return ATA_DEV_UNKNOWN;
+}
+
+static void ata_id_string(const u16 *id, unsigned char *s,
+			 unsigned int ofs, unsigned int len)
+{
+	unsigned int c;
+
+	while (len > 0) {
+		c = id[ofs] >> 8;
+		*s = c;
+		s++;
+
+		c = id[ofs] & 0xff;
+		*s = c;
+		s++;
+
+		ofs++;
+		len -= 2;
+	}
+}
+
+void ata_id_c_string(const u16 *id, unsigned char *s,
+			 unsigned int ofs, unsigned int len)
+{
+	unsigned char *p;
+
+	ata_id_string(id, s, ofs, len - 1);
+
+	p = s + strnlen((char *)s, len - 1);
+	while (p > s && p[-1] == ' ')
+		p--;
+	*p = '\0';
+}
+
+void ata_dump_id(u16 *id)
+{
+	unsigned char serial[ATA_ID_SERNO_LEN + 1];
+	unsigned char firmware[ATA_ID_FW_REV_LEN + 1];
+	unsigned char product[ATA_ID_PROD_LEN + 1];
+	u64 n_sectors;
+
+	/* Serial number */
+	ata_id_c_string(id, serial, ATA_ID_SERNO, sizeof(serial));
+	printf("S/N: %s\n\r", serial);
+
+	/* Firmware version */
+	ata_id_c_string(id, firmware, ATA_ID_FW_REV, sizeof(firmware));
+	printf("Firmware version: %s\n\r", firmware);
+
+	/* Product model */
+	ata_id_c_string(id, product, ATA_ID_PROD, sizeof(product));
+	printf("Product model number: %s\n\r", product);
+
+	/* Total sectors of device  */
+	n_sectors = ata_id_n_sectors(id);
+	printf("Capablity: %d sectors\n\r", n_sectors);
+
+	printf("id[49]: capabilities ==0x%04x\n"
+		"id[53]: field valid ==0x%04x\n"
+		"id[63]: mwdma ==0x%04x\n"
+		"id[64]: pio ==0x%04x\n"
+		"id[75]: queue depth ==0x%04x\n",
+		id[49],
+		id[53],
+		id[63],
+		id[64],
+		id[75]);
+
+	printf("id[76]: sata capablity ==0x%04x\n"
+		"id[78]: sata features supported ==0x%04x\n"
+		"id[79]: sata features enable ==0x%04x\n",
+		id[76],
+		id[78],
+		id[79]);
+
+	printf("id[80]: major version ==0x%04x\n"
+		"id[81]: minor version ==0x%04x\n"
+		"id[82]: command set supported 1 ==0x%04x\n"
+		"id[83]: command set supported 2 ==0x%04x\n"
+		"id[84]: command set extension ==0x%04x\n",
+		id[80],
+		id[81],
+		id[82],
+		id[83],
+		id[84]);
+	printf("id[85]: command set enable 1 ==0x%04x\n"
+		"id[86]: command set enable 2 ==0x%04x\n"
+		"id[87]: command set default ==0x%04x\n"
+		"id[88]: udma ==0x%04x\n"
+		"id[93]: hardware reset result ==0x%04x\n",
+		id[85],
+		id[86],
+		id[87],
+		id[88],
+		id[93]);
+}
+
+void ata_swap_buf_le16(u16 *buf, unsigned int buf_words)
+{
+	unsigned int i;
+
+	for (i = 0; i < buf_words; i++)
+		buf[i] = le16_to_cpu(buf[i]);
+}
diff --git a/include/libata.h b/include/libata.h
new file mode 100644
index 0000000..552a495
--- /dev/null
+++ b/include/libata.h
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2008 Freescale Semiconductor, Inc.
+ *		Dave Liu <daveliu@freescale.com>
+ *		port from libata of linux kernel
+ *
+ * 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 of
+ * the License, 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+#ifndef __LIBATA_H__
+#define __LIBATA_H__
+
+/* command
+ */
+enum ata_cmd {
+	/* non-NCQ command */
+	ATA_CMD_DEV_RESET		= 0x08, /* ATAPI device reset */
+	ATA_CMD_FLUSH_CACHE		= 0xE7,
+	ATA_CMD_FLUSH_CACHE_EXT		= 0xEA,
+	ATA_CMD_ID_ATA			= 0xEC,
+	ATA_CMD_ID_ATAPI		= 0xA1,
+	ATA_CMD_READ_DMA		= 0xC8,
+	ATA_CMD_READ_DMA_EXT		= 0x25,
+	ATA_CMD_WRITE_DMA		= 0xCA,
+	ATA_CMD_WRITE_DMA_EXT		= 0x35,
+	ATA_CMD_PIO_READ		= 0x20,
+	ATA_CMD_PIO_READ_EXT		= 0x24,
+	ATA_CMD_PIO_WRITE		= 0x30,
+	ATA_CMD_PIO_WRITE_EXT		= 0x34,
+	ATA_CMD_SET_FEATURES		= 0xEF,
+
+	/* NCQ command */
+	ATA_CMD_READ_FPDMA_QUEUED	= 0x60,
+	ATA_CMD_WRITE_FPDMA_QUEUED	= 0x61,
+};
+
+/* SETFEATURES stuff
+ */
+enum ata_set_features {
+	/* SETFEATURES stuff */
+	SETFEATURES_XFER	= 0x03,
+	XFER_UDMA_7		= 0x47,
+	XFER_UDMA_6		= 0x46,
+	XFER_UDMA_5		= 0x45,
+	XFER_UDMA_4		= 0x44,
+	XFER_UDMA_3		= 0x43,
+	XFER_UDMA_2		= 0x42,
+	XFER_UDMA_1		= 0x41,
+	XFER_UDMA_0		= 0x40,
+	XFER_MW_DMA_4		= 0x24, /* CFA only */
+	XFER_MW_DMA_3		= 0x23, /* CFA only */
+	XFER_MW_DMA_2		= 0x22,
+	XFER_MW_DMA_1		= 0x21,
+	XFER_MW_DMA_0		= 0x20,
+	XFER_PIO_6		= 0x0E, /* CFA only */
+	XFER_PIO_5		= 0x0D, /* CFA only */
+	XFER_PIO_4		= 0x0C,
+	XFER_PIO_3		= 0x0B,
+	XFER_PIO_2		= 0x0A,
+	XFER_PIO_1		= 0x09,
+	XFER_PIO_0		= 0x08,
+	XFER_PIO_SLOW		= 0x00,
+
+	SETFEATURES_WC_ON	= 0x02, /* Enable write cache */
+	SETFEATURES_WC_OFF	= 0x82, /* Disable write cache */
+
+	SETFEATURES_SPINUP	= 0x07, /* Spin-up drive */
+};
+
+enum ata_protocol {
+	ATA_PROT_UNKNOWN,	/* unknown */
+	ATA_PROT_NODATA,	/* no data */
+	ATA_PROT_PIO,		/* PIO data xfer */
+	ATA_PROT_DMA,		/* DMA */
+	ATA_PROT_NCQ,		/* NCQ */
+	ATA_PROT_ATAPI,		/* packet command, PIO data xfer */
+	ATA_PROT_ATAPI_NODATA,	/* packet command, no data */
+	ATA_PROT_ATAPI_DMA,	/* packet command, DMA */
+};
+
+enum ata_dev_typed {
+	ATA_DEV_ATA,		/* ATA device */
+	ATA_DEV_ATAPI,		/* ATAPI device */
+	ATA_DEV_PMP,		/* Port Multiplier Port */
+	ATA_DEV_UNKNOWN,	/* unknown */
+};
+
+enum {
+	ATA_SECT_SIZE		= 512,
+	ATA_MAX_SECTORS_128	= 128,
+	ATA_MAX_SECTORS		= 256,
+	ATA_MAX_SECTORS_LBA48	= 65535,
+
+	/* bits in ATA command block registers */
+	ATA_HOB			= (1 << 7),	/* LBA48 selector */
+	ATA_NIEN		= (1 << 1),	/* disable-irq flag */
+	ATA_LBA			= (1 << 6),	/* LBA28 selector */
+	ATA_DEV1		= (1 << 4),	/* Select Device 1 (slave) */
+	ATA_BUSY		= (1 << 7),	/* BSY status bit */
+	ATA_DRDY		= (1 << 6),	/* device ready */
+	ATA_DF			= (1 << 5),	/* device fault */
+	ATA_DRQ			= (1 << 3),	/* data request i/o */
+	ATA_ERR			= (1 << 0),	/* have an error */
+	ATA_SRST		= (1 << 2),	/* software reset */
+	ATA_ICRC		= (1 << 7),	/* interface CRC error */
+	ATA_UNC			= (1 << 6),	/* uncorrectable media error */
+	ATA_IDNF		= (1 << 4),	/* ID not found */
+	ATA_ABORTED		= (1 << 2),	/* command aborted */
+
+	ATA_ID_WORDS		= 256,
+	ATA_ID_SERNO		= 10,
+	ATA_ID_FW_REV		= 23,
+	ATA_ID_PROD		= 27,
+	ATA_ID_FIELD_VALID	= 53,
+	ATA_ID_LBA_SECTORS	= 60,
+	ATA_ID_MWDMA_MODES	= 63,
+	ATA_ID_PIO_MODES	= 64,
+	ATA_ID_QUEUE_DEPTH	= 75,
+	ATA_ID_SATA_CAP		= 76,
+	ATA_ID_SATA_FEATURES	= 78,
+	ATA_ID_SATA_FEATURES_EN	= 79,
+	ATA_ID_MAJOR_VER	= 80,
+	ATA_ID_MINOR_VER	= 81,
+	ATA_ID_UDMA_MODES	= 88,
+	ATA_ID_LBA48_SECTORS	= 100,
+
+	ATA_ID_SERNO_LEN	= 20,
+	ATA_ID_FW_REV_LEN	= 8,
+	ATA_ID_PROD_LEN		= 40,
+
+	ATA_PIO3		= (1 << 0),
+	ATA_PIO4		= ATA_PIO3 | (1 << 1),
+
+	ATA_UDMA0		= (1 << 0),
+	ATA_UDMA1		= ATA_UDMA0 | (1 << 1),
+	ATA_UDMA2		= ATA_UDMA1 | (1 << 2),
+	ATA_UDMA3		= ATA_UDMA2 | (1 << 3),
+	ATA_UDMA4		= ATA_UDMA3 | (1 << 4),
+	ATA_UDMA5		= ATA_UDMA4 | (1 << 5),
+	ATA_UDMA6		= ATA_UDMA5 | (1 << 6),
+	ATA_UDMA7		= ATA_UDMA6 | (1 << 7),
+};
+
+#define ata_id_is_ata(id)		(((id)[0] & (1 << 15)) == 0)
+#define ata_id_wcache_enabled(id)	((id)[85] & (1 << 5))
+#define ata_id_has_fua(id)		((id)[84] & (1 << 6))
+#define ata_id_has_flush(id)		((id)[83] & (1 << 12))
+#define ata_id_has_flush_ext(id)	((id)[83] & (1 << 13))
+#define ata_id_has_lba48(id)		((id)[83] & (1 << 10))
+#define ata_id_has_wcache(id)		((id)[82] & (1 << 5))
+#define ata_id_has_lba(id)		((id)[49] & (1 << 9))
+#define ata_id_has_dma(id)		((id)[49] & (1 << 8))
+#define ata_id_has_ncq(id)		((id)[76] & (1 << 8))
+#define ata_id_queue_depth(id)		(((id)[75] & 0x1f) + 1)
+
+#define ata_id_u32(id,n)        \
+        (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)]))
+#define ata_id_u64(id,n)        \
+        ( ((u64) (id)[(n) + 3] << 48) | \
+          ((u64) (id)[(n) + 2] << 32) | \
+          ((u64) (id)[(n) + 1] << 16) | \
+          ((u64) (id)[(n) + 0]) )
+
+static inline unsigned int ata_id_major_version(const u16 *id)
+{
+	unsigned int mver;
+
+	if (id[ATA_ID_MAJOR_VER] == 0xFFFF)
+		return 0;
+
+	for (mver = 14; mver >= 1; mver--)
+		if (id[ATA_ID_MAJOR_VER] & (1 << mver))
+			break;
+	return mver;
+}
+
+static inline int ata_id_is_sata(const u16 *id)
+{
+	return ata_id_major_version(id) >= 5 && id[93] == 0;
+}
+
+int sata_init(void);
+
+#endif /* __LIBATA_H__ */
-- 
1.5.4.rc4

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

* [U-Boot-Users] [PATCH v1 2/5] ATA: Add the libata support
  2008-03-16  8:33 [U-Boot-Users] [PATCH v1 2/5] ATA: Add the libata support Dave Liu
@ 2008-03-17 21:55 ` Tor Krill
  2008-03-19  9:35 ` Tor Krill
  1 sibling, 0 replies; 8+ messages in thread
From: Tor Krill @ 2008-03-17 21:55 UTC (permalink / raw)
  To: u-boot




On 3/16/2008, "Dave Liu" <r63238@freescale.com> wrote:

>add simple libata support in u-boot

I get a compilation error on libata.c:

---8<----------------------
u-boot/include/libata.h:177: warning: type defaults to 'int' in
declaration of 'u16'
-----8<--------------------

Seems to be a missing include of "common.h". Adding it to libata.c (or
libata.h) fixes the issue.

/Tor

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

* [U-Boot-Users] [PATCH v1 2/5] ATA: Add the libata support
  2008-03-19  9:35 ` Tor Krill
@ 2008-03-19  9:08   ` Dave Liu
  2008-03-19 12:14     ` Wolfgang Denk
  2008-03-19 12:06   ` Wolfgang Denk
  1 sibling, 1 reply; 8+ messages in thread
From: Dave Liu @ 2008-03-19  9:08 UTC (permalink / raw)
  To: u-boot

On Wed, 2008-03-19 at 09:35 +0000, Tor Krill wrote:

> After some further work with these pathces. (I currently work on a
> SIL3114 driver using them)
> 
> It seems like there is a "lot" of code duplication in libata.h and the
> existant ata.h. Thus making it impossible to include both ones. Which i
> would like to do.

Yes, it is my one concern.

My another concern is, the common dir originally have one cmd_sata.c.
However, the cmd_sata.c is not generic.

Wolfgang,
How do we handle it?

> Pasted below is the modifications i did to do to get it working.
> 
> Could one perhaps merge the differences? Or is there other suggestions on
> how to solve this?

So, Wolfgang,
Can we merge the new stuff from libata.h to ata.h?

Thanks,
Dave

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

* [U-Boot-Users] [PATCH v1 2/5] ATA: Add the libata support
  2008-03-16  8:33 [U-Boot-Users] [PATCH v1 2/5] ATA: Add the libata support Dave Liu
  2008-03-17 21:55 ` Tor Krill
@ 2008-03-19  9:35 ` Tor Krill
  2008-03-19  9:08   ` Dave Liu
  2008-03-19 12:06   ` Wolfgang Denk
  1 sibling, 2 replies; 8+ messages in thread
From: Tor Krill @ 2008-03-19  9:35 UTC (permalink / raw)
  To: u-boot



Hi again,

After some further work with these pathces. (I currently work on a
SIL3114 driver using them)

It seems like there is a "lot" of code duplication in libata.h and the
existant ata.h. Thus making it impossible to include both ones. Which i
would like to do.

Pasted below is the modifications i did to do to get it working.

Could one perhaps merge the differences? Or is there other suggestions on
how to solve this?

/Tor

--- ../u-boot/include/ata.h	2008-02-28 07:40:55.000000000 +0100
+++ u-boot/include/ata.h	2008-03-18 11:53:43.000000000 +0100
@@ -84,43 +84,45 @@
 #define ATA_LBA		0xE0

 enum {
-	ATA_MAX_DEVICES = 1,	/* per bus/port */
-	ATA_MAX_PRD = 256,	/* we could make these 256/256 */
-	ATA_SECT_SIZE = 256,	/*256 words per sector */
+	ATA_MAX_DEVICES 	= 1,	/* per bus/port */
+	ATA_MAX_PRD 		= 256,	/* we could make these 256/256 */
+	ATA_SECT_SIZE 		= 256,	/*256 words per sector */

 	/* bits in ATA command block registers */
-	ATA_HOB = (1 << 7),	/* LBA48 selector */
-	ATA_NIEN = (1 << 1),	/* disable-irq flag */
-	/*ATA_LBA                 = (1 << 6), */ /* LBA28 selector */
-	ATA_DEV1 = (1 << 4),	/* Select Device 1 (slave) */
-	ATA_DEVICE_OBS = (1 << 7) | (1 << 5),	/* obs bits in dev reg */
-	ATA_DEVCTL_OBS = (1 << 3),	/* obsolete bit in devctl reg */
-	ATA_BUSY = (1 << 7),	/* BSY status bit */
-	ATA_DRDY = (1 << 6),	/* device ready */
-	ATA_DF = (1 << 5),	/* device fault */
-	ATA_DRQ = (1 << 3),	/* data request i/o */
-	ATA_ERR = (1 << 0),	/* have an error */
-	ATA_SRST = (1 << 2),	/* software reset */
-	ATA_ABORTED = (1 << 2),	/* command aborted */
+	ATA_HOB			= (1 << 7),	/* LBA48 selector */
+	ATA_NIEN		= (1 << 1),	/* disable-irq flag */
+	/*ATA_LBA			= (1 << 6),	*//* LBA28 selector */
+	ATA_DEV1 		= (1 << 4),	/* Select Device 1 (slave) */
+	ATA_DEVICE_OBS 	= (1 << 7) | (1 << 5),	/* obs bits in dev reg */
+	ATA_DEVCTL_OBS 	= (1 << 3),	/* obsolete bit in devctl reg */
+	ATA_BUSY 		= (1 << 7),	/* BSY status bit */
+	ATA_DRDY 		= (1 << 6),	/* device ready */
+	ATA_DF 			= (1 << 5),	/* device fault */
+	ATA_DRQ			= (1 << 3),	/* data request i/o */
+	ATA_ERR			= (1 << 0),	/* have an error */
+	ATA_SRST		= (1 << 2),	/* software reset */
+	ATA_ABORTED		= (1 << 2),	/* command aborted */
 	/* ATA command block registers */
-	ATA_REG_DATA = 0x00,
-	ATA_REG_ERR = 0x01,
-	ATA_REG_NSECT = 0x02,
-	ATA_REG_LBAL = 0x03,
-	ATA_REG_LBAM = 0x04,
-	ATA_REG_LBAH = 0x05,
-	ATA_REG_DEVICE = 0x06,
-	ATA_REG_STATUS = 0x07,
-	ATA_PCI_CTL_OFS = 0x02,
+	ATA_REG_DATA 	= 0x00,
+	ATA_REG_ERR 	= 0x01,
+	ATA_REG_NSECT	= 0x02,
+	ATA_REG_LBAL	= 0x03,
+	ATA_REG_LBAM	= 0x04,
+	ATA_REG_LBAH	= 0x05,
+	ATA_REG_DEVICE	= 0x06,
+	ATA_REG_STATUS	= 0x07,
+	ATA_PCI_CTL_OFS	= 0x02,
 	/* and their aliases */
-	ATA_REG_FEATURE = ATA_REG_ERR,
-	ATA_REG_CMD = ATA_REG_STATUS,
-	ATA_REG_BYTEL = ATA_REG_LBAM,
-	ATA_REG_BYTEH = ATA_REG_LBAH,
-	ATA_REG_DEVSEL = ATA_REG_DEVICE,
-	ATA_REG_IRQ = ATA_REG_NSECT,
+	ATA_REG_FEATURE	= ATA_REG_ERR,
+	ATA_REG_CMD		= ATA_REG_STATUS,
+	ATA_REG_BYTEL	= ATA_REG_LBAM,
+	ATA_REG_BYTEH	= ATA_REG_LBAH,
+	ATA_REG_DEVSEL	= ATA_REG_DEVICE,
+	ATA_REG_IRQ		= ATA_REG_NSECT,
+};

-	/* SETFEATURES stuff */
+/* SETFEATURES stuff */
+enum ata_set_features{
 	SETFEATURES_XFER = 0x03,
 	XFER_UDMA_7 = 0x47,
 	XFER_UDMA_6 = 0x46,
@@ -130,9 +132,13 @@
 	XFER_UDMA_2 = 0x42,
 	XFER_UDMA_1 = 0x41,
 	XFER_UDMA_0 = 0x40,
+	XFER_MW_DMA_4	= 0x24, /* CFA only */
+	XFER_MW_DMA_3	= 0x23, /* CFA only */
 	XFER_MW_DMA_2 = 0x22,
 	XFER_MW_DMA_1 = 0x21,
 	XFER_MW_DMA_0 = 0x20,
+	XFER_PIO_6		= 0x0E, /* CFA only */
+	XFER_PIO_5		= 0x0D, /* CFA only */
 	XFER_PIO_4 = 0x0C,
 	XFER_PIO_3 = 0x0B,
 	XFER_PIO_2 = 0x0A,
@@ -141,8 +147,14 @@
 	XFER_SW_DMA_2 = 0x12,
 	XFER_SW_DMA_1 = 0x11,
 	XFER_SW_DMA_0 = 0x10,
-	XFER_PIO_SLOW = 0x00
+	XFER_PIO_SLOW = 0x00,
+
+	SETFEATURES_WC_ON	= 0x02, /* Enable write cache */
+	SETFEATURES_WC_OFF	= 0x82, /* Disable write cache */
+
+	SETFEATURES_SPINUP	= 0x07, /* Spin-up drive */
 };
+
 /*
  * ATA Commands (only mandatory commands listed here)
  */
--- work/include/libata.h	2008-03-19 08:49:47.000000000 +0100
+++ u-boot/include/libata.h	2008-03-18 11:56:02.000000000 +0100
@@ -47,38 +47,6 @@
 	ATA_CMD_WRITE_FPDMA_QUEUED	= 0x61,
 };

-/* SETFEATURES stuff
- */
-enum ata_set_features {
-	/* SETFEATURES stuff */
-	SETFEATURES_XFER	= 0x03,
-	XFER_UDMA_7		= 0x47,
-	XFER_UDMA_6		= 0x46,
-	XFER_UDMA_5		= 0x45,
-	XFER_UDMA_4		= 0x44,
-	XFER_UDMA_3		= 0x43,
-	XFER_UDMA_2		= 0x42,
-	XFER_UDMA_1		= 0x41,
-	XFER_UDMA_0		= 0x40,
-	XFER_MW_DMA_4		= 0x24, /* CFA only */
-	XFER_MW_DMA_3		= 0x23, /* CFA only */
-	XFER_MW_DMA_2		= 0x22,
-	XFER_MW_DMA_1		= 0x21,
-	XFER_MW_DMA_0		= 0x20,
-	XFER_PIO_6		= 0x0E, /* CFA only */
-	XFER_PIO_5		= 0x0D, /* CFA only */
-	XFER_PIO_4		= 0x0C,
-	XFER_PIO_3		= 0x0B,
-	XFER_PIO_2		= 0x0A,
-	XFER_PIO_1		= 0x09,
-	XFER_PIO_0		= 0x08,
-	XFER_PIO_SLOW		= 0x00,
-
-	SETFEATURES_WC_ON	= 0x02, /* Enable write cache */
-	SETFEATURES_WC_OFF	= 0x82, /* Disable write cache */
-
-	SETFEATURES_SPINUP	= 0x07, /* Spin-up drive */
-};

 enum ata_protocol {
 	ATA_PROT_UNKNOWN,	/* unknown */
@@ -99,27 +67,10 @@
 };

 enum {
-	ATA_SECT_SIZE		= 512,
 	ATA_MAX_SECTORS_128	= 128,
 	ATA_MAX_SECTORS		= 256,
 	ATA_MAX_SECTORS_LBA48	= 65535,

-	/* bits in ATA command block registers */
-	ATA_HOB			= (1 << 7),	/* LBA48 selector */
-	ATA_NIEN		= (1 << 1),	/* disable-irq flag */
-	ATA_LBA			= (1 << 6),	/* LBA28 selector */
-	ATA_DEV1		= (1 << 4),	/* Select Device 1 (slave) */
-	ATA_BUSY		= (1 << 7),	/* BSY status bit */
-	ATA_DRDY		= (1 << 6),	/* device ready */
-	ATA_DF			= (1 << 5),	/* device fault */
-	ATA_DRQ			= (1 << 3),	/* data request i/o */
-	ATA_ERR			= (1 << 0),	/* have an error */
-	ATA_SRST		= (1 << 2),	/* software reset */
-	ATA_ICRC		= (1 << 7),	/* interface CRC error */
-	ATA_UNC			= (1 << 6),	/* uncorrectable media error */
-	ATA_IDNF		= (1 << 4),	/* ID not found */
-	ATA_ABORTED		= (1 << 2),	/* command aborted */
-
 	ATA_ID_WORDS		= 256,
 	ATA_ID_SERNO		= 10,
 	ATA_ID_FW_REV		= 23,
@@ -193,5 +144,5 @@
 }

 int sata_init(void);
-
+void ata_dump_id(u16 *id);
 #endif /* __LIBATA_H__ */

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

* [U-Boot-Users] [PATCH v1 2/5] ATA: Add the libata support
  2008-03-19  9:35 ` Tor Krill
  2008-03-19  9:08   ` Dave Liu
@ 2008-03-19 12:06   ` Wolfgang Denk
  2008-03-19 13:16     ` Tor Krill
  1 sibling, 1 reply; 8+ messages in thread
From: Wolfgang Denk @ 2008-03-19 12:06 UTC (permalink / raw)
  To: u-boot

In message <PWN74WD6.1205919334.9849270.tor@localhost> you wrote:
> 
> After some further work with these pathces. (I currently work on a
> SIL3114 driver using them)
> 
> It seems like there is a "lot" of code duplication in libata.h and the
> existant ata.h. Thus making it impossible to include both ones. Which i
> would like to do.

There is no such file like libata.h in mainline U-Boot code. What are
you referring to?

> Pasted below is the modifications i did to do to get it working.

Modifications against which source version exactly?

> Could one perhaps merge the differences? Or is there other suggestions on
> how to solve this?

Please make sure to add your SIgned-off-by line when submitting
patcehs.

Also, it would be better to split changes of content and pure
"beautifying" changes into separate patches.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
An Ada exception is when a routine gets in trouble and says
'Beam me up, Scotty'.

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

* [U-Boot-Users] [PATCH v1 2/5] ATA: Add the libata support
  2008-03-19  9:08   ` Dave Liu
@ 2008-03-19 12:14     ` Wolfgang Denk
  0 siblings, 0 replies; 8+ messages in thread
From: Wolfgang Denk @ 2008-03-19 12:14 UTC (permalink / raw)
  To: u-boot

Dear Dave,

in message <1205917739.3654.81.camel@localhost.localdomain> you wrote:
>
> > It seems like there is a "lot" of code duplication in libata.h and the
> > existant ata.h. Thus making it impossible to include both ones. Which i
> > would like to do.
> 
> Yes, it is my one concern.

As usual: patches welcome. They should apply, of course.

> My another concern is, the common dir originally have one cmd_sata.c.
> However, the cmd_sata.c is not generic.

In which way not generic?

How about submitting patches?

> How do we handle it?

Submit patches?

> Can we merge the new stuff from libata.h to ata.h?

There is no libata.h in the U-Boot tree so you cannot merge code from
there.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Gew?hnlich glaubt der Mensch,  wenn er nur Worte h?rt,  es m?sse sich
dabei doch auch was denken lassen.                 -- Goethe, Faust I

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

* [U-Boot-Users] [PATCH v1 2/5] ATA: Add the libata support
  2008-03-19 13:16     ` Tor Krill
@ 2008-03-19 12:23       ` Liu Dave
  0 siblings, 0 replies; 8+ messages in thread
From: Liu Dave @ 2008-03-19 12:23 UTC (permalink / raw)
  To: u-boot


> I can resubmit the additions to ata.h, and then maybe Dave 
> could remove
> the corresponding parts from his patch?

Hello everybody,

I think it will be better to handle these duplicated mess.
after I sent the full patch.

Are you ok?

Thanks,
Dave

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

* [U-Boot-Users] [PATCH v1 2/5] ATA: Add the libata support
  2008-03-19 12:06   ` Wolfgang Denk
@ 2008-03-19 13:16     ` Tor Krill
  2008-03-19 12:23       ` Liu Dave
  0 siblings, 1 reply; 8+ messages in thread
From: Tor Krill @ 2008-03-19 13:16 UTC (permalink / raw)
  To: u-boot




On 3/19/2008, "Wolfgang Denk" <wd@denx.de> wrote:

>In message <PWN74WD6.1205919334.9849270.tor@localhost> you wrote:
>>
>> After some further work with these pathces. (I currently work on a
>> SIL3114 driver using them)
>>
>> It seems like there is a "lot" of code duplication in libata.h and the
>> existant ata.h. Thus making it impossible to include both ones. Which i
>> would like to do.
>
>There is no such file like libata.h in mainline U-Boot code. What are
>you referring to?

Sorry if this was not clear. This reply was on the patch for addition of
libata.h and thus i referred to that patch.

>> Pasted below is the modifications i did to do to get it working.
>
>Modifications against which source version exactly?

The original patch and mainline ata.h

>> Could one perhaps merge the differences? Or is there other suggestions on
>> how to solve this?
>
>Please make sure to add your SIgned-off-by line when submitting
>patcehs.

Sure, will do. This version was merely for comments.

>Also, it would be better to split changes of content and pure
>"beautifying" changes into separate patches.

Once again. Ok. will do.

I can resubmit the additions to ata.h, and then maybe Dave could remove
the corresponding parts from his patch?

Best Regards,

/Tor

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

end of thread, other threads:[~2008-03-19 13:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-16  8:33 [U-Boot-Users] [PATCH v1 2/5] ATA: Add the libata support Dave Liu
2008-03-17 21:55 ` Tor Krill
2008-03-19  9:35 ` Tor Krill
2008-03-19  9:08   ` Dave Liu
2008-03-19 12:14     ` Wolfgang Denk
2008-03-19 12:06   ` Wolfgang Denk
2008-03-19 13:16     ` Tor Krill
2008-03-19 12:23       ` Liu Dave

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox