Skip to contentSkip to conversation

ATA: Add the libata support

PATCH New Dave Liu 4 participants 8 messages Mar 16, 2008 – Mar 19, 2008 Block layer

lore
Share & tools
lore

Dave Liu

author
#0 lore raw

PATCH 2/5 ATA: Add the libata support

add simple libata support in u-boot

---
 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
drivers/block/Makefile +1 -0
index e069969..d63ca2d 100644
@@ -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
drivers/block/libata.c new file +158 -0

158 lines not on this page · raw message

include/libata.h new file +197 -0

197 lines not on this page · raw message

Signature · 1 line
1.5.4.rc4
#1 lore raw

PATCH 2/5 ATA: Add the libata support

Quoted 1 line · Dave Liu

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

#2 lore raw

PATCH 2/5 ATA: Add the libata support

In reply to Dave Liu

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

include/ata.h renamed from u-boot/include/ata.h +45 -33
@@ -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)
  */
include/libata.h +1 -50

71 lines not on this page · raw message

author
#3 lore raw

PATCH 2/5 ATA: Add the libata support

Quoted 6 lines · Tor Krill

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?

Quoted 4 lines

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

#4 lore raw

PATCH 2/5 ATA: Add the libata support

Dear Dave,

Quoted 6 lines · in message <[email protected]> you wrote:
Quoted 4 lines

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.

Quoted 2 lines

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?

Quoted 1 line

How do we handle it?

Submit patches?

Quoted 1 line

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

Signature · 5 lines
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
#5 lore raw

PATCH 2/5 ATA: Add the libata support

In reply to Tor Krill
Quoted 7 lines · 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?

Quoted 1 line

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

Modifications against which source version exactly?

Quoted 2 lines

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

Signature · 5 lines
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'.
#6 lore raw

PATCH 2/5 ATA: Add the libata support

Quoted 11 lines · Wolfgang Denk
Quoted 7 lines · 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.

Quoted 3 lines
Quoted 1 line

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

Quoted 5 lines
Quoted 2 lines

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.

Quoted 2 lines

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

#7 lore raw

PATCH 2/5 ATA: Add the libata support

Quoted 4 lines

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