Skip to contentSkip to conversation

cmd_ide: enhance new feature "CONFIG_IDE_AHB"

PATCH Superseded Macpaul Lin 3 participants 5 messages Jan 24, 2011 – Apr 25, 2011 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cmd_ide: enhance new feature "CONFIG_IDE_AHB"

Although most IDE controller is designed to be connected to PCI bridge, there are still some IDE controller support AHB interface for SoC design.

The driver implementation of these IDE-AHB controllers differ from other IDE-PCI controller, some additional registers and commands access is required during CMD/DATA I/O. Hence a configuration "CONFIG_IDE_AHB" in cmd_ide.c is required to be defined to support these kinds of SoC controllers. Such as Faraday's FTIDE020 series and Global Unichip's UINF-0301.

---
 README           |    8 ++++++++
 common/cmd_ide.c |   37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletions(-)
README +8 -0
index 727bf8a..3de0605 100644
@@ -2673,6 +2673,14 @@ Low Level (hardware related) configuration options:
 		source code. It is used to make hardware dependant
 		initializations.
 
+- CONFIG_IDE_AHB:
+		Most IDE controllers were designed to be connected with PCI
+		interface. Only few of them were designed for AHB interface.
+		When software is doing ATA command and data transfer to
+		IDE devices through IDE-AHB controller, some additional
+		registers accessing to these kind of IDE-AHB controller
+		is requierd.
+
 - CONFIG_SYS_IMMR:	Physical address of the Internal Memory.
 		DO NOT CHANGE unless you know exactly what you're
 		doing! (11-4) [MPC8xx/82xx systems only]
common/cmd_ide.c +36 -1
index ea0f4a7..edb4fc0 100644
@@ -518,8 +518,22 @@ __ide_outb(int dev, int port, unsigned char val)
 {
 	debug ("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n",
 		dev, port, val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
+
+#if defined(CONFIG_IDE_AHB)
+	if (port) {
+		/* write command */
+		extern void ide_write_register(int, unsigned int, unsigned char);
+
+		ide_write_register(dev, port, val);
+	} else {
+		/* write data */
+		outb(val, (ATA_CURR_BASE(dev)));
+	}
+#else
 	outb(val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
+#endif
 }
+
 void ide_outb (int dev, int port, unsigned char val)
 		__attribute__((weak, alias("__ide_outb")));
 
@@ -527,7 +541,15 @@ unsigned char inline
 __ide_inb(int dev, int port)
 {
 	uchar val;
+
+#if defined(CONFIG_IDE_AHB)
+	extern unsigned char ide_read_register(int, unsigned int);
+
+	val = ide_read_register(dev, port);
+#else
 	val = inb((ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
+#endif
+
 	debug ("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n",
 		dev, port, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)), val);
 	return val;
@@ -696,6 +718,7 @@ void ide_init (void)
 		ide_dev_desc[i].blksz=0;
 		ide_dev_desc[i].lba=0;
 		ide_dev_desc[i].block_read=ide_read;
+		ide_dev_desc[i].block_write = ide_write;
 		if (!ide_bus_ok[IDE_BUS(i)])
 			continue;
 		ide_led (led, 1);		/* LED on	*/
@@ -902,7 +925,13 @@ output_data(int dev, ulong *sect_buf, int words)
 static void
 output_data(int dev, ulong *sect_buf, int words)
 {
-	outsw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words<<1);
+#if defined(CONFIG_IDE_AHB)
+	extern void ide_write_data(int, ulong *, int);
+
+	ide_write_data(dev, sect_buf, words);
+#else
+	outsw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words << 1);
+#endif
 }
 #endif	/* CONFIG_IDE_SWAP_IO */
 
@@ -960,7 +989,13 @@ input_data(int dev, ulong *sect_buf, int words)
 static void
 input_data(int dev, ulong *sect_buf, int words)
 {
+#if defined(CONFIG_IDE_AHB)
+	extern void ide_read_data(int, ulong *, int);
+
+	ide_read_data(dev, sect_buf, words);
+#else
 	insw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words << 1);
+#endif
 }
 
 #endif	/* CONFIG_IDE_SWAP_IO */
Signature · 1 line
1.7.3.5
#1 lore raw

PATCH 2/2 ftide020: add faraday ide ahb controller from Linux kernel

Faraday's ftide020_s is an IDE-AHB controller for SoC design. This patch ported the u-boot driver (PIO) of ftide020 ATA (IDE) driver from Linux kernel. IDE commands include read, info, and other functions has been implemented.

Because this IDE controller support AHB interface only which is differ from other most IDE controller supports PCI interface. Some registers access is required during CMD/DATA I/O. Hence a configuration "CONFIG_IDE_AHB" is required to be defined according to the feature in cmd_ide.c.

---
 drivers/block/Makefile   |    1 +
 drivers/block/ftide020.c |  380 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/block/ftide020.h |  265 ++++++++++++++++++++++++++++++++
 3 files changed, 646 insertions(+), 0 deletions(-)
 create mode 100644 drivers/block/ftide020.c
 create mode 100644 drivers/block/ftide020.h
drivers/block/Makefile +1 -0
index e27175b..e3f46b8 100644
@@ -28,6 +28,7 @@ LIB	:= $(obj)libblock.o
 COBJS-$(CONFIG_SCSI_AHCI) += ahci.o
 COBJS-$(CONFIG_ATA_PIIX) += ata_piix.o
 COBJS-$(CONFIG_FSL_SATA) += fsl_sata.o
+COBJS-$(CONFIG_IDE_FTIDE020) += ftide020.o
 COBJS-$(CONFIG_LIBATA) += libata.o
 COBJS-$(CONFIG_CMD_MG_DISK) += mg_disk.o
 COBJS-$(CONFIG_MVSATA_IDE) += mvsata_ide.o
drivers/block/ftide020.c new file +380 -0

380 lines not on this page · raw message

drivers/block/ftide020.h new file +265 -0

265 lines not on this page · raw message

Signature · 1 line
1.7.3.5
#2 lore raw

PATCH 2/2 ftide020: add faraday ide ahb controller from Linux kernel

Dear Macpaul Lin,

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

Faraday's ftide020_s is an IDE-AHB controller for SoC design. This patch ported the u-boot driver (PIO) of ftide020 ATA (IDE) driver from Linux kernel. IDE commands include read, info, and other functions has been implemented.

When copying code from Linux, you must give exact reference from which file and which exact version (commit ID) the code was taken rom; please see bullet # 4 at
http://www.denx.de/wiki/view/U-Boot/Patches#Attributing_Code_Copyrights_Sign

...

Quoted 1 line

+extern ulong ide_bus_offset[CONFIG_SYS_IDE_MAXBUS];

See before - please move to header file.

...

drivers/block/ftide020.c line 268

Quoted 6 lines
drivers/block/ftide020.c new file +6 -0
+			tcyc = (u8) (((UDMA_ACCESS_TIMING[UDMA_TCYC][mode] * sysclk) + 9990) / 10000);
+			tcvs = (u8) (((UDMA_ACCESS_TIMING[UDMA_TCVS][mode] * sysclk) + 9990) / 10000);
+			tmli = (u8) (((UDMA_ACCESS_TIMING[UDMA_TMLI][mode] * sysclk) + 9990) / 10000);
+			tenv = (u8) (((UDMA_ACCESS_TIMING[UDMA_TENV][mode] * sysclk) + 9990) / 10000);
+			trp  = (u8) (((UDMA_ACCESS_TIMING[UDMA_TRP][mode]  * sysclk) + 9990) / 10000);
+			tack = (u8) (((UDMA_ACCESS_TIMING[UDMA_TACK][mode] * sysclk) + 9990) / 10000);

Lines too long, please fix globally.

...

drivers/block/ftide020.h line 167

Quoted 2 lines
drivers/block/ftide020.h new file +2 -0
+/* set device: (CF4) */
+#define IDE_SET_OPCODE		(0x2740 << 2) 		/* [15:2], 0x9d00 */

please, no space before tabs. Please fix globally.

Best regards,

Wolfgang Denk

Signature · 4 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: [email protected]
When all is said and done, more is said than done.
#3 lore raw

PATCH 1/2 cmd_ide: enhance new feature "CONFIG_IDE_AHB"

In reply to Macpaul Lin

Dear Macpaul Lin,

Quoted 8 lines · In message <[email protected]> you wrote:

Although most IDE controller is designed to be connected to PCI bridge, there are still some IDE controller support AHB interface for SoC design.

The driver implementation of these IDE-AHB controllers differ from other IDE-PCI controller, some additional registers and commands access is required during CMD/DATA I/O. Hence a configuration "CONFIG_IDE_AHB" in cmd_ide.c is required to be defined to support these kinds of SoC controllers. Such as Faraday's FTIDE020 series and Global Unichip's UINF-0301.

...

Quoted 1 line
common/cmd_ide.c +1 -0
+		extern void ide_write_register(int, unsigned int, unsigned char);

...

common/cmd_ide.c unsigned char inline · line 546

Quoted 1 line
common/cmd_ide.c +1 -0
+	extern unsigned char ide_read_register(int, unsigned int);

Etc. Please move all such prototype decarations to an appropriate header file and get rid of these "extern"s here.

Thanks.

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
All a hacker needs is a tight PUSHJ, a loose pair of UUOs, and a warm
place to shift.
#4 lore raw

PATCH 1/2 cmd_ide: enhance new feature "CONFIG_IDE_AHB"

Hi Wolfgang,

2011/4/12 Wolfgang Denk <[email protected]>

Quoted 7 lines

Dear Macpaul Lin,
...

Quoted 1 line

+ ? ? ? ? ? ? extern void ide_write_register(int, unsigned int, unsigned char);

...

Quoted 1 line

+ ? ? extern unsigned char ide_read_register(int, unsigned int);

Quoted 8 lines

Etc. ?Please move all such prototype decarations to an appropriate header file and get rid of these "extern"s here.

Thanks.

Best regards,

Wolfgang Denk

The patch v2 of this patch set has been send on?2011-04-12 as follows

cmd_ide: enhance new feature "CONFIG_IDE_AHB"
http://patchwork.ozlabs.org/patch/90723/

ftide020: add faraday ide ahb controller
http://patchwork.ozlabs.org/patch/90724/

Please help on checking if these 2 patch is adaptable.

Sorry for that at the time when I send patch v2,
I have no idea about how to send patch with correct "In-reply-to" header.

Thanks.

--
Best regards,
Macpaul Lin