linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* H8/300 target support patch
@ 2004-02-15  6:05 Yoshinori Sato
  2004-02-15 14:40 ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 21+ messages in thread
From: Yoshinori Sato @ 2004-02-15  6:05 UTC (permalink / raw)
  To: linux-ide

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

Hello.
I develop H8/300 support of linux kernel.

I made a patch to use IDE driver with a H8/300 target.
I want to do merge to source if possible.

How will about it?

-- 
Yoshinori Sato
<ysato@users.sourceforge.jp>


[-- Attachment #2: h8300-ide.diff --]
[-- Type: application/octet-stream, Size: 9939 bytes --]

diff -Nru -x CVS -x '.*' -x '*.o' linux-2.6.2/drivers/ide/Makefile linux-2.6.2-h8300/drivers/ide/Makefile
--- linux-2.6.2/drivers/ide/Makefile		2004-02-15 08:20:48.000000000 +0900
+++ linux-2.6.2-h8300/drivers/ide/Makefile	2004-02-13 15:59:05.000000000 +0900
@@ -30,5 +30,5 @@
 obj-$(CONFIG_PROC_FS)			+= ide-proc.o
 endif
 
-obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ ppc/ arm/
+obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ ppc/ arm/ h8300/
 obj-$(CONFIG_BLK_DEV_HD)		+= legacy/
diff -Nru linux-2.6.2/drivers/ide/h8300/Makefile linux-2.6.2-h8300/drivers/ide/h8300/Makefile
--- linux-2.6.2/drivers/ide/h8300/Makefile		1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.2-h8300/drivers/ide/h8300/Makefile	2004-02-13 16:27:26.000000000 +0900
@@ -0,0 +1,2 @@
+obj-$(CONFIG_H8300H_H8MAX) := h8max_ide.o
+obj-$(CONFIG_H8300H_AKI3068NET) := aki3068_ide.o
diff -Nru linux-2.6.2/drivers/ide/h8300/aki3068_ide.c linux-2.6.2-h8300/drivers/ide/h8300/aki3068_ide.c
--- linux-2.6.2/drivers/ide/h8300/aki3068_ide.c		1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.2-h8300drivers/ide/h8300/aki3068_ide.c	2004-02-13 16:28:27.000000000 +0900
@@ -0,0 +1,139 @@
+/****************************************************************************/
+/*
+ *  linux/drivers/ide/h8300/aki3068_ide.c
+ *  AE-3068/AE-3069 IDE I/F support
+ *  reference schematic is http://www.linet.gr.jp/mituiwa/h8/h8osv3/hddprog/hdd.png
+ *
+ *  Copyright (C) 2003 Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License.  See the file COPYING in the main directory of this archive for
+ *  more details.
+ *
+ */
+/****************************************************************************/
+
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+#include <asm/irq.h>
+#include <asm/regs306x.h>
+
+/* IDE I/F configuration */
+#define IDE_BASE CONFIG_H8300_IDE_BASE
+#define IDE_CTRL CONFIG_H8300_IDE_ALT
+#define IDE_IRQ  (EXT_IRQ0 + CONFIG_H8300_IDE_IRQNO)
+
+#define IDE_DATA	0x00
+#define IDE_ERROR	0x02
+#define IDE_NSECTOR	0x04
+#define IDE_SECTOR	0x06
+#define IDE_LCYL	0x08
+#define IDE_HCYL	0x0A
+#define IDE_SELECT	0x0C
+#define IDE_STATUS	0x0E
+
+const static int offsets[IDE_NR_PORTS] = {
+    IDE_DATA, IDE_ERROR,  IDE_NSECTOR, IDE_SECTOR, IDE_LCYL,
+    IDE_HCYL, IDE_SELECT, IDE_STATUS,          -1,       -1
+};
+
+static void _outb(u8 d, unsigned long a)
+{
+	*(unsigned short *)a = (d & 0xff);
+}
+
+static void _outbsync(ide_drive_t *drive, u8 d, unsigned long a)
+{
+	*(unsigned short *)a = (d & 0xff);
+}
+
+static u8 _inb(unsigned long a)
+{
+	return *(unsigned short *)a;
+}
+
+static void _outw(u16 d, unsigned long a)
+{
+	*(unsigned short *)a = (d << 8) | (d >> 8);
+}
+
+static u16 _inw(unsigned long a)
+{
+	unsigned short d;
+	d = *(unsigned short *)a;
+	return (d << 8) | (d >> 8);
+}
+
+static void _outl(u32 d, unsigned long a)
+{
+}
+
+static u32 _inl(unsigned long a)
+{
+	return 0xffffffffUL;
+}
+
+static void _outsw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned volatile short *ap = (unsigned volatile short *)addr;
+	unsigned short *bp = (unsigned short *)buf;
+	unsigned short d;
+	while(len--) {
+		d = *bp++;
+		*ap = (d << 8) | (d >> 8);
+	}
+}
+
+static void _insw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned volatile short *ap = (unsigned volatile short *)addr;
+	unsigned short *bp = (unsigned short *)buf;
+	unsigned short d;
+	while(len--) {
+		d = *ap;
+		*bp++ = (d << 8) | (d >> 8);
+	}
+}
+
+void __init h8300_ide_init(void)
+{
+	hw_regs_t hw;
+	ide_hwif_t *hwif;
+	volatile unsigned char *abwcr = (volatile unsigned char *)ABWCR;
+	volatile unsigned char *cscr = (volatile unsigned char *)CSCR;
+	*abwcr &= ~((1 << ((IDE_BASE >> 21) & 7)) | (1 << ((IDE_CTRL >> 21) & 7)));
+	*cscr  |= (1 << ((IDE_BASE >> 21) & 7)) | (1 << ((IDE_CTRL >> 21) & 7)) | 0x0f;
+	memset(&hw,0,sizeof(hw));
+	ide_setup_ports(&hw, IDE_BASE, (int *)offsets,
+                             IDE_CTRL, 0, NULL,IDE_IRQ);
+	if (ide_register_hw(&hw, &hwif) != -1) {
+		hwif->mmio  = 0;
+		hwif->OUTB  = _outb;
+		hwif->OUTBSYNC = _outbsync;
+		hwif->OUTW  = _outw;
+		hwif->OUTL  = _outl;
+		hwif->OUTSW = _outsw;
+		hwif->OUTSL = NULL;
+		hwif->INB   = _inb;
+		hwif->INW   = _inw;
+		hwif->INL   = _inl;
+		hwif->INSW  = _insw;
+		hwif->INSL  = NULL;
+	}
+}
+
+void __init h8300_ide_print_resource(char *name, hw_regs_t *hw)
+{
+	printk("%s at 0x%08x-0x%08x,0x%08x on irq %d", name,
+		(unsigned int)hw->io_ports[IDE_DATA_OFFSET],
+		(unsigned int)hw->io_ports[IDE_DATA_OFFSET]+15,
+		(unsigned int)hw->io_ports[IDE_CONTROL_OFFSET],
+		hw->irq);
+}
diff -Nru linux-2.6.2/drivers/ide/h8300/h8max_ide.c linux-2.6.2-h8300/drivers/ide/h8300/h8max_ide.c
--- linux-2.6.2/drivers/ide/h8300/h8max_ide.c		1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.2-h8300/drivers/ide/h8300/h8max_ide.c	2004-02-13 16:28:14.000000000 +0900
@@ -0,0 +1,134 @@
+/****************************************************************************/
+/*
+ *  linux/drivers/ide/h8300/h8max_ide.c
+ *  H8MAX IDE Interface support
+ *
+ *  Copyright (C) 2003 Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License.  See the file COPYING in the main directory of this archive for
+ *  more details.
+ *
+ */
+/****************************************************************************/
+
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+#include <asm/irq.h>
+
+/* IDE I/F configuration */
+#define IDE_BASE 0x200000
+#define IDE_CTRL 0x60000c
+#define IDE_IRQ  EXT_IRQ5
+
+#define IDE_DATA	0x00
+#define IDE_ERROR	0x02
+#define IDE_NSECTOR	0x04
+#define IDE_SECTOR	0x06
+#define IDE_LCYL	0x08
+#define IDE_HCYL	0x0A
+#define IDE_SELECT	0x0C
+#define IDE_STATUS	0x0E
+
+const static int offsets[IDE_NR_PORTS] = {
+    IDE_DATA, IDE_ERROR,  IDE_NSECTOR, IDE_SECTOR, IDE_LCYL,
+    IDE_HCYL, IDE_SELECT, IDE_STATUS,          -1,       -1
+};
+
+static void h8max_outb(u8 d, unsigned long a)
+{
+	*(unsigned short *)a = (d & 0xff);
+}
+
+static void h8max_outbsync(ide_drive_t *drive, u8 d, unsigned long a)
+{
+	*(unsigned short *)a = (d & 0xff);
+}
+
+static u8 h8max_inb(unsigned long a)
+{
+	return (*(unsigned short *)a) & 0xff;
+}
+
+static void h8max_outw(u16 d, unsigned long a)
+{
+	*(unsigned short *)a = ((d << 8) & 0xff00) | ((d >> 8) & 0x00ff);
+}
+
+static u16 h8max_inw(unsigned long a)
+{
+	unsigned short d;
+	d = *(unsigned short *)a;
+	return ((d << 8) & 0xff00) | ((d >> 8) & 0x00ff);
+}
+
+static void h8max_outl(u32 d, unsigned long a)
+{
+}
+
+static u32 h8max_inl(unsigned long a)
+{
+	return 0xffffffffUL;
+}
+
+static void h8max_outsw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned volatile short *ap = (unsigned volatile short *)addr;
+	unsigned short *bp = (unsigned short *)buf;
+	unsigned short d;
+	while(len--) {
+		d = *bp++;
+		*ap = (d >> 8) | (d << 8);
+	}
+}
+
+static void h8max_insw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned volatile short *ap = (unsigned volatile short *)addr;
+	unsigned short *bp = (unsigned short *)buf;
+	unsigned short d;
+	while(len--) {
+		d = *ap;
+		*bp++ = (d >> 8) | (d << 8);
+	}
+}
+
+void __init h8300_ide_init(void)
+{
+	hw_regs_t hw;
+	ide_hwif_t *hwif;
+
+	memset(&hw,0,sizeof(hw));
+	ide_setup_ports(&hw, IDE_BASE, (int *)offsets,
+                             IDE_CTRL, 0, NULL,IDE_IRQ);
+	if (ide_register_hw(&hw, &hwif) != -1) {
+		hwif->mmio  = 0;
+		hwif->OUTB  = h8max_outb;
+		hwif->OUTBSYNC = h8max_outbsync;
+		hwif->OUTW  = h8max_outw;
+		hwif->OUTL  = h8max_outl;
+		hwif->OUTSW = h8max_outsw;
+		hwif->OUTSL = NULL;
+		hwif->INB   = h8max_inb;
+		hwif->INW   = h8max_inw;
+		hwif->INL   = h8max_inl;
+		hwif->INSW  = h8max_insw;
+		hwif->INSL  = NULL;
+	}
+}
+
+void __init h8300_ide_print_resource(char *name, hw_regs_t *hw)
+{
+	printk("%s at 0x%08x-0x%08x,0x%08x on irq %d", name,
+		(unsigned int)hw->io_ports[IDE_DATA_OFFSET],
+		(unsigned int)hw->io_ports[IDE_DATA_OFFSET]+15,
+		(unsigned int)hw->io_ports[IDE_CONTROL_OFFSET],
+		hw->irq);
+}
diff -Nru linux-2.6.2/drivers/ide/ide-probe.c linux-2.6.2-h8300/drivers/ide/ide-probe.c
--- linux-2.6.2/drivers/ide/ide-probe.c		2004-02-15 08:20:53.000000000 +0900
+++ linux-2.6.2-h8300/drivers/ide/ide-probe.c	2004-02-13 15:58:15.000000000 +0900
@@ -1102,7 +1102,8 @@
 		spin_unlock_irq(&ide_lock);
 	}
 
-#if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__)
+#if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__) && \
+    !defined(__H8300H__) && !defined(__H8300S__)
 	printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name,
 		hwif->io_ports[IDE_DATA_OFFSET],
 		hwif->io_ports[IDE_DATA_OFFSET]+7,
@@ -1112,6 +1113,8 @@
 		hwif->io_ports[IDE_DATA_OFFSET],
 		hwif->io_ports[IDE_DATA_OFFSET]+7,
 		hwif->io_ports[IDE_CONTROL_OFFSET], __irq_itoa(hwif->irq));
+#elif defined(__H8300H__) || defined(__H8300S__)
+	h8300_ide_print_resource(hwif->name,&(hwif->hw));
 #else
 	printk("%s at 0x%08lx on irq %d", hwif->name,
 		hwif->io_ports[IDE_DATA_OFFSET], hwif->irq);
diff -Nru linux-2.6.2/drivers/ide/ide.c linux-2.6.2-h8300/drivers/ide/ide.c
--- linux-2.6.2/drivers/ide/ide.c	2004-02-15 08:20:58.000000000 +0900
+++ linux-2.6.2-h8300/drivers/ide/ide.c	2004-02-13 15:55:51.000000000 +0900
@@ -2274,6 +2274,12 @@
 		pnpide_init(1);
 	}
 #endif /* CONFIG_BLK_DEV_IDEPNP */
+#if defined(__H8300H__) || defined(__H8300S__)
+        {
+		extern void h8300_ide_init(void);
+		h8300_ide_init();
+	}
+#endif /* defined(__H8300H__) || defined(__H8300S__) */
 }
 
 void __init ide_init_builtin_drivers (void)

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

* Re: H8/300 target support patch
  2004-02-15  6:05 H8/300 target support patch Yoshinori Sato
@ 2004-02-15 14:40 ` Bartlomiej Zolnierkiewicz
  2004-02-16 16:09   ` Yoshinori Sato
  0 siblings, 1 reply; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-02-15 14:40 UTC (permalink / raw)
  To: Yoshinori Sato; +Cc: linux-ide

On Sunday 15 of February 2004 07:05, Yoshinori Sato wrote:
> Hello.
> I develop H8/300 support of linux kernel.
>
> I made a patch to use IDE driver with a H8/300 target.
> I want to do merge to source if possible.
>
> How will about it?

Hi,

+ *  reference schematic is http://www.linet.gr.jp/mituiwa/h8/h8osv3/hddprog/hdd.png

this link is dead

+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/blkdev.h>

why do you include mm.h and blkdev.h?

+static void _outsw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned volatile short *ap = (unsigned volatile short *)addr;
+	unsigned short *bp = (unsigned short *)buf;
+	unsigned short d;
+	while(len--) {
+		d = *bp++;
+		*ap = (d << 8) | (d >> 8);
+	}
+}
+
+static void _insw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned volatile short *ap = (unsigned volatile short *)addr;
+	unsigned short *bp = (unsigned short *)buf;
+	unsigned short d;
+	while(len--) {
+		d = *ap;
+		*bp++ = (d << 8) | (d >> 8);
+	}
+}

why you don't use outsw() and insw() from include/asm-h8300/io.h?


+	ide_setup_ports(&hw, IDE_BASE, (int *)offsets,
+                             IDE_CTRL, 0, NULL,IDE_IRQ);

ide_setup_ports() is deprecated, please do not use it.

+		hwif->mmio  = 0;

Your driver is doing MMIO, it should request and release resources itself
and set hwif->mmio to 2.

+void __init h8300_ide_print_resource(char *name, hw_regs_t *hw)
+{
+	printk("%s at 0x%08x-0x%08x,0x%08x on irq %d", name,
+		(unsigned int)hw->io_ports[IDE_DATA_OFFSET],
+		(unsigned int)hw->io_ports[IDE_DATA_OFFSET]+15,
+		(unsigned int)hw->io_ports[IDE_CONTROL_OFFSET],
+		hw->irq);
+}

Is this necessary (this is a reason for extra #ifdefs in ide-probe.c)?
Can't we do what m68k is doing (print only address and IRQ) for now?

Both drivers use same IO ops so they can be moved to some include file
or both drivers can be merged (preferred solution) - they are for different
boards and can't work together (plus MAX_HWIFS is defined to 1 for h8300).

Here is patch (not tested) addressing some of these issues...

Thanks,
--bart

 linux-2.6.3-rc2-bk4-root/drivers/ide/h8300/aki3068_ide.c |   96 ++-------------
 linux-2.6.3-rc2-bk4-root/drivers/ide/h8300/h8_ide_iops.h |   72 +++++++++++
 linux-2.6.3-rc2-bk4-root/drivers/ide/h8300/h8max_ide.c   |   94 ++------------
 3 files changed, 109 insertions(+), 153 deletions(-)

diff -puN drivers/ide/h8300/aki3068_ide.c~h8300-ide-fixes drivers/ide/h8300/aki3068_ide.c
--- linux-2.6.3-rc2-bk4/drivers/ide/h8300/aki3068_ide.c~h8300-ide-fixes	2004-02-15 14:14:20.429869920 +0100
+++ linux-2.6.3-rc2-bk4-root/drivers/ide/h8300/aki3068_ide.c	2004-02-15 15:00:29.804860928 +0100
@@ -2,7 +2,6 @@
 /*
  *  linux/drivers/ide/h8300/aki3068_ide.c
  *  AE-3068/AE-3069 IDE I/F support
- *  reference schematic is http://www.linet.gr.jp/mituiwa/h8/h8osv3/hddprog/hdd.png
  *
  *  Copyright (C) 2003 Yoshinori Sato <ysato@users.sourceforge.jp>
  *
@@ -25,6 +24,8 @@
 #include <asm/irq.h>
 #include <asm/regs306x.h>
 
+#include "h8_ide_iops.h"
+
 /* IDE I/F configuration */
 #define IDE_BASE CONFIG_H8300_IDE_BASE
 #define IDE_CTRL CONFIG_H8300_IDE_ALT
@@ -39,67 +40,16 @@
 #define IDE_SELECT	0x0C
 #define IDE_STATUS	0x0E
 
-const static int offsets[IDE_NR_PORTS] = {
-    IDE_DATA, IDE_ERROR,  IDE_NSECTOR, IDE_SECTOR, IDE_LCYL,
-    IDE_HCYL, IDE_SELECT, IDE_STATUS,          -1,       -1
-};
-
-static void _outb(u8 d, unsigned long a)
-{
-	*(unsigned short *)a = (d & 0xff);
-}
-
-static void _outbsync(ide_drive_t *drive, u8 d, unsigned long a)
-{
-	*(unsigned short *)a = (d & 0xff);
-}
-
-static u8 _inb(unsigned long a)
+static void h8300_ide_ports(hw_regs_t *hw, unsigned long ioaddr)
 {
-	return *(unsigned short *)a;
-}
-
-static void _outw(u16 d, unsigned long a)
-{
-	*(unsigned short *)a = (d << 8) | (d >> 8);
-}
-
-static u16 _inw(unsigned long a)
-{
-	unsigned short d;
-	d = *(unsigned short *)a;
-	return (d << 8) | (d >> 8);
-}
-
-static void _outl(u32 d, unsigned long a)
-{
-}
-
-static u32 _inl(unsigned long a)
-{
-	return 0xffffffffUL;
-}
-
-static void _outsw(unsigned long addr, void *buf, u32 len)
-{
-	unsigned volatile short *ap = (unsigned volatile short *)addr;
-	unsigned short *bp = (unsigned short *)buf;
-	unsigned short d;
-	while(len--) {
-		d = *bp++;
-		*ap = (d << 8) | (d >> 8);
-	}
-}
-
-static void _insw(unsigned long addr, void *buf, u32 len)
-{
-	unsigned volatile short *ap = (unsigned volatile short *)addr;
-	unsigned short *bp = (unsigned short *)buf;
-	unsigned short d;
-	while(len--) {
-		d = *ap;
-		*bp++ = (d << 8) | (d >> 8);
-	}
+	hw->io_ports[IDE_DATA_OFFSET]	 = ioaddr + IDE_DATA;
+	hw->io_ports[IDE_ERROR_OFFSET]	 = ioaddr + IDE_ERROR;
+	hw->io_ports[IDE_NSECTOR_OFFSET] = ioaddr + IDE_NSECTOR;
+	hw->io_ports[IDE_SECTOR_OFFSET]	 = ioaddr + IDE_SECTOR;
+	hw->io_ports[IDE_LCYL_OFFSET]	 = ioaddr + IDE_LCYL;
+	hw->io_ports[IDE_HCYL_OFFSET]	 = ioaddr + IDE_HCYL;
+	hw->io_ports[IDE_SELECT_OFFSET]	 = ioaddr + IDE_SELECT;
+	hw->io_ports[IDE_STATUS_OFFSET]	 = ioaddr + IDE_STATUS;
 }
 
 void __init h8300_ide_init(void)
@@ -110,23 +60,15 @@ void __init h8300_ide_init(void)
 	volatile unsigned char *cscr = (volatile unsigned char *)CSCR;
 	*abwcr &= ~((1 << ((IDE_BASE >> 21) & 7)) | (1 << ((IDE_CTRL >> 21) & 7)));
 	*cscr  |= (1 << ((IDE_BASE >> 21) & 7)) | (1 << ((IDE_CTRL >> 21) & 7)) | 0x0f;
+
 	memset(&hw,0,sizeof(hw));
-	ide_setup_ports(&hw, IDE_BASE, (int *)offsets,
-                             IDE_CTRL, 0, NULL,IDE_IRQ);
-	if (ide_register_hw(&hw, &hwif) != -1) {
-		hwif->mmio  = 0;
-		hwif->OUTB  = _outb;
-		hwif->OUTBSYNC = _outbsync;
-		hwif->OUTW  = _outw;
-		hwif->OUTL  = _outl;
-		hwif->OUTSW = _outsw;
-		hwif->OUTSL = NULL;
-		hwif->INB   = _inb;
-		hwif->INW   = _inw;
-		hwif->INL   = _inl;
-		hwif->INSW  = _insw;
-		hwif->INSL  = NULL;
-	}
+
+	h8300_ide_ports(&hw, IDE_BASE);
+	hw.io_ports[IDE_CONTROL_OFFSET] = IDE_CTRL;
+	hw.irq = IDE_IRQ;
+
+	if (ide_register_hw(&hw, &hwif) != -1)
+		h8300_hwif_iops(hwif);
 }
 
 void __init h8300_ide_print_resource(char *name, hw_regs_t *hw)
diff -puN drivers/ide/h8300/h8max_ide.c~h8300-ide-fixes drivers/ide/h8300/h8max_ide.c
--- linux-2.6.3-rc2-bk4/drivers/ide/h8300/h8max_ide.c~h8300-ide-fixes	2004-02-15 14:14:23.858348712 +0100
+++ linux-2.6.3-rc2-bk4-root/drivers/ide/h8300/h8max_ide.c	2004-02-15 14:59:50.338860672 +0100
@@ -23,6 +23,8 @@
 #include <linux/init.h>
 #include <asm/irq.h>
 
+#include "h8_ide_iops.h"
+
 /* IDE I/F configuration */
 #define IDE_BASE 0x200000
 #define IDE_CTRL 0x60000c
@@ -37,67 +39,16 @@
 #define IDE_SELECT	0x0C
 #define IDE_STATUS	0x0E
 
-const static int offsets[IDE_NR_PORTS] = {
-    IDE_DATA, IDE_ERROR,  IDE_NSECTOR, IDE_SECTOR, IDE_LCYL,
-    IDE_HCYL, IDE_SELECT, IDE_STATUS,          -1,       -1
-};
-
-static void h8max_outb(u8 d, unsigned long a)
-{
-	*(unsigned short *)a = (d & 0xff);
-}
-
-static void h8max_outbsync(ide_drive_t *drive, u8 d, unsigned long a)
-{
-	*(unsigned short *)a = (d & 0xff);
-}
-
-static u8 h8max_inb(unsigned long a)
-{
-	return (*(unsigned short *)a) & 0xff;
-}
-
-static void h8max_outw(u16 d, unsigned long a)
-{
-	*(unsigned short *)a = ((d << 8) & 0xff00) | ((d >> 8) & 0x00ff);
-}
-
-static u16 h8max_inw(unsigned long a)
+static void h8300_ide_ports(hw_regs_t *hw, unsigned long ioaddr)
 {
-	unsigned short d;
-	d = *(unsigned short *)a;
-	return ((d << 8) & 0xff00) | ((d >> 8) & 0x00ff);
-}
-
-static void h8max_outl(u32 d, unsigned long a)
-{
-}
-
-static u32 h8max_inl(unsigned long a)
-{
-	return 0xffffffffUL;
-}
-
-static void h8max_outsw(unsigned long addr, void *buf, u32 len)
-{
-	unsigned volatile short *ap = (unsigned volatile short *)addr;
-	unsigned short *bp = (unsigned short *)buf;
-	unsigned short d;
-	while(len--) {
-		d = *bp++;
-		*ap = (d >> 8) | (d << 8);
-	}
-}
-
-static void h8max_insw(unsigned long addr, void *buf, u32 len)
-{
-	unsigned volatile short *ap = (unsigned volatile short *)addr;
-	unsigned short *bp = (unsigned short *)buf;
-	unsigned short d;
-	while(len--) {
-		d = *ap;
-		*bp++ = (d >> 8) | (d << 8);
-	}
+	hw->io_ports[IDE_DATA_OFFSET]	 = ioaddr + IDE_DATA;
+	hw->io_ports[IDE_ERROR_OFFSET]	 = ioaddr + IDE_ERROR;
+	hw->io_ports[IDE_NSECTOR_OFFSET] = ioaddr + IDE_NSECTOR;
+	hw->io_ports[IDE_SECTOR_OFFSET]	 = ioaddr + IDE_SECTOR;
+	hw->io_ports[IDE_LCYL_OFFSET]	 = ioaddr + IDE_LCYL;
+	hw->io_ports[IDE_HCYL_OFFSET]	 = ioaddr + IDE_HCYL;
+	hw->io_ports[IDE_SELECT_OFFSET]	 = ioaddr + IDE_SELECT;
+	hw->io_ports[IDE_STATUS_OFFSET]	 = ioaddr + IDE_STATUS;
 }
 
 void __init h8300_ide_init(void)
@@ -106,22 +57,13 @@ void __init h8300_ide_init(void)
 	ide_hwif_t *hwif;
 
 	memset(&hw,0,sizeof(hw));
-	ide_setup_ports(&hw, IDE_BASE, (int *)offsets,
-                             IDE_CTRL, 0, NULL,IDE_IRQ);
-	if (ide_register_hw(&hw, &hwif) != -1) {
-		hwif->mmio  = 0;
-		hwif->OUTB  = h8max_outb;
-		hwif->OUTBSYNC = h8max_outbsync;
-		hwif->OUTW  = h8max_outw;
-		hwif->OUTL  = h8max_outl;
-		hwif->OUTSW = h8max_outsw;
-		hwif->OUTSL = NULL;
-		hwif->INB   = h8max_inb;
-		hwif->INW   = h8max_inw;
-		hwif->INL   = h8max_inl;
-		hwif->INSW  = h8max_insw;
-		hwif->INSL  = NULL;
-	}
+
+	h8300_ide_ports(&hw, IDE_BASE);
+	hw.io_ports[IDE_CONTROL_OFFSET] = IDE_CTRL;
+	hw.irq = IDE_IRQ;
+
+	if (ide_register_hw(&hw, &hwif) != -1)
+		h8300_hwif_iops(hwif);
 }
 
 void __init h8300_ide_print_resource(char *name, hw_regs_t *hw)
diff -puN /dev/null drivers/ide/h8300/h8_ide_iops.h
--- /dev/null	2004-01-17 00:25:55.000000000 +0100
+++ linux-2.6.3-rc2-bk4-root/drivers/ide/h8300/h8_ide_iops.h	2004-02-15 14:59:58.588606520 +0100
@@ -0,0 +1,72 @@
+static void __ide_outb(u8 d, unsigned long a)
+{
+	*(unsigned short *)a = d;
+}
+
+static void __ide_outbsync(ide_drive_t *drive, u8 d, unsigned long a)
+{
+	*(unsigned short *)a = d;
+}
+
+static u8 __ide_inb(unsigned long a)
+{
+	return *(unsigned short *)a;
+}
+
+static void __ide_outw(u16 d, unsigned long a)
+{
+	*(unsigned short *)a = (d << 8) | (d >> 8);
+}
+
+static u16 __ide_inw(unsigned long a)
+{
+	unsigned short d;
+	d = *(unsigned short *)a;
+	return (d << 8) | (d >> 8);
+}
+
+static void __ide_outl(u32 d, unsigned long a)
+{
+}
+
+static u32 __ide_inl(unsigned long a)
+{
+	return 0xffffffffUL;
+}
+
+static void __ide_outsw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned volatile short *ap = (unsigned volatile short *)addr;
+	unsigned short *bp = (unsigned short *)buf;
+	unsigned short d;
+	while(len--) {
+		d = *bp++;
+		*ap = (d << 8) | (d >> 8);
+	}
+}
+
+static void __ide_insw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned volatile short *ap = (unsigned volatile short *)addr;
+	unsigned short *bp = (unsigned short *)buf;
+	unsigned short d;
+	while(len--) {
+		d = *ap;
+		*bp++ = (d << 8) | (d >> 8);
+	}
+}
+
+static void h8300_hwif_iops(ide_hwif_t *hwif)
+{
+	hwif->OUTB 	= __ide_outb;
+	hwif->OUTBSYNC	= __ide_outbsync;
+	hwif->OUTW	= __ide_outw;
+	hwif->OUTL	= __ide_outl;
+	hwif->OUTSW	= __ide_outsw;
+	hwif->OUTSL	= NULL;
+	hwif->INB	= __ide_inb;
+	hwif->INW	= __ide_inw;
+	hwif->INL	= __ide_inl;
+	hwif->INSW	= __ide_insw;
+	hwif->INSL	= NULL;
+}

_


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

* Re: H8/300 target support patch
  2004-02-15 14:40 ` Bartlomiej Zolnierkiewicz
@ 2004-02-16 16:09   ` Yoshinori Sato
  2004-02-16 16:40     ` Bartlomiej Zolnierkiewicz
  2004-02-16 22:09     ` Benjamin Herrenschmidt
  0 siblings, 2 replies; 21+ messages in thread
From: Yoshinori Sato @ 2004-02-16 16:09 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide

At Sun, 15 Feb 2004 15:40:56 +0100,
Bartlomiej Zolnierkiewicz wrote:
> 
> On Sunday 15 of February 2004 07:05, Yoshinori Sato wrote:
> > Hello.
> > I develop H8/300 support of linux kernel.
> >
> > I made a patch to use IDE driver with a H8/300 target.
> > I want to do merge to source if possible.
> >
> > How will about it?
> 
> Hi,
> 
> + *  reference schematic is http://www.linet.gr.jp/mituiwa/h8/h8osv3/hddprog/hdd.png
> 
> this link is dead
>
> +#include <linux/mm.h>
> +#include <linux/interrupt.h>
> +#include <linux/blkdev.h>
> 
> why do you include mm.h and blkdev.h?

It is code in a thing of 2.4.x
I seem to have left that deleted it when shifted to new driver.
 
> +static void _outsw(unsigned long addr, void *buf, u32 len)
> +{
> +	unsigned volatile short *ap = (unsigned volatile short *)addr;
> +	unsigned short *bp = (unsigned short *)buf;
> +	unsigned short d;
> +	while(len--) {
> +		d = *bp++;
> +		*ap = (d << 8) | (d >> 8);
> +	}
> +}
> +
> +static void _insw(unsigned long addr, void *buf, u32 len)
> +{
> +	unsigned volatile short *ap = (unsigned volatile short *)addr;
> +	unsigned short *bp = (unsigned short *)buf;
> +	unsigned short d;
> +	while(len--) {
> +		d = *ap;
> +		*bp++ = (d << 8) | (d >> 8);
> +	}
> +}
> 
> why you don't use outsw() and insw() from include/asm-h8300/io.h?

Because bus turns over, insw/outsw is not usable.

> +	ide_setup_ports(&hw, IDE_BASE, (int *)offsets,
> +                             IDE_CTRL, 0, NULL,IDE_IRQ);
> 
> ide_setup_ports() is deprecated, please do not use it.
> 
> +		hwif->mmio  = 0;
> 
> Your driver is doing MMIO, it should request and release resources itself
> and set hwif->mmio to 2.
> 
> +void __init h8300_ide_print_resource(char *name, hw_regs_t *hw)
> +{
> +	printk("%s at 0x%08x-0x%08x,0x%08x on irq %d", name,
> +		(unsigned int)hw->io_ports[IDE_DATA_OFFSET],
> +		(unsigned int)hw->io_ports[IDE_DATA_OFFSET]+15,
> +		(unsigned int)hw->io_ports[IDE_CONTROL_OFFSET],
> +		hw->irq);
> +}
> 
> Is this necessary (this is a reason for extra #ifdefs in ide-probe.c)?
> Can't we do what m68k is doing (print only address and IRQ) for now?

I can use it.
But there is the problem that resource to use cannot output justly.
I think that solved if can define a part of +7 with #define.
 
> Both drivers use same IO ops so they can be moved to some include file
> or both drivers can be merged (preferred solution) - they are for different
> boards and can't work together (plus MAX_HWIFS is defined to 1 for h8300).
>
> Here is patch (not tested) addressing some of these issues...

I identified operation.
MMIO and print_resource examine a correction method.

Thank you.

-- 
Yoshinori Sato
<ysato@users.sourceforge.jp>

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

* Re: H8/300 target support patch
  2004-02-16 16:09   ` Yoshinori Sato
@ 2004-02-16 16:40     ` Bartlomiej Zolnierkiewicz
  2004-02-16 22:07       ` Benjamin Herrenschmidt
  2004-02-16 22:09     ` Benjamin Herrenschmidt
  1 sibling, 1 reply; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-02-16 16:40 UTC (permalink / raw)
  To: Yoshinori Sato; +Cc: linux-ide

On Monday 16 of February 2004 17:09, Yoshinori Sato wrote:
> > +static void _outsw(unsigned long addr, void *buf, u32 len)
> > +{
> > +	unsigned volatile short *ap = (unsigned volatile short *)addr;
> > +	unsigned short *bp = (unsigned short *)buf;
> > +	unsigned short d;
> > +	while(len--) {
> > +		d = *bp++;
> > +		*ap = (d << 8) | (d >> 8);
> > +	}
> > +}
> > +
> > +static void _insw(unsigned long addr, void *buf, u32 len)
> > +{
> > +	unsigned volatile short *ap = (unsigned volatile short *)addr;
> > +	unsigned short *bp = (unsigned short *)buf;
> > +	unsigned short d;
> > +	while(len--) {
> > +		d = *ap;
> > +		*bp++ = (d << 8) | (d >> 8);
> > +	}
> > +}
> >
> > why you don't use outsw() and insw() from include/asm-h8300/io.h?
>
> Because bus turns over, insw/outsw is not usable.

Please explain.  I don't understand why outsw()/insw()
from io.h can't be assigned to hwif->OUTSW/hwif->INSW.

> > +	ide_setup_ports(&hw, IDE_BASE, (int *)offsets,
> > +                             IDE_CTRL, 0, NULL,IDE_IRQ);
> >
> > ide_setup_ports() is deprecated, please do not use it.
> >
> > +		hwif->mmio  = 0;
> >
> > Your driver is doing MMIO, it should request and release resources itself
> > and set hwif->mmio to 2.
> >
> > +void __init h8300_ide_print_resource(char *name, hw_regs_t *hw)
> > +{
> > +	printk("%s at 0x%08x-0x%08x,0x%08x on irq %d", name,
> > +		(unsigned int)hw->io_ports[IDE_DATA_OFFSET],
> > +		(unsigned int)hw->io_ports[IDE_DATA_OFFSET]+15,
> > +		(unsigned int)hw->io_ports[IDE_CONTROL_OFFSET],
> > +		hw->irq);
> > +}
> >
> > Is this necessary (this is a reason for extra #ifdefs in ide-probe.c)?
> > Can't we do what m68k is doing (print only address and IRQ) for now?
>
> I can use it.
> But there is the problem that resource to use cannot output justly.
> I think that solved if can define a part of +7 with #define.

That's what I'm talking about.  Do not print all resources but just base
address and IRQ (you can still get rest from /proc/ioports if you want).
Nevermind it is minor issue, we can live with one more #ifdef in ide-probe.c.

> > Both drivers use same IO ops so they can be moved to some include file
> > or both drivers can be merged (preferred solution) - they are for
> > different boards and can't work together (plus MAX_HWIFS is defined to 1
> > for h8300).
> >
> > Here is patch (not tested) addressing some of these issues...
>
> I identified operation.
> MMIO and print_resource examine a correction method.

Thanks.
--bart


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

* Re: H8/300 target support patch
  2004-02-16 16:40     ` Bartlomiej Zolnierkiewicz
@ 2004-02-16 22:07       ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 21+ messages in thread
From: Benjamin Herrenschmidt @ 2004-02-16 22:07 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Yoshinori Sato, linux-ide

On Tue, 2004-02-17 at 03:40, Bartlomiej Zolnierkiewicz wrote:
> On Monday 16 of February 2004 17:09, Yoshinori Sato wrote:
> > > +static void _outsw(unsigned long addr, void *buf, u32 len)
> > > +{
> > > +	unsigned volatile short *ap = (unsigned volatile short *)addr;
> > > +	unsigned short *bp = (unsigned short *)buf;
> > > +	unsigned short d;
> > > +	while(len--) {
> > > +		d = *bp++;
> > > +		*ap = (d << 8) | (d >> 8);
> > > +	}
> > > +}
> > > +
> > > +static void _insw(unsigned long addr, void *buf, u32 len)
> > > +{
> > > +	unsigned volatile short *ap = (unsigned volatile short *)addr;
> > > +	unsigned short *bp = (unsigned short *)buf;
> > > +	unsigned short d;
> > > +	while(len--) {
> > > +		d = *ap;
> > > +		*bp++ = (d << 8) | (d >> 8);
> > > +	}
> > > +}
> > >
> > > why you don't use outsw() and insw() from include/asm-h8300/io.h?
> >
> > Because bus turns over, insw/outsw is not usable.
>
> Please explain.  I don't understand why outsw()/insw()
> from io.h can't be assigned to hwif->OUTSW/hwif->INSW.

I'd add that the above code is incredibely shitty... Whatever the HW
does, this is not how it should be implemented.



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

* Re: H8/300 target support patch
  2004-02-16 16:09   ` Yoshinori Sato
  2004-02-16 16:40     ` Bartlomiej Zolnierkiewicz
@ 2004-02-16 22:09     ` Benjamin Herrenschmidt
  2004-02-17 11:33       ` Yoshinori Sato
  1 sibling, 1 reply; 21+ messages in thread
From: Benjamin Herrenschmidt @ 2004-02-16 22:09 UTC (permalink / raw)
  To: Yoshinori Sato; +Cc: Bartlomiej Zolnierkiewicz, linux-ide


> > 
> > why you don't use outsw() and insw() from include/asm-h8300/io.h?
> 
> Because bus turns over, insw/outsw is not usable.

Please explain.

Your IDE bus is flipped backward ? The next one who do that should
lose all rights to do any kind of HW design... Or is it a big endian
platform ? In this case, use normal flipping inw/outw for IOs and
non-flipping for stream IOs (insw/outsw)

Your functions are "streaming" versions, they should be called
with the proper name "insw/outsw". Calling the streaming versions
from the IO ones is wrong.



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

* Re: H8/300 target support patch
  2004-02-16 22:09     ` Benjamin Herrenschmidt
@ 2004-02-17 11:33       ` Yoshinori Sato
  2004-02-17 12:55         ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 21+ messages in thread
From: Yoshinori Sato @ 2004-02-17 11:33 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linux-ide

At Tue, 17 Feb 2004 09:09:38 +1100,
Benjamin Herrenschmidt wrote:
> 
> 
> > > 
> > > why you don't use outsw() and insw() from include/asm-h8300/io.h?
> > 
> > Because bus turns over, insw/outsw is not usable.
> 
> Please explain.
> 
> Your IDE bus is flipped backward ? The next one who do that should
> lose all rights to do any kind of HW design... Or is it a big endian
> platform ? In this case, use normal flipping inw/outw for IOs and
> non-flipping for stream IOs (insw/outsw)

This architecture is big endian.

> 
> Your functions are "streaming" versions, they should be called
> with the proper name "insw/outsw". Calling the streaming versions
> from the IO ones is wrong.
> 
> 

It was my misunderstanding that did not use asm/io.h.
It is the patch which it corrected to use it.
h8300/h8_ide_iops.h becomes needless.

diff -u ide-probe.c.orig ide-probe.c
--- ide-probe.c.orig	2004-02-17 19:46:33.000000000 +0900
+++ ide-probe.c	2004-02-17 19:51:30.000000000 +0900
@@ -983,6 +983,7 @@
 	unsigned int index;
 	ide_hwgroup_t *hwgroup;
 	ide_hwif_t *match = NULL;
+	int ide_regs_gap;
 
 	BUG_ON(in_interrupt());
 	BUG_ON(irqs_disabled());	
@@ -1101,19 +1102,17 @@
 		spin_unlock_irq(&ide_lock);
 	}
 
-#if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__) && \
-    !defined(__H8300H__) && !defined(__H8300S__)
+	ide_regs_gap = hwif->io_ports[IDE_ERROR_OFFSET] - hwif->io_ports[IDE_DATA_OFFSET];
+#if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__)
 	printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name,
 		hwif->io_ports[IDE_DATA_OFFSET],
-		hwif->io_ports[IDE_DATA_OFFSET]+7,
+		hwif->io_ports[IDE_DATA_OFFSET] + ide_regs_gap * 8 - 1,
 		hwif->io_ports[IDE_CONTROL_OFFSET], hwif->irq);
 #elif defined(__sparc__)
 	printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %s", hwif->name,
 		hwif->io_ports[IDE_DATA_OFFSET],
 		hwif->io_ports[IDE_DATA_OFFSET]+7,
 		hwif->io_ports[IDE_CONTROL_OFFSET], __irq_itoa(hwif->irq));
-#elif defined(__H8300H__) || defined(__H8300S__)
-	h8300_ide_print_resource(hwif->name,&(hwif->hw));
 #else
 	printk("%s at 0x%08lx on irq %d", hwif->name,
 		hwif->io_ports[IDE_DATA_OFFSET], hwif->irq);
diff -u h8300/aki3068_ide.c.orig h8300/aki3068_ide.c
--- aki3068_ide.c.orig	2004-02-16 22:48:00.000000000 +0900
+++ aki3068_ide.c	2004-02-17 20:09:11.000000000 +0900
@@ -24,8 +24,6 @@
 #include <asm/irq.h>
 #include <asm/regs306x.h>
 
-#include "h8_ide_iops.h"
-
 /* IDE I/F configuration */
 #define IDE_BASE CONFIG_H8300_IDE_BASE
 #define IDE_CTRL CONFIG_H8300_IDE_ALT
@@ -40,7 +38,7 @@
 #define IDE_SELECT	0x0C
 #define IDE_STATUS	0x0E
 
-static void h8300_ide_ports(hw_regs_t *hw, unsigned long ioaddr)
+static void __init h8300_ide_ports(hw_regs_t *hw, unsigned long ioaddr)
 {
 	hw->io_ports[IDE_DATA_OFFSET]	 = ioaddr + IDE_DATA;
 	hw->io_ports[IDE_ERROR_OFFSET]	 = ioaddr + IDE_ERROR;
@@ -68,14 +66,5 @@
 	hw.irq = IDE_IRQ;
 
 	if (ide_register_hw(&hw, &hwif) != -1)
-		h8300_hwif_iops(hwif);
-}
-
-void __init h8300_ide_print_resource(char *name, hw_regs_t *hw)
-{
-	printk("%s at 0x%08x-0x%08x,0x%08x on irq %d", name,
-		(unsigned int)hw->io_ports[IDE_DATA_OFFSET],
-		(unsigned int)hw->io_ports[IDE_DATA_OFFSET]+15,
-		(unsigned int)hw->io_ports[IDE_CONTROL_OFFSET],
-		hw->irq);
+		default_hwif_iops(hwif);
 }
diff -u h8300/h8max_ide.c.orig h8300/h8max_ide.c
--- h8max_ide.c.orig	2004-02-17 19:45:46.000000000 +0900
+++ h8max_ide.c	2004-02-17 19:50:32.000000000 +0900
@@ -23,8 +23,6 @@
 #include <linux/init.h>
 #include <asm/irq.h>
 
-#include "h8_ide_iops.h"
-
 /* IDE I/F configuration */
 #define IDE_BASE 0x200000
 #define IDE_CTRL 0x60000c
@@ -39,7 +37,7 @@
 #define IDE_SELECT	0x0C
 #define IDE_STATUS	0x0E
 
-static void h8300_ide_ports(hw_regs_t *hw, unsigned long ioaddr)
+static void __init h8300_ide_ports(hw_regs_t *hw, unsigned long ioaddr)
 {
 	hw->io_ports[IDE_DATA_OFFSET]	 = ioaddr + IDE_DATA;
 	hw->io_ports[IDE_ERROR_OFFSET]	 = ioaddr + IDE_ERROR;
@@ -63,14 +61,5 @@
 	hw.irq = IDE_IRQ;
 
 	if (ide_register_hw(&hw, &hwif) != -1)
-		h8300_hwif_iops(hwif);
-}
-
-void __init h8300_ide_print_resource(char *name, hw_regs_t *hw)
-{
-	printk("%s at 0x%08x-0x%08x,0x%08x on irq %d", name,
-		(unsigned int)hw->io_ports[IDE_DATA_OFFSET],
-		(unsigned int)hw->io_ports[IDE_DATA_OFFSET]+15,
-		(unsigned int)hw->io_ports[IDE_CONTROL_OFFSET],
-		hw->irq);
+		default_hwif_iops(hwif);
 }

-- 
Yoshinori Sato
<ysato@users.sourceforge.jp>

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

* Re: H8/300 target support patch
  2004-02-17 11:33       ` Yoshinori Sato
@ 2004-02-17 12:55         ` Benjamin Herrenschmidt
  2004-02-19 16:12           ` Yoshinori Sato
  0 siblings, 1 reply; 21+ messages in thread
From: Benjamin Herrenschmidt @ 2004-02-17 12:55 UTC (permalink / raw)
  To: Yoshinori Sato; +Cc: linux-ide


> > Your IDE bus is flipped backward ? The next one who do that should
> > lose all rights to do any kind of HW design... Or is it a big endian
> > platform ? In this case, use normal flipping inw/outw for IOs and
> > non-flipping for stream IOs (insw/outsw)
> 
> This architecture is big endian.

A big endian architecture needs the standard inx/outx macros to
be byteswapped, but _not_ the insw/outsw. That should be all 
done properly from the standard macros in your asm/io.h, you
should _not_ have to byteswap normal transfers.

> It was my misunderstanding that did not use asm/io.h.
> It is the patch which it corrected to use it.
> h8300/h8_ide_iops.h becomes needless.

Ben.



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

* Re: H8/300 target support patch
  2004-02-17 12:55         ` Benjamin Herrenschmidt
@ 2004-02-19 16:12           ` Yoshinori Sato
  2004-02-19 16:34             ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 21+ messages in thread
From: Yoshinori Sato @ 2004-02-19 16:12 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linux-ide

At Tue, 17 Feb 2004 23:55:54 +1100,
Benjamin Herrenschmidt wrote:
> 
> 
> > > Your IDE bus is flipped backward ? The next one who do that should
> > > lose all rights to do any kind of HW design... Or is it a big endian
> > > platform ? In this case, use normal flipping inw/outw for IOs and
> > > non-flipping for stream IOs (insw/outsw)
> > 
> > This architecture is big endian.
> 
> A big endian architecture needs the standard inx/outx macros to
> be byteswapped, but _not_ the insw/outsw. That should be all 
> done properly from the standard macros in your asm/io.h, you
> should _not_ have to byteswap normal transfers.

I appreciated incorrectly.
 
> > It was my misunderstanding that did not use asm/io.h.
> > It is the patch which it corrected to use it.
> > h8300/h8_ide_iops.h becomes needless.
> 
> Ben.
> 
> 

I corrected it.

--- aki3068_ide.c.orig	2004-02-16 22:48:00.000000000 +0900
+++ aki3068_ide.c	2004-02-20 00:03:49.000000000 +0900
@@ -40,7 +40,7 @@
 #define IDE_SELECT	0x0C
 #define IDE_STATUS	0x0E
 
-static void h8300_ide_ports(hw_regs_t *hw, unsigned long ioaddr)
+static void __init h8300_ide_ports(hw_regs_t *hw, unsigned long ioaddr)
 {
 	hw->io_ports[IDE_DATA_OFFSET]	 = ioaddr + IDE_DATA;
 	hw->io_ports[IDE_ERROR_OFFSET]	 = ioaddr + IDE_ERROR;
@@ -70,12 +70,3 @@
 	if (ide_register_hw(&hw, &hwif) != -1)
 		h8300_hwif_iops(hwif);
 }
-
-void __init h8300_ide_print_resource(char *name, hw_regs_t *hw)
-{
-	printk("%s at 0x%08x-0x%08x,0x%08x on irq %d", name,
-		(unsigned int)hw->io_ports[IDE_DATA_OFFSET],
-		(unsigned int)hw->io_ports[IDE_DATA_OFFSET]+15,
-		(unsigned int)hw->io_ports[IDE_CONTROL_OFFSET],
-		hw->irq);
-}
--- h8max_ide.c.orig	2004-02-17 19:45:46.000000000 +0900
+++ h8max_ide.c	2004-02-19 22:56:41.000000000 +0900
@@ -39,7 +39,7 @@
 #define IDE_SELECT	0x0C
 #define IDE_STATUS	0x0E
 
-static void h8300_ide_ports(hw_regs_t *hw, unsigned long ioaddr)
+static void __init h8300_ide_ports(hw_regs_t *hw, unsigned long ioaddr)
 {
 	hw->io_ports[IDE_DATA_OFFSET]	 = ioaddr + IDE_DATA;
 	hw->io_ports[IDE_ERROR_OFFSET]	 = ioaddr + IDE_ERROR;
@@ -65,12 +65,3 @@
 	if (ide_register_hw(&hw, &hwif) != -1)
 		h8300_hwif_iops(hwif);
 }
-
-void __init h8300_ide_print_resource(char *name, hw_regs_t *hw)
-{
-	printk("%s at 0x%08x-0x%08x,0x%08x on irq %d", name,
-		(unsigned int)hw->io_ports[IDE_DATA_OFFSET],
-		(unsigned int)hw->io_ports[IDE_DATA_OFFSET]+15,
-		(unsigned int)hw->io_ports[IDE_CONTROL_OFFSET],
-		hw->irq);
-}
--- h8_ide_iops.h.orig	2004-02-19 23:54:06.000000000 +0900
+++ h8_ide_iops.h	2004-02-19 23:54:58.000000000 +0900
@@ -1,28 +1,30 @@
+/* H8/300 IDE I/F I/O operations */
+
+#include <asm/io.h>
+
 static void __ide_outb(u8 d, unsigned long a)
 {
-	*(unsigned short *)a = d;
+	outb(d,a); 
 }
 
 static void __ide_outbsync(ide_drive_t *drive, u8 d, unsigned long a)
 {
-	*(unsigned short *)a = d;
+	outb(d,a); 
 }
 
 static u8 __ide_inb(unsigned long a)
 {
-	return *(unsigned short *)a;
+	return inb(a);
 }
 
 static void __ide_outw(u16 d, unsigned long a)
 {
-	*(unsigned short *)a = (d << 8) | (d >> 8);
+	outw(d,a);
 }
 
 static u16 __ide_inw(unsigned long a)
 {
-	unsigned short d;
-	d = *(unsigned short *)a;
-	return (d << 8) | (d >> 8);
+	return inw(a);
 }
 
 static void __ide_outl(u32 d, unsigned long a)
@@ -36,27 +38,19 @@
 
 static void __ide_outsw(unsigned long addr, void *buf, u32 len)
 {
-	unsigned volatile short *ap = (unsigned volatile short *)addr;
 	unsigned short *bp = (unsigned short *)buf;
-	unsigned short d;
-	while(len--) {
-		d = *bp++;
-		*ap = (d << 8) | (d >> 8);
-	}
+	while(len--)
+		outw(*bp++,addr);
 }
 
 static void __ide_insw(unsigned long addr, void *buf, u32 len)
 {
-	unsigned volatile short *ap = (unsigned volatile short *)addr;
 	unsigned short *bp = (unsigned short *)buf;
-	unsigned short d;
-	while(len--) {
-		d = *ap;
-		*bp++ = (d << 8) | (d >> 8);
-	}
+	while(len--)
+		*bp++ = inw(addr);
 }
 
-static void h8300_hwif_iops(ide_hwif_t *hwif)
+static void __init h8300_hwif_iops(ide_hwif_t *hwif)
 {
 	hwif->OUTB 	= __ide_outb;
 	hwif->OUTBSYNC	= __ide_outbsync;

-- 
Yoshinori Sato
<ysato@users.sourceforge.jp>

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

* Re: H8/300 target support patch
  2004-02-19 16:12           ` Yoshinori Sato
@ 2004-02-19 16:34             ` Bartlomiej Zolnierkiewicz
  2004-02-20 12:28               ` Yoshinori Sato
  0 siblings, 1 reply; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-02-19 16:34 UTC (permalink / raw)
  To: Yoshinori Sato; +Cc: Benjamin Herrenschmidt, linux-ide


Hi,

Can you send updated patch?
I am lost in incremental changes. :-)

Thanks.


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

* Re: H8/300 target support patch
  2004-02-19 16:34             ` Bartlomiej Zolnierkiewicz
@ 2004-02-20 12:28               ` Yoshinori Sato
  2004-02-20 15:25                 ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 21+ messages in thread
From: Yoshinori Sato @ 2004-02-20 12:28 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Benjamin Herrenschmidt, linux-ide

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

At Thu, 19 Feb 2004 17:34:49 +0100,
Bartlomiej Zolnierkiewicz wrote:
> 
> 
> Hi,
> 
> Can you send updated patch?
> I am lost in incremental changes. :-)
> 
> Thanks.
> 

Difference with linux-2.6.3.

-- 
Yoshinori Sato
<ysato@users.sourceforge.jp>


[-- Attachment #2: linux-2.6.3-h8300-ide.diff --]
[-- Type: application/octet-stream, Size: 8680 bytes --]

diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/Makefile linux-2.6.3-h8300/drivers/ide/Makefile
--- linux-2.6.3/drivers/ide/Makefile		2004-02-20 01:08:02.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/Makefile	2004-02-20 17:42:40.000000000 +0900
@@ -46,5 +46,5 @@
 obj-$(CONFIG_BLK_DEV_IDETAPE)		+= ide-tape.o
 obj-$(CONFIG_BLK_DEV_IDEFLOPPY)		+= ide-floppy.o
 
-obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ arm/
+obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ arm/ h8300/
 obj-$(CONFIG_BLK_DEV_HD)		+= legacy/
diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/h8300/Makefile linux-2.6.3-h8300/drivers/ide/h8300/Makefile
--- linux-2.6.3/drivers/ide/h8300/Makefile		1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/h8300/Makefile	2003-08-27 22:59:37.000000000 +0900
@@ -0,0 +1,3 @@
+obj-$(CONFIG_H8300H_H8MAX) := h8max_ide.o
+obj-$(CONFIG_H8300H_AKI3068NET) := aki3068_ide.o
+obj-m		:=
diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/h8300/aki3068_ide.c linux-2.6.3-h8300/drivers/ide/h8300/aki3068_ide.c
--- linux-2.6.3/drivers/ide/h8300/aki3068_ide.c		1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/h8300/aki3068_ide.c	2004-02-20 18:11:36.000000000 +0900
@@ -0,0 +1,72 @@
+/****************************************************************************/
+/*
+ *  linux/drivers/ide/h8300/aki3068_ide.c
+ *  aki3068net IDE I/F support
+ *
+ *  Copyright (C) 2003 Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License.  See the file COPYING in the main directory of this archive for
+ *  more details.
+ *
+ */
+/****************************************************************************/
+
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+#include <asm/irq.h>
+#include <asm/regs306x.h>
+
+#include "h8_ide_iops.h"
+
+/* IDE I/F configuration */
+#define IDE_BASE CONFIG_H8300_IDE_BASE
+#define IDE_CTRL CONFIG_H8300_IDE_ALT
+#define IDE_IRQ  (EXT_IRQ0 + CONFIG_H8300_IDE_IRQNO)
+
+#define IDE_DATA	0x00
+#define IDE_ERROR	0x02
+#define IDE_NSECTOR	0x04
+#define IDE_SECTOR	0x06
+#define IDE_LCYL	0x08
+#define IDE_HCYL	0x0A
+#define IDE_SELECT	0x0C
+#define IDE_STATUS	0x0E
+
+static void __init h8300_ide_ports(hw_regs_t *hw, unsigned long ioaddr)
+{
+	hw->io_ports[IDE_DATA_OFFSET]	 = ioaddr + IDE_DATA;
+	hw->io_ports[IDE_ERROR_OFFSET]	 = ioaddr + IDE_ERROR;
+	hw->io_ports[IDE_NSECTOR_OFFSET] = ioaddr + IDE_NSECTOR;
+	hw->io_ports[IDE_SECTOR_OFFSET]	 = ioaddr + IDE_SECTOR;
+	hw->io_ports[IDE_LCYL_OFFSET]	 = ioaddr + IDE_LCYL;
+	hw->io_ports[IDE_HCYL_OFFSET]	 = ioaddr + IDE_HCYL;
+	hw->io_ports[IDE_SELECT_OFFSET]	 = ioaddr + IDE_SELECT;
+	hw->io_ports[IDE_STATUS_OFFSET]	 = ioaddr + IDE_STATUS;
+}
+
+void __init h8300_ide_init(void)
+{
+	hw_regs_t hw;
+	ide_hwif_t *hwif;
+	volatile unsigned char *abwcr = (volatile unsigned char *)ABWCR;
+	volatile unsigned char *cscr = (volatile unsigned char *)CSCR;
+	*abwcr &= ~((1 << ((IDE_BASE >> 21) & 7)) | (1 << ((IDE_CTRL >> 21) & 7)));
+	*cscr  |= (1 << ((IDE_BASE >> 21) & 7)) | (1 << ((IDE_CTRL >> 21) & 7)) | 0x0f;
+
+	memset(&hw,0,sizeof(hw));
+
+	h8300_ide_ports(&hw, IDE_BASE);
+	hw.io_ports[IDE_CONTROL_OFFSET] = IDE_CTRL;
+	hw.irq = IDE_IRQ;
+
+	if (ide_register_hw(&hw, &hwif) != -1)
+		h8300_hwif_iops(hwif);
+}
diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/h8300/h8_ide_iops.h linux-2.6.3-h8300/drivers/ide/h8300/h8_ide_iops.h
--- linux-2.6.3/drivers/ide/h8300/h8_ide_iops.h		1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/h8300/h8_ide_iops.h	2004-02-20 17:40:15.000000000 +0900
@@ -0,0 +1,66 @@
+/* H8/300 IDE I/F I/O operations */
+
+#include <asm/io.h>
+
+static void __ide_outb(u8 d, unsigned long a)
+{
+	outb(d,a); 
+}
+
+static void __ide_outbsync(ide_drive_t *drive, u8 d, unsigned long a)
+{
+	outb(d,a); 
+}
+
+static u8 __ide_inb(unsigned long a)
+{
+	return inb(a);
+}
+
+static void __ide_outw(u16 d, unsigned long a)
+{
+	return outw(d,a);
+}
+
+static u16 __ide_inw(unsigned long a)
+{
+	return inw(a);
+}
+
+static void __ide_outl(u32 d, unsigned long a)
+{
+}
+
+static u32 __ide_inl(unsigned long a)
+{
+	return 0xffffffffUL;
+}
+
+static void __ide_outsw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned short *bp = (unsigned short *)buf;
+	while(len--)
+		outw(*bp++,addr);
+}
+
+static void __ide_insw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned short *bp = (unsigned short *)buf;
+	while(len--)
+		*bp++ = inw(addr);
+}
+
+static void __init h8300_hwif_iops(ide_hwif_t *hwif)
+{
+	hwif->OUTB 	= __ide_outb;
+	hwif->OUTBSYNC	= __ide_outbsync;
+	hwif->OUTW	= __ide_outw;
+	hwif->OUTL	= __ide_outl;
+	hwif->OUTSW	= __ide_outsw;
+	hwif->OUTSL	= NULL;
+	hwif->INB	= __ide_inb;
+	hwif->INW	= __ide_inw;
+	hwif->INL	= __ide_inl;
+	hwif->INSW	= __ide_insw;
+	hwif->INSL	= NULL;
+}
diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/h8300/h8max_ide.c linux-2.6.3-h8300/drivers/ide/h8300/h8max_ide.c
--- linux-2.6.3/drivers/ide/h8300/h8max_ide.c		1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/h8300/h8max_ide.c	2004-02-20 18:11:36.000000000 +0900
@@ -0,0 +1,67 @@
+/****************************************************************************/
+/*
+ *  linux/drivers/ide/h8300/h8max_ide.c
+ *  H8MAX IDE Interface support
+ *
+ *  Copyright (C) 2003 Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License.  See the file COPYING in the main directory of this archive for
+ *  more details.
+ *
+ */
+/****************************************************************************/
+
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+#include <asm/irq.h>
+
+#include "h8_ide_iops.h"
+
+/* IDE I/F configuration */
+#define IDE_BASE 0x200000
+#define IDE_CTRL 0x60000c
+#define IDE_IRQ  EXT_IRQ5
+
+#define IDE_DATA	0x00
+#define IDE_ERROR	0x02
+#define IDE_NSECTOR	0x04
+#define IDE_SECTOR	0x06
+#define IDE_LCYL	0x08
+#define IDE_HCYL	0x0A
+#define IDE_SELECT	0x0C
+#define IDE_STATUS	0x0E
+
+static void __init h8300_ide_ports(hw_regs_t *hw, unsigned long ioaddr)
+{
+	hw->io_ports[IDE_DATA_OFFSET]	 = ioaddr + IDE_DATA;
+	hw->io_ports[IDE_ERROR_OFFSET]	 = ioaddr + IDE_ERROR;
+	hw->io_ports[IDE_NSECTOR_OFFSET] = ioaddr + IDE_NSECTOR;
+	hw->io_ports[IDE_SECTOR_OFFSET]	 = ioaddr + IDE_SECTOR;
+	hw->io_ports[IDE_LCYL_OFFSET]	 = ioaddr + IDE_LCYL;
+	hw->io_ports[IDE_HCYL_OFFSET]	 = ioaddr + IDE_HCYL;
+	hw->io_ports[IDE_SELECT_OFFSET]	 = ioaddr + IDE_SELECT;
+	hw->io_ports[IDE_STATUS_OFFSET]	 = ioaddr + IDE_STATUS;
+}
+
+void __init h8300_ide_init(void)
+{
+	hw_regs_t hw;
+	ide_hwif_t *hwif;
+
+	memset(&hw,0,sizeof(hw));
+
+	h8300_ide_ports(&hw, IDE_BASE);
+	hw.io_ports[IDE_CONTROL_OFFSET] = IDE_CTRL;
+	hw.irq = IDE_IRQ;
+
+	if (ide_register_hw(&hw, &hwif) != -1)
+		h8300_hwif_iops(hwif);
+}
diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/ide-probe.c linux-2.6.3-h8300/drivers/ide/ide-probe.c
--- linux-2.6.3/drivers/ide/ide-probe.c	2004-02-11 23:54:31.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/ide-probe.c	2004-02-20 17:45:25.000000000 +0900
@@ -983,7 +983,7 @@
 	unsigned int index;
 	ide_hwgroup_t *hwgroup;
 	ide_hwif_t *match = NULL;
-
+	int ide_regs_gap;
 
 	BUG_ON(in_interrupt());
 	BUG_ON(irqs_disabled());	
@@ -1102,10 +1102,11 @@
 		spin_unlock_irq(&ide_lock);
 	}
 
+	ide_regs_gap = hwif->io_ports[IDE_ERROR_OFFSET] - hwif->io_ports[IDE_DATA_OFFSET];
 #if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__)
 	printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name,
 		hwif->io_ports[IDE_DATA_OFFSET],
-		hwif->io_ports[IDE_DATA_OFFSET]+7,
+		hwif->io_ports[IDE_DATA_OFFSET] + ide_regs_gap * 8 - 1,
 		hwif->io_ports[IDE_CONTROL_OFFSET], hwif->irq);
 #elif defined(__sparc__)
 	printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %s", hwif->name,
diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/ide.c linux-2.6.3-h8300/drivers/ide/ide.c
--- linux-2.6.3/drivers/ide/ide.c	2004-02-20 01:08:02.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/ide.c	2004-02-20 17:46:52.000000000 +0900
@@ -2239,6 +2239,12 @@
 		pnpide_init(1);
 	}
 #endif /* CONFIG_BLK_DEV_IDEPNP */
+#if defined(__H8300H__) || defined(__H8300S__)
+        {
+		extern void h8300_ide_init(void);
+		h8300_ide_init();
+	}
+#endif /* defined(__H8300H__) || defined(__H8300S__) */
 }
 
 /*

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

* Re: H8/300 target support patch
  2004-02-20 12:28               ` Yoshinori Sato
@ 2004-02-20 15:25                 ` Bartlomiej Zolnierkiewicz
  2004-02-20 17:58                   ` Yoshinori Sato
  0 siblings, 1 reply; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-02-20 15:25 UTC (permalink / raw)
  To: Yoshinori Sato; +Cc: Benjamin Herrenschmidt, linux-ide

On Friday 20 of February 2004 13:28, Yoshinori Sato wrote:
> At Thu, 19 Feb 2004 17:34:49 +0100,
>
> Bartlomiej Zolnierkiewicz wrote:
> > Hi,
> >
> > Can you send updated patch?
> > I am lost in incremental changes. :-)
> >
> > Thanks.
>
> Difference with linux-2.6.3.

Hi,

Your patch lacks Kconfig entries for CONFIG_H8300_IDE_{BASE,ALT,IRQNO}
and they are not present in kernel 2.6.3?

Are you aware that you can't build kernel which will support both controllers?
Not an issue if you can't build kernel which supports both this boards. :-)

I cleaned up patch a bit, changelog:
- h8max_ide.c and aki3068_ide.c merged into ide-h8300.c
- added #if !defined(__H8300H__) to ide-proc.c
  (only place where ->OUTL is used, ->INL is unused in generic IDE code)
- __ide_outl() and __ide_inl() removed 
- redundant includes removed 
- init driver through initcall (so no need to make changes in ide.c)

Not tested et all, I don't know whether it compiles. :-)

 linux-2.6.3-root/drivers/ide/Makefile          |    5 
 linux-2.6.3-root/drivers/ide/h8300/ide-h8300.c |  139 +++++++++++++++++++++++++
 linux-2.6.3-root/drivers/ide/ide-probe.c       |    5 
 linux-2.6.3-root/drivers/ide/ide-proc.c        |    5 
 4 files changed, 149 insertions(+), 5 deletions(-)

diff -puN /dev/null drivers/ide/h8300/ide-h8300.c
--- /dev/null	2004-01-17 00:25:55.000000000 +0100
+++ linux-2.6.3-root/drivers/ide/h8300/ide-h8300.c	2004-02-20 16:01:08.884254448 +0100
@@ -0,0 +1,139 @@
+/****************************************************************************/
+/*
+ *  linux/drivers/ide/ide-h8300.c
+ *  H8MAX and aki3068net IDE Interfaces support
+ *
+ *  Copyright (C) 2003 Yoshinori Sato <ysato@users.sourceforge.jp>
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License.  See the file COPYING in the main directory of this archive for
+ *  more details.
+ *
+ */
+/****************************************************************************/
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/ide.h>
+#include <linux/interrupt.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/regs306x.h>
+
+/* IDE I/F configuration */
+
+#ifdef CONFIG_H8300H_H8MAX
+#define IDE_BASE 0x200000
+#define IDE_CTRL 0x60000c
+#define IDE_IRQ  EXT_IRQ5
+#endif
+
+#ifdef CONFIG_H8300H_AKI3068NET
+#define IDE_BASE CONFIG_H8300_IDE_BASE
+#define IDE_CTRL CONFIG_H8300_IDE_ALT
+#define IDE_IRQ  (EXT_IRQ0 + CONFIG_H8300_IDE_IRQNO)
+#endif
+
+#define IDE_DATA	0x00
+#define IDE_ERROR	0x02
+#define IDE_NSECTOR	0x04
+#define IDE_SECTOR	0x06
+#define IDE_LCYL	0x08
+#define IDE_HCYL	0x0A
+#define IDE_SELECT	0x0C
+#define IDE_STATUS	0x0E
+
+static void __init h8300_ide_ports(hw_regs_t *hw, unsigned long ioaddr)
+{
+	hw->io_ports[IDE_DATA_OFFSET]	 = ioaddr + IDE_DATA;
+	hw->io_ports[IDE_ERROR_OFFSET]	 = ioaddr + IDE_ERROR;
+	hw->io_ports[IDE_NSECTOR_OFFSET] = ioaddr + IDE_NSECTOR;
+	hw->io_ports[IDE_SECTOR_OFFSET]	 = ioaddr + IDE_SECTOR;
+	hw->io_ports[IDE_LCYL_OFFSET]	 = ioaddr + IDE_LCYL;
+	hw->io_ports[IDE_HCYL_OFFSET]	 = ioaddr + IDE_HCYL;
+	hw->io_ports[IDE_SELECT_OFFSET]	 = ioaddr + IDE_SELECT;
+	hw->io_ports[IDE_STATUS_OFFSET]	 = ioaddr + IDE_STATUS;
+}
+
+/* H8/300 IDE I/F I/O operations */
+
+static void __ide_outb(u8 d, unsigned long a)
+{
+	outb(d,a);
+}
+
+static void __ide_outbsync(ide_drive_t *drive, u8 d, unsigned long a)
+{
+	outb(d,a);
+}
+
+static u8 __ide_inb(unsigned long a)
+{
+	return inb(a);
+}
+
+static void __ide_outw(u16 d, unsigned long a)
+{
+	return outw(d,a);
+}
+
+static u16 __ide_inw(unsigned long a)
+{
+	return inw(a);
+}
+
+static void __ide_outsw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned short *bp = (unsigned short *)buf;
+	while(len--)
+		outw(*bp++,addr);
+}
+
+static void __ide_insw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned short *bp = (unsigned short *)buf;
+	while(len--)
+		*bp++ = inw(addr);
+}
+
+static void __init h8300_hwif_iops(ide_hwif_t *hwif)
+{
+	hwif->OUTB 	= __ide_outb;
+	hwif->OUTBSYNC	= __ide_outbsync;
+	hwif->OUTW	= __ide_outw;
+	hwif->OUTL	= NULL;
+	hwif->OUTSW	= __ide_outsw;
+	hwif->OUTSL	= NULL;
+	hwif->INB	= __ide_inb;
+	hwif->INW	= __ide_inw;
+	hwif->INL	= NULL;
+	hwif->INSW	= __ide_insw;
+	hwif->INSL	= NULL;
+}
+
+static int __init h8300_ide_init(void)
+{
+	hw_regs_t hw;
+	ide_hwif_t *hwif;
+
+#ifdef CONFIG_H8300H_AKI3068NET
+	volatile unsigned char *abwcr = (volatile unsigned char *)ABWCR;
+	volatile unsigned char *cscr = (volatile unsigned char *)CSCR;
+	*abwcr &= ~((1 << ((IDE_BASE >> 21) & 7)) | (1 << ((IDE_CTRL >> 21) & 7)));
+	*cscr  |= (1 << ((IDE_BASE >> 21) & 7)) | (1 << ((IDE_CTRL >> 21) & 7)) | 0x0f;
+#endif
+	memset(&hw, 0, sizeof(hw));
+
+	h8300_ide_ports(&hw, IDE_BASE);
+	hw.io_ports[IDE_CONTROL_OFFSET] = IDE_CTRL;
+	hw.irq = IDE_IRQ;
+
+	if (ide_register_hw(&hw, &hwif) != -1)
+		h8300_hwif_iops(hwif);
+
+	return 0;
+}
+
+module_init(h8300_ide_init);
diff -puN drivers/ide/ide-probe.c~ide_h8300 drivers/ide/ide-probe.c
--- linux-2.6.3/drivers/ide/ide-probe.c~ide_h8300	2004-02-20 16:05:11.900310392 +0100
+++ linux-2.6.3-root/drivers/ide/ide-probe.c	2004-02-20 16:07:23.736268280 +0100
@@ -965,7 +965,7 @@ static int init_irq (ide_hwif_t *hwif)
 	unsigned int index;
 	ide_hwgroup_t *hwgroup;
 	ide_hwif_t *match = NULL;
-
+	unsigned int regs_gap;		/* needed for H8/300 */
 
 	BUG_ON(in_interrupt());
 	BUG_ON(irqs_disabled());	
@@ -1084,10 +1084,11 @@ static int init_irq (ide_hwif_t *hwif)
 		spin_unlock_irq(&ide_lock);
 	}
 
+	regs_gap = hwif->io_ports[IDE_ERROR_OFFSET] - hwif->io_ports[IDE_DATA_OFFSET];
 #if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__)
 	printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name,
 		hwif->io_ports[IDE_DATA_OFFSET],
-		hwif->io_ports[IDE_DATA_OFFSET]+7,
+		hwif->io_ports[IDE_DATA_OFFSET] + regs_gap * 8 - 1,
 		hwif->io_ports[IDE_CONTROL_OFFSET], hwif->irq);
 #elif defined(__sparc__)
 	printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %s", hwif->name,
diff -puN drivers/ide/ide-proc.c~ide_h8300 drivers/ide/ide-proc.c
--- linux-2.6.3/drivers/ide/ide-proc.c~ide_h8300	2004-02-20 15:49:23.108548664 +0100
+++ linux-2.6.3-root/drivers/ide/ide-proc.c	2004-02-20 15:50:25.580051552 +0100
@@ -239,8 +239,7 @@ static int proc_ide_write_config
 					}
 #endif	/* CONFIG_BLK_DEV_IDEPCI */
 				} else {	/* not pci */
-#if !defined(__mc68000__) && !defined(CONFIG_APUS)
-
+#if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__H8300H__)
 /*
  * Geert Uytterhoeven
  *
@@ -268,7 +267,7 @@ static int proc_ide_write_config
 						case 8:	hwif->OUTL(val, reg);
 							break;
 					}
-#endif /* !__mc68000__ && !CONFIG_APUS */
+#endif /* !__mc68000__ && !CONFIG_APUS !__H8300H__ */
 				}
 			}
 		}
diff -puN drivers/ide/Makefile~ide_h8300 drivers/ide/Makefile
--- linux-2.6.3/drivers/ide/Makefile~ide_h8300	2004-02-20 15:51:48.649423088 +0100
+++ linux-2.6.3-root/drivers/ide/Makefile	2004-02-20 16:02:33.666365608 +0100
@@ -39,6 +39,11 @@ ide-core-$(CONFIG_BLK_DEV_IDE_PMAC)	+= p
 ide-core-$(CONFIG_BLK_DEV_IDE_SWARM)	+= ppc/swarm.o
 
 obj-$(CONFIG_BLK_DEV_IDE)		+= ide-core.o
+
+# there can be only one interface => no ordering problems
+ide-$(CONFIG_H8300H_H8MAX)		+= h8300/ide-h8300.o
+ide-$(CONFIG_H8300H_AKI3068NET)		+= h8300/ide-h8300.o
+
 obj-$(CONFIG_IDE_GENERIC)		+= ide-generic.o
 
 obj-$(CONFIG_BLK_DEV_IDEDISK)		+= ide-disk.o

_



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

* Re: H8/300 target support patch
  2004-02-20 15:25                 ` Bartlomiej Zolnierkiewicz
@ 2004-02-20 17:58                   ` Yoshinori Sato
  2004-02-20 18:42                     ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 21+ messages in thread
From: Yoshinori Sato @ 2004-02-20 17:58 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Benjamin Herrenschmidt, linux-ide

At Fri, 20 Feb 2004 16:25:42 +0100,
Bartlomiej Zolnierkiewicz wrote:
> 
> On Friday 20 of February 2004 13:28, Yoshinori Sato wrote:
> > At Thu, 19 Feb 2004 17:34:49 +0100,
> >
> > Bartlomiej Zolnierkiewicz wrote:
> > > Hi,
> > >
> > > Can you send updated patch?
> > > I am lost in incremental changes. :-)
> > >
> > > Thanks.
> >
> > Difference with linux-2.6.3.
> 
> Hi,
> 
> Your patch lacks Kconfig entries for CONFIG_H8300_IDE_{BASE,ALT,IRQNO}
> and they are not present in kernel 2.6.3?

It is not done merge yet.
I compound it with other corrections and will submit it.
 
> Are you aware that you can't build kernel which will support both controllers?
> Not an issue if you can't build kernel which supports both this boards. :-)
> 
> I cleaned up patch a bit, changelog:
> - h8max_ide.c and aki3068_ide.c merged into ide-h8300.c

Because there is a target different in implementation, 
correspondence becomes easy separated.

> - added #if !defined(__H8300H__) to ide-proc.c
>   (only place where ->OUTL is used, ->INL is unused in generic IDE code)
"__H8300S__" becomes the same condition, too.

> - __ide_outl() and __ide_inl() removed 
> - redundant includes removed 
> - init driver through initcall (so no need to make changes in ide.c)

It seems to have been overwritten with default_hwif_iops 
setting of h8300_hwif_iops in module_init.
 
> Not tested et all, I don't know whether it compiles. :-)
> 

-- 
Yoshinori Sato
<ysato@users.sourceforge.jp>

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

* Re: H8/300 target support patch
  2004-02-20 17:58                   ` Yoshinori Sato
@ 2004-02-20 18:42                     ` Bartlomiej Zolnierkiewicz
  2004-02-22 16:30                       ` Yoshinori Sato
  0 siblings, 1 reply; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-02-20 18:42 UTC (permalink / raw)
  To: Yoshinori Sato; +Cc: Benjamin Herrenschmidt, linux-ide

On Friday 20 of February 2004 18:58, Yoshinori Sato wrote:

> > - added #if !defined(__H8300H__) to ide-proc.c
> >   (only place where ->OUTL is used, ->INL is unused in generic IDE code)
>
> "__H8300S__" becomes the same condition, too.

Oh yes, it should be CONFIG_H8300.

> > - __ide_outl() and __ide_inl() removed
> > - redundant includes removed
> > - init driver through initcall (so no need to make changes in ide.c)
>
> It seems to have been overwritten with default_hwif_iops
> setting of h8300_hwif_iops in module_init.

Yep, h8300_ide_init() still should be called from ide.c.
(because ide_register_hw() checks "initialization" flag etc.)


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

* Re: H8/300 target support patch
  2004-02-20 18:42                     ` Bartlomiej Zolnierkiewicz
@ 2004-02-22 16:30                       ` Yoshinori Sato
  2004-02-22 17:08                         ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 21+ messages in thread
From: Yoshinori Sato @ 2004-02-22 16:30 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Benjamin Herrenschmidt, linux-ide

At Fri, 20 Feb 2004 19:42:00 +0100,
Bartlomiej Zolnierkiewicz wrote:
> 
> On Friday 20 of February 2004 18:58, Yoshinori Sato wrote:
> 
> > > - added #if !defined(__H8300H__) to ide-proc.c
> > >   (only place where ->OUTL is used, ->INL is unused in generic IDE code)
> >
> > "__H8300S__" becomes the same condition, too.
> 
> Oh yes, it should be CONFIG_H8300.
> 
> > > - __ide_outl() and __ide_inl() removed
> > > - redundant includes removed
> > > - init driver through initcall (so no need to make changes in ide.c)
> >
> > It seems to have been overwritten with default_hwif_iops
> > setting of h8300_hwif_iops in module_init.
> 
> Yep, h8300_ide_init() still should be called from ide.c.
> (because ide_register_hw() checks "initialization" flag etc.)
> 

I corrected it to initialize it with ide_init_default_hwifs.
A correction of ide.c becomes needless.

Because h8300-iops.c might change every a target, 
I arranged with the other directory.

diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/Makefile linux-2.6.3-h8300/drivers/ide/Makefile
--- linux-2.6.3/drivers/ide/Makefile	2004-02-20 01:08:02.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/Makefile	2004-02-20 17:42:40.000000000 +0900
@@ -46,5 +46,5 @@
 obj-$(CONFIG_BLK_DEV_IDETAPE)		+= ide-tape.o
 obj-$(CONFIG_BLK_DEV_IDEFLOPPY)		+= ide-floppy.o
 
-obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ arm/
+obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ arm/ h8300/
 obj-$(CONFIG_BLK_DEV_HD)		+= legacy/
diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/h8300/Makefile linux-2.6.3-h8300/drivers/ide/h8300/Makefile
--- linux-2.6.3/drivers/ide/h8300/Makefile	1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/h8300/Makefile	2004-02-23 00:58:43.000000000 +0900
@@ -0,0 +1,2 @@
+obj-$(CONFIG_H8300H_H8MAX) := h8300-iops.o
+obj-$(CONFIG_H8300H_AKI3068NET) := h8300-iops.o
diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/h8300/h8300-iops.c linux-2.6.3-h8300/drivers/ide/h8300/h8300-iops.c
--- linux-2.6.3/drivers/ide/h8300/h8300-iops.c	1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/h8300/h8300-iops.c	2004-02-23 00:53:24.000000000 +0900
@@ -0,0 +1,107 @@
+/* H8/300 IDE I/F I/O operations */
+
+/*
+ support target
+
+ AE-3068/AE-3069 + IDE Expand
+ H8MAX
+*/
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/ide.h>
+#include <asm/io.h>
+
+static void __ide_outb(u8 d, unsigned long a)
+{
+	outb(d,a); 
+}
+
+static void __ide_outbsync(ide_drive_t *drive, u8 d, unsigned long a)
+{
+	outb(d,a); 
+}
+
+static u8 __ide_inb(unsigned long a)
+{
+	return inb(a);
+}
+
+static void __ide_outw(u16 d, unsigned long a)
+{
+	return outw(d,a);
+}
+
+static u16 __ide_inw(unsigned long a)
+{
+	return inw(a);
+}
+
+static void __ide_outl(u32 d, unsigned long a)
+{
+}
+
+static u32 __ide_inl(unsigned long a)
+{
+	return 0xffffffffUL;
+}
+
+static void __ide_outsw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned short *bp = (unsigned short *)buf;
+	while(len--)
+		outw(*bp++,addr);
+}
+
+static void __ide_insw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned short *bp = (unsigned short *)buf;
+	while(len--)
+		*bp++ = inw(addr);
+}
+
+static void __init h8300_hwif_iops(ide_hwif_t *hwif)
+{
+	hwif->OUTB 	= __ide_outb;
+	hwif->OUTBSYNC	= __ide_outbsync;
+	hwif->OUTW	= __ide_outw;
+	hwif->OUTL	= __ide_outl;
+	hwif->OUTSW	= __ide_outsw;
+	hwif->OUTSL	= NULL;
+	hwif->INB	= __ide_inb;
+	hwif->INW	= __ide_inw;
+	hwif->INL	= __ide_inl;
+	hwif->INSW	= __ide_insw;
+	hwif->INSL	= NULL;
+}
+
+void __init ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
+				unsigned long ctrl_port, int *irq)
+{
+	hw->io_ports[IDE_DATA_OFFSET]	 = data_port + IDE_DATA;
+	hw->io_ports[IDE_ERROR_OFFSET]	 = data_port + IDE_ERROR;
+	hw->io_ports[IDE_NSECTOR_OFFSET] = data_port + IDE_NSECTOR;
+	hw->io_ports[IDE_SECTOR_OFFSET]	 = data_port + IDE_SECTOR;
+	hw->io_ports[IDE_LCYL_OFFSET]	 = data_port + IDE_LCYL;
+	hw->io_ports[IDE_HCYL_OFFSET]	 = data_port + IDE_HCYL;
+	hw->io_ports[IDE_SELECT_OFFSET]	 = data_port + IDE_SELECT;
+	hw->io_ports[IDE_STATUS_OFFSET]	 = data_port + IDE_STATUS;
+	hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
+	hw->irq = *irq;
+}
+
+void __init ide_init_default_hwifs(void)
+{
+	hw_regs_t hw;
+	ide_hwif_t *hwif;
+	int irq = IDE_IRQ;
+
+	H8300_IDE_SETUP();
+
+	memset(&hw,0,sizeof(hw));
+
+	ide_init_hwif_ports(&hw, IDE_BASE,IDE_CTRL,&irq);
+	ide_register_hw(&hw, &hwif);
+	h8300_hwif_iops(hwif);
+}
+
diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/ide-probe.c linux-2.6.3-h8300/drivers/ide/ide-probe.c
--- linux-2.6.3/drivers/ide/ide-probe.c	2004-02-11 23:54:31.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/ide-probe.c	2004-02-20 17:45:25.000000000 +0900
@@ -983,7 +983,7 @@
 	unsigned int index;
 	ide_hwgroup_t *hwgroup;
 	ide_hwif_t *match = NULL;
-
+	unsigned int ide_regs_gap;	/* needed for H8/300 */
 
 	BUG_ON(in_interrupt());
 	BUG_ON(irqs_disabled());	
@@ -1102,11 +1102,12 @@
 		spin_unlock_irq(&ide_lock);
 	}
 
+	ide_regs_gap = hwif->io_ports[IDE_ERROR_OFFSET] - hwif->io_ports[IDE_DATA_OFFSET];
 #if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__)
 	printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name,
 		hwif->io_ports[IDE_DATA_OFFSET],
-		hwif->io_ports[IDE_DATA_OFFSET]+7,
+		hwif->io_ports[IDE_DATA_OFFSET] + ide_regs_gap * 8 - 1,
 		hwif->io_ports[IDE_CONTROL_OFFSET], hwif->irq);
 #elif defined(__sparc__)
 	printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %s", hwif->name,
diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/ide-proc.c linux-2.6.3-h8300/drivers/ide/ide-proc.c
--- linux-2.6.3/drivers/ide/ide-proc.c	2004-02-20 15:49:23.108548664 +0100
+++ linux-2.6.3-h8300/drivers/ide/ide-proc.c	2004-02-20 15:50:25.580051552 +0100
@@ -239,8 +239,7 @@ static int proc_ide_write_config
 					}
 #endif	/* CONFIG_BLK_DEV_IDEPCI */
 				} else {	/* not pci */
-#if !defined(__mc68000__) && !defined(CONFIG_APUS)
-
+#if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__H8300H__) && !defined(__H8300S__)
 /*
  * Geert Uytterhoeven
  *
@@ -268,7 +267,7 @@ static int proc_ide_write_config
 						case 8:	hwif->OUTL(val, reg);
 							break;
 					}
-#endif /* !__mc68000__ && !CONFIG_APUS */
+#endif /* !__mc68000__ && !CONFIG_APUS !__H8300H__ && !__H8300S__ */
 				}
 			}
 		}
diff -X .exclude-diff -Nru linux-2.6.3/include/asm-h8300/ide.h linux-2.6.3-h8300/include/asm-h8300/ide.h
--- linux-2.6.3/include/asm-h8300/ide.h	19 Feb 2004 17:43:11 -0000	1.5
+++ linux-2.6.3-h8300/include/asm-h8300/ide.h	22 Feb 2004 16:15:49 -0000
@@ -16,19 +16,26 @@
 #ifdef __KERNEL__
 /****************************************************************************/
 
-void h8300_ide_print_resource(char *name, hw_regs_t *hw);
-static inline int ide_default_irq(unsigned long base) { return 0; };
-static inline unsigned long ide_default_io_base(int index) { return 0; };
+#define H8300_IDE_DEFINE
+#include <asm/machine-depend.h>
+#undef  H8300_IDE_DEFINE
 
-static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
-	 unsigned long ctrl_port, int *irq)
+static __inline__ int ide_default_irq(unsigned long base)
 {
-}
+	return IDE_IRQ;
+};
 
-
-static inline void ide_init_default_hwifs(void)
+static __inline__ unsigned long ide_default_io_base(int index)
 {
-}
+	if (index == 0)
+		return IDE_BASE;
+	else
+		return 0;
+};
+
+void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
+			 unsigned long ctrl_port, int *irq);
+void ide_init_default_hwifs(void);
 
 #define MAX_HWIFS	1
 
-- 
Yoshinori Sato
<ysato@users.sourceforge.jp>

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

* Re: H8/300 target support patch
  2004-02-22 16:30                       ` Yoshinori Sato
@ 2004-02-22 17:08                         ` Bartlomiej Zolnierkiewicz
  2004-02-22 17:28                           ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-02-22 17:08 UTC (permalink / raw)
  To: Yoshinori Sato; +Cc: Benjamin Herrenschmidt, linux-ide

On Sunday 22 of February 2004 17:30, Yoshinori Sato wrote:
> At Fri, 20 Feb 2004 19:42:00 +0100,
>
> Bartlomiej Zolnierkiewicz wrote:
> > On Friday 20 of February 2004 18:58, Yoshinori Sato wrote:
> > > > - added #if !defined(__H8300H__) to ide-proc.c
> > > >   (only place where ->OUTL is used, ->INL is unused in generic IDE
> > > > code)
> > >
> > > "__H8300S__" becomes the same condition, too.
> >
> > Oh yes, it should be CONFIG_H8300.
> >
> > > > - __ide_outl() and __ide_inl() removed
> > > > - redundant includes removed
> > > > - init driver through initcall (so no need to make changes in ide.c)
> > >
> > > It seems to have been overwritten with default_hwif_iops
> > > setting of h8300_hwif_iops in module_init.
> >
> > Yep, h8300_ide_init() still should be called from ide.c.
> > (because ide_register_hw() checks "initialization" flag etc.)
>
> I corrected it to initialize it with ide_init_default_hwifs.
> A correction of ide.c becomes needless.

NO!!!  ide_init_default_hwifs() should DIE!
The same goes for ide_default_{irq,io_base}().

They are not needed - you have driver(s) for H8/300 IDE controllers!

> Because h8300-iops.c might change every a target,
> I arranged with the other directory.

Please explain.

> +static u16 __ide_inw(unsigned long a)
> +{
> +	return inw(a);
> +}
> +
> +static void __ide_outl(u32 d, unsigned long a)
> +{
> +}
> +
> +static u32 __ide_inl(unsigned long a)
> +{
> +	return 0xffffffffUL;
> +}

__ide_outl() and __inl() are really not needed

> +void __init ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
> +				unsigned long ctrl_port, int *irq)

This should be static as it was before.

> -void h8300_ide_print_resource(char *name, hw_regs_t *hw);
> -static inline int ide_default_irq(unsigned long base) { return 0; };
> -static inline unsigned long ide_default_io_base(int index) { return 0; };
> +#define H8300_IDE_DEFINE
> +#include <asm/machine-depend.h>
> +#undef  H8300_IDE_DEFINE

What's that?
If you want to choose between H8MAX and IDE expand for AE-3068/9 just do this
using arch specific Kconfig or (better in my opinion) in drivers/ide/Kconfig.

> -static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, unsigned long
> data_port, -	 unsigned long ctrl_port, int *irq)
> +static __inline__ int ide_default_irq(unsigned long base)
>  {
> -}
> +	return IDE_IRQ;
> +};
>
> -
> -static inline void ide_init_default_hwifs(void)
> +static __inline__ unsigned long ide_default_io_base(int index)
>  {
> -}
> +	if (index == 0)
> +		return IDE_BASE;
> +	else
> +		return 0;
> +};
> +
> +void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
> +			 unsigned long ctrl_port, int *irq);
> +void ide_init_default_hwifs(void);

This is just wrong and redundant.
Please, no more <asm/ide.h> crap for new IDE drivers.

Cheers,
--bart


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

* Re: H8/300 target support patch
  2004-02-22 17:08                         ` Bartlomiej Zolnierkiewicz
@ 2004-02-22 17:28                           ` Bartlomiej Zolnierkiewicz
  2004-02-26 16:46                             ` Yoshinori Sato
  0 siblings, 1 reply; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-02-22 17:28 UTC (permalink / raw)
  To: Yoshinori Sato; +Cc: Benjamin Herrenschmidt, linux-ide

On Sunday 22 of February 2004 18:08, Bartlomiej Zolnierkiewicz wrote:

> > I corrected it to initialize it with ide_init_default_hwifs.
> > A correction of ide.c becomes needless.
>
> NO!!!  ide_init_default_hwifs() should DIE!
> The same goes for ide_default_{irq,io_base}().
>
> They are not needed - you have driver(s) for H8/300 IDE controllers!

It should be like that:

You should have host drivers for your IDE controllers,
not inline functions for ide.c and ide-probe.c.


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

* Re: H8/300 target support patch
  2004-02-22 17:28                           ` Bartlomiej Zolnierkiewicz
@ 2004-02-26 16:46                             ` Yoshinori Sato
  2004-02-26 19:26                               ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 21+ messages in thread
From: Yoshinori Sato @ 2004-02-26 16:46 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Benjamin Herrenschmidt, linux-ide

At Sun, 22 Feb 2004 18:28:18 +0100,
Bartlomiej Zolnierkiewicz wrote:
> 
> On Sunday 22 of February 2004 18:08, Bartlomiej Zolnierkiewicz wrote:
> 
> > > I corrected it to initialize it with ide_init_default_hwifs.
> > > A correction of ide.c becomes needless.
> >
> > NO!!!  ide_init_default_hwifs() should DIE!
> > The same goes for ide_default_{irq,io_base}().
> >
> > They are not needed - you have driver(s) for H8/300 IDE controllers!
> 
> It should be like that:
> 
> You should have host drivers for your IDE controllers,
> not inline functions for ide.c and ide-probe.c.
> 

I tuned to a driver of PC/AT wherever practicable.
Examination is necessary for a call method of h8300_hwif_iops.
CONFIG_H8300_IDE_foo defines it with arch/h8300/Kconfig.

diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/Makefile linux-2.6.3-h8300/drivers/ide/Makefile
--- linux-2.6.3/drivers/ide/Makefile	2004-02-20 01:08:02.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/Makefile	2004-02-20 17:42:40.000000000 +0900
@@ -46,5 +46,5 @@
 obj-$(CONFIG_BLK_DEV_IDETAPE)		+= ide-tape.o
 obj-$(CONFIG_BLK_DEV_IDEFLOPPY)		+= ide-floppy.o
 
-obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ arm/
+obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ arm/ h8300/
 obj-$(CONFIG_BLK_DEV_HD)		+= legacy/
diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/h8300/Makefile linux-2.6.3-h8300/drivers/ide/h8300/Makefile
--- linux-2.6.3/drivers/ide/h8300/Makefile	1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/h8300/Makefile	2004-02-23 00:58:43.000000000 +0900
@@ -0,0 +1,2 @@
+obj-$(CONFIG_H8300H_H8MAX) := h8300-iops.o
+obj-$(CONFIG_H8300H_AKI3068NET) := h8300-iops.o
diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/h8300/h8300-iops.c linux-2.6.3-h8300/drivers/ide/h8300/h8300-iops.c
--- linux-2.6.3/drivers/ide/h8300/h8300-iops.c	1970-01-01 09:00:00.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/h8300/h8300-iops.c	2004-02-27 01:08:20.000000000 +0900
@@ -0,0 +1,67 @@
+/* H8/300 IDE I/F I/O operations */
+
+/*
+ support target
+
+ AE-3068/AE-3069 + IDE Expand
+ H8MAX
+*/
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/ide.h>
+#include <asm/io.h>
+
+static void __ide_outb(u8 d, unsigned long a)
+{
+	outb(d,a); 
+}
+
+static void __ide_outbsync(ide_drive_t *drive, u8 d, unsigned long a)
+{
+	outb(d,a); 
+}
+
+static u8 __ide_inb(unsigned long a)
+{
+	return inb(a);
+}
+
+static void __ide_outw(u16 d, unsigned long a)
+{
+	return outw(d,a);
+}
+
+static u16 __ide_inw(unsigned long a)
+{
+	return inw(a);
+}
+
+static void __ide_outsw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned short *bp = (unsigned short *)buf;
+	while(len--)
+		outw(*bp++,addr);
+}
+
+static void __ide_insw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned short *bp = (unsigned short *)buf;
+	while(len--)
+		*bp++ = inw(addr);
+}
+
+void h8300_hwif_iops(ide_hwif_t *hwif)
+{
+	hwif->OUTB 	= __ide_outb;
+	hwif->OUTBSYNC	= __ide_outbsync;
+	hwif->OUTW	= __ide_outw;
+	hwif->OUTL	= NULL;
+	hwif->OUTSW	= __ide_outsw;
+	hwif->OUTSL	= NULL;
+	hwif->INB	= __ide_inb;
+	hwif->INW	= __ide_inw;
+	hwif->INL	= NULL;
+	hwif->INSW	= __ide_insw;
+	hwif->INSL	= NULL;
+}
diff -X .exclude-diff -Nru linux-2.6.3/drivers/ide/ide-iops.c linux-2.6.3-h8300/drivers/ide/ide-iops.c
--- linux-2.6.3/drivers/ide/ide-iops.c	2004-02-20 01:08:02.000000000 +0900
+++ linux-2.6.3-h8300/drivers/ide/ide-iops.c	2004-02-27 01:09:21.000000000 +0900
@@ -31,6 +31,7 @@
  *	Conventional PIO operations for ATA devices
  */
 
+#if !defined(__H8300H__) && !defined(__H8300S__) /* not use H8/300 target */
 static u8 ide_inb (unsigned long port)
 {
 	return (u8) inb(port);
@@ -88,9 +158,14 @@
 {
 	outsl(port, addr, count);
 }
+#endif /* !defined(__H8300H__) && !defined(__H8300S__) */
 
 void default_hwif_iops (ide_hwif_t *hwif)
 {
+#if defined(__H8300H__) || defined(__H8300S__)
+	void h8300_hwif_iops (ide_hwif_t *hwif);
+	h8300_hwif_iops(hwif);
+#else
 	hwif->OUTB	= ide_outb;
 	hwif->OUTBSYNC	= ide_outbsync;
 	hwif->OUTW	= ide_outw;
@@ -102,6 +177,7 @@
 	hwif->INL	= ide_inl;
 	hwif->INSW	= ide_insw;
 	hwif->INSL	= ide_insl;
+#endif
 }
 
 EXPORT_SYMBOL(default_hwif_iops);
diff -X .exclude-diff -Nru linux-2.6.3/include/asm-h8300/ide.h linux-2.6.3-h8300/include/asm-h8300/ide.h
--- linux-2.6.3/include/asm-h8300/ide.h	2004-01-09 15:59:09.000000000 +0900
+++ linux-2.6.3-h8300/include/asm-h8300/ide.h	2004-02-27 01:10:27.000000000 +0900
@@ -16,20 +16,61 @@
 #ifdef __KERNEL__
 /****************************************************************************/
 
-void h8300_ide_print_resource(char *name, hw_regs_t *hw);
-static inline int ide_default_irq(unsigned long base) { return 0; };
-static inline ide_ioreg_t ide_default_io_base(int index) { return 0; };
+#define IDE_DATA	0x00
+#define IDE_ERROR	0x02
+#define IDE_NSECTOR	0x04
+#define IDE_SECTOR	0x06
+#define IDE_LCYL	0x08
+#define IDE_HCYL	0x0A
+#define IDE_SELECT	0x0C
+#define IDE_STATUS	0x0E
+
+static __inline__ int ide_default_irq(unsigned long base)
+{
+	return (base == CONFIG_H8300_IDE_BASE)?(CONFIG_H8300_IDE_IRQ + 12):0;
+};
+
+static __inline__ unsigned long ide_default_io_base(int index)
+{
+	return (index == 0)?CONFIG_H8300_IDE_BASE:0UL;
+};
 
 static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
-	 unsigned long ctrl_port, int *irq)
+					   unsigned long ctrl_port, int *irq)
 {
+	hw->io_ports[IDE_DATA_OFFSET]	 = data_port + IDE_DATA;
+	hw->io_ports[IDE_ERROR_OFFSET]	 = data_port + IDE_ERROR;
+	hw->io_ports[IDE_NSECTOR_OFFSET] = data_port + IDE_NSECTOR;
+	hw->io_ports[IDE_SECTOR_OFFSET]	 = data_port + IDE_SECTOR;
+	hw->io_ports[IDE_LCYL_OFFSET]	 = data_port + IDE_LCYL;
+	hw->io_ports[IDE_HCYL_OFFSET]	 = data_port + IDE_HCYL;
+	hw->io_ports[IDE_SELECT_OFFSET]	 = data_port + IDE_SELECT;
+	hw->io_ports[IDE_STATUS_OFFSET]	 = data_port + IDE_STATUS;
 }
 
+#define AREABIT(addr) (1 << (((addr) >> 21) & 7))
 
-static inline void ide_init_default_hwifs(void)
+static __inline__ void ide_init_default_hwifs(void)
 {
+	hw_regs_t hw;
+
+#if defined(CONFIG_H8300_AKI3068NET)
+	{
+		volatile unsigned char *abwcr = (volatile unsigned char *)ABWCR;
+		volatile unsigned char *cscr = (volatile unsigned char *)CSCR;
+		*abwcr &= ~(AREABIT(CONFIG_H8300_IDE_BASE) | AREABIT(CONFIG_H8300_IDE_ALT));
+		*cscr  |= (AREABIT(CONFIG_H8300_IDE_BASE) | AREABIT(CONFIG_H8300_IDE_ALT)) | 0x0f;
+	}
+#endif
+	memset(&hw,0,sizeof(hw));
+
+	ide_init_hwif_ports(&hw, ide_default_io_base(0), 0, NULL);
+	hw.irq = ide_default_irq(ide_default_io_base(0));
+
+	ide_register_hw(&hw, NULL);
 }
 
+
 #define MAX_HWIFS	1

-- 
Yoshinori Sato
<ysato@users.sourceforge.jp>

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

* Re: H8/300 target support patch
  2004-02-26 16:46                             ` Yoshinori Sato
@ 2004-02-26 19:26                               ` Bartlomiej Zolnierkiewicz
  2004-02-28 17:02                                 ` Yoshinori Sato
  0 siblings, 1 reply; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-02-26 19:26 UTC (permalink / raw)
  To: Yoshinori Sato; +Cc: Benjamin Herrenschmidt, linux-ide

On Thursday 26 of February 2004 17:46, Yoshinori Sato wrote:
> At Sun, 22 Feb 2004 18:28:18 +0100,
>
> Bartlomiej Zolnierkiewicz wrote:
> > On Sunday 22 of February 2004 18:08, Bartlomiej Zolnierkiewicz wrote:
> > > > I corrected it to initialize it with ide_init_default_hwifs.
> > > > A correction of ide.c becomes needless.
> > >
> > > NO!!!  ide_init_default_hwifs() should DIE!
> > > The same goes for ide_default_{irq,io_base}().
> > >
> > > They are not needed - you have driver(s) for H8/300 IDE controllers!
> >
> > It should be like that:
> >
> > You should have host drivers for your IDE controllers,
> > not inline functions for ide.c and ide-probe.c.
>
> I tuned to a driver of PC/AT wherever practicable.

Just because original/legacy PC/AT driver is braindamaged (and dated)
doesn't mean your code should be, does it?  Hiding driver's code into
asm/ide.h causes MAJOR problems for IDE code reorganization.

> Examination is necessary for a call method of h8300_hwif_iops.

All ide-iops.c #ifdef-s won't be needed if you separate you driver
properly from asm/ide.h (thus overriding default_hwif_iops() ops
by ones used by your driver).

Please revert to putting your code into ide/h8300/.

Thanks.


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

* Re: H8/300 target support patch
  2004-02-26 19:26                               ` Bartlomiej Zolnierkiewicz
@ 2004-02-28 17:02                                 ` Yoshinori Sato
  2004-02-28 17:55                                   ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 21+ messages in thread
From: Yoshinori Sato @ 2004-02-28 17:02 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: Benjamin Herrenschmidt, linux-ide

At Thu, 26 Feb 2004 20:26:51 +0100,
Bartlomiej Zolnierkiewicz wrote:
> 
> On Thursday 26 of February 2004 17:46, Yoshinori Sato wrote:
> > At Sun, 22 Feb 2004 18:28:18 +0100,
> >
> > Bartlomiej Zolnierkiewicz wrote:
> > > On Sunday 22 of February 2004 18:08, Bartlomiej Zolnierkiewicz wrote:
> > > > > I corrected it to initialize it with ide_init_default_hwifs.
> > > > > A correction of ide.c becomes needless.
> > > >
> > > > NO!!!  ide_init_default_hwifs() should DIE!
> > > > The same goes for ide_default_{irq,io_base}().
> > > >
> > > > They are not needed - you have driver(s) for H8/300 IDE controllers!
> > >
> > > It should be like that:
> > >
> > > You should have host drivers for your IDE controllers,
> > > not inline functions for ide.c and ide-probe.c.
> >
> > I tuned to a driver of PC/AT wherever practicable.
> 
> Just because original/legacy PC/AT driver is braindamaged (and dated)
> doesn't mean your code should be, does it?  Hiding driver's code into
> asm/ide.h causes MAJOR problems for IDE code reorganization.
> 
> > Examination is necessary for a call method of h8300_hwif_iops.
> 
> All ide-iops.c #ifdef-s won't be needed if you separate you driver
> properly from asm/ide.h (thus overriding default_hwif_iops() ops
> by ones used by your driver).
> 
> Please revert to putting your code into ide/h8300/.
> 

I did overriding of default_hwif_iops in form to replace obj because 
it was not possible well.

It is difference m with linux-2.6.4-rc1.
Do not change asm/ide.h.

Index: drivers/ide/Makefile
===================================================================
RCS file: /var/lib/cvs/linux-2.6/drivers/ide/Makefile,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 Makefile
--- a/drivers/ide/Makefile	19 Feb 2004 16:10:32 -0000	1.1.1.7
+++ b/drivers/ide/Makefile	28 Feb 2004 15:20:10 -0000
@@ -16,6 +16,10 @@
 ide-core-y += ide.o ide-default.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \
 	ide-taskfile.o
 
+ifndef CONFIG_H8300
+ide-core-y += ide-lowio.o
+endif
+
 ide-core-$(CONFIG_BLK_DEV_CMD640)	+= pci/cmd640.o
 
 # Core IDE code - must come before legacy
@@ -46,5 +50,5 @@
 obj-$(CONFIG_BLK_DEV_IDETAPE)		+= ide-tape.o
 obj-$(CONFIG_BLK_DEV_IDEFLOPPY)		+= ide-floppy.o
 
-obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ arm/
+obj-$(CONFIG_BLK_DEV_IDE)		+= legacy/ arm/ h8300/
 obj-$(CONFIG_BLK_DEV_HD)		+= legacy/
Index: drivers/ide/ide-iops.c
===================================================================
RCS file: /var/lib/cvs/linux-2.6/drivers/ide/ide-iops.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 ide-iops.c
--- a/drivers/ide/ide-iops.c	19 Feb 2004 16:10:32 -0000	1.1.1.3
+++ b/drivers/ide/ide-iops.c	28 Feb 2004 15:19:35 -0000
@@ -30,160 +30,6 @@
 #include <asm/io.h>
 #include <asm/bitops.h>
 
-/*
- *	Conventional PIO operations for ATA devices
- */
-
-static u8 ide_inb (unsigned long port)
-{
-	return (u8) inb(port);
-}
-
-static u16 ide_inw (unsigned long port)
-{
-	return (u16) inw(port);
-}
-
-static void ide_insw (unsigned long port, void *addr, u32 count)
-{
-	return insw(port, addr, count);
-}
-
-static u32 ide_inl (unsigned long port)
-{
-	return (u32) inl(port);
-}
-
-static void ide_insl (unsigned long port, void *addr, u32 count)
-{
-	insl(port, addr, count);
-}
-
-static void ide_outb (u8 val, unsigned long port)
-{
-	outb(val, port);
-}
-
-static void ide_outbsync (ide_drive_t *drive, u8 addr, unsigned long port)
-{
-	outb(addr, port);
-}
-
-static void ide_outw (u16 val, unsigned long port)
-{
-	outw(val, port);
-}
-
-static void ide_outsw (unsigned long port, void *addr, u32 count)
-{
-	outsw(port, addr, count);
-}
-
-static void ide_outl (u32 val, unsigned long port)
-{
-	outl(val, port);
-}
-
-static void ide_outsl (unsigned long port, void *addr, u32 count)
-{
-	outsl(port, addr, count);
-}
-
-void default_hwif_iops (ide_hwif_t *hwif)
-{
-	hwif->OUTB	= ide_outb;
-	hwif->OUTBSYNC	= ide_outbsync;
-	hwif->OUTW	= ide_outw;
-	hwif->OUTL	= ide_outl;
-	hwif->OUTSW	= ide_outsw;
-	hwif->OUTSL	= ide_outsl;
-	hwif->INB	= ide_inb;
-	hwif->INW	= ide_inw;
-	hwif->INL	= ide_inl;
-	hwif->INSW	= ide_insw;
-	hwif->INSL	= ide_insl;
-}
-
-EXPORT_SYMBOL(default_hwif_iops);
-
-/*
- *	MMIO operations, typically used for SATA controllers
- */
-
-static u8 ide_mm_inb (unsigned long port)
-{
-	return (u8) readb(port);
-}
-
-static u16 ide_mm_inw (unsigned long port)
-{
-	return (u16) readw(port);
-}
-
-static void ide_mm_insw (unsigned long port, void *addr, u32 count)
-{
-	__ide_mm_insw(port, addr, count);
-}
-
-static u32 ide_mm_inl (unsigned long port)
-{
-	return (u32) readl(port);
-}
-
-static void ide_mm_insl (unsigned long port, void *addr, u32 count)
-{
-	__ide_mm_insl(port, addr, count);
-}
-
-static void ide_mm_outb (u8 value, unsigned long port)
-{
-	writeb(value, port);
-}
-
-static void ide_mm_outbsync (ide_drive_t *drive, u8 value, unsigned long port)
-{
-	writeb(value, port);	
-}
-
-static void ide_mm_outw (u16 value, unsigned long port)
-{
-	writew(value, port);
-}
-
-static void ide_mm_outsw (unsigned long port, void *addr, u32 count)
-{
-	__ide_mm_outsw(port, addr, count);
-}
-
-static void ide_mm_outl (u32 value, unsigned long port)
-{
-	writel(value, port);
-}
-
-static void ide_mm_outsl (unsigned long port, void *addr, u32 count)
-{
-	__ide_mm_outsl(port, addr, count);
-}
-
-void default_hwif_mmiops (ide_hwif_t *hwif)
-{
-	hwif->OUTB	= ide_mm_outb;
-	/* Most systems will need to override OUTBSYNC, alas however
-	   this one is controller specific! */
-	hwif->OUTBSYNC	= ide_mm_outbsync;
-	hwif->OUTW	= ide_mm_outw;
-	hwif->OUTL	= ide_mm_outl;
-	hwif->OUTSW	= ide_mm_outsw;
-	hwif->OUTSL	= ide_mm_outsl;
-	hwif->INB	= ide_mm_inb;
-	hwif->INW	= ide_mm_inw;
-	hwif->INL	= ide_mm_inl;
-	hwif->INSW	= ide_mm_insw;
-	hwif->INSL	= ide_mm_insl;
-}
-
-EXPORT_SYMBOL(default_hwif_mmiops);
-
 void default_hwif_transport (ide_hwif_t *hwif)
 {
 	hwif->ata_input_data		= ata_input_data;
Index: drivers/ide/ide-lowio.c
===================================================================
RCS file: drivers/ide/ide-lowio.c
diff -N drivers/ide/ide-lowio.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ b/drivers/ide/ide-lowio.c	28 Feb 2004 14:24:27 -0000
@@ -0,0 +1,231 @@
+/*
+ * linux/drivers/ide/ide-lowio.c
+ *
+ * IDE I/F Lowlevel I/O functions
+ */
+
+#include <linux/ide.h>
+#include <asm/io.h>
+
+/*
+ *	IDE operator we assign to an unplugged device so that
+ *	we don't trash new hardware assigned the same resources
+ */
+ 
+static u8 ide_unplugged_inb (unsigned long port)
+{
+	return 0xFF;
+}
+
+static u16 ide_unplugged_inw (unsigned long port)
+{
+	return 0xFFFF;
+}
+
+static void ide_unplugged_insw (unsigned long port, void *addr, u32 count)
+{
+}
+
+static u32 ide_unplugged_inl (unsigned long port)
+{
+	return 0xFFFFFFFF;
+}
+
+static void ide_unplugged_insl (unsigned long port, void *addr, u32 count)
+{
+}
+
+static void ide_unplugged_outb (u8 val, unsigned long port)
+{
+}
+
+static void ide_unplugged_outbsync (ide_drive_t *drive, u8 addr, unsigned long port)
+{
+}
+
+static void ide_unplugged_outw (u16 val, unsigned long port)
+{
+}
+
+static void ide_unplugged_outsw (unsigned long port, void *addr, u32 count)
+{
+}
+
+static void ide_unplugged_outl (u32 val, unsigned long port)
+{
+}
+
+static void ide_unplugged_outsl (unsigned long port, void *addr, u32 count)
+{
+}
+
+void unplugged_hwif_iops (ide_hwif_t *hwif)
+{
+	hwif->OUTB	= ide_unplugged_outb;
+	hwif->OUTBSYNC	= ide_unplugged_outbsync;
+	hwif->OUTW	= ide_unplugged_outw;
+	hwif->OUTL	= ide_unplugged_outl;
+	hwif->OUTSW	= ide_unplugged_outsw;
+	hwif->OUTSL	= ide_unplugged_outsl;
+	hwif->INB	= ide_unplugged_inb;
+	hwif->INW	= ide_unplugged_inw;
+	hwif->INL	= ide_unplugged_inl;
+	hwif->INSW	= ide_unplugged_insw;
+	hwif->INSL	= ide_unplugged_insl;
+}
+
+EXPORT_SYMBOL(unplugged_hwif_iops);
+
+/*
+ *	Conventional PIO operations for ATA devices
+ */
+
+static u8 ide_inb (unsigned long port)
+{
+	return (u8) inb(port);
+}
+
+static u16 ide_inw (unsigned long port)
+{
+	return (u16) inw(port);
+}
+
+static void ide_insw (unsigned long port, void *addr, u32 count)
+{
+	return insw(port, addr, count);
+}
+
+static u32 ide_inl (unsigned long port)
+{
+	return (u32) inl(port);
+}
+
+static void ide_insl (unsigned long port, void *addr, u32 count)
+{
+	insl(port, addr, count);
+}
+
+static void ide_outb (u8 val, unsigned long port)
+{
+	outb(val, port);
+}
+
+static void ide_outbsync (ide_drive_t *drive, u8 addr, unsigned long port)
+{
+	outb(addr, port);
+}
+
+static void ide_outw (u16 val, unsigned long port)
+{
+	outw(val, port);
+}
+
+static void ide_outsw (unsigned long port, void *addr, u32 count)
+{
+	outsw(port, addr, count);
+}
+
+static void ide_outl (u32 val, unsigned long port)
+{
+	outl(val, port);
+}
+
+static void ide_outsl (unsigned long port, void *addr, u32 count)
+{
+	outsl(port, addr, count);
+}
+
+void default_hwif_iops (ide_hwif_t *hwif)
+{
+	hwif->OUTB	= ide_outb;
+	hwif->OUTBSYNC	= ide_outbsync;
+	hwif->OUTW	= ide_outw;
+	hwif->OUTL	= ide_outl;
+	hwif->OUTSW	= ide_outsw;
+	hwif->OUTSL	= ide_outsl;
+	hwif->INB	= ide_inb;
+	hwif->INW	= ide_inw;
+	hwif->INL	= ide_inl;
+	hwif->INSW	= ide_insw;
+	hwif->INSL	= ide_insl;
+}
+
+EXPORT_SYMBOL(default_hwif_iops);
+
+/*
+ *	MMIO operations, typically used for SATA controllers
+ */
+
+static u8 ide_mm_inb (unsigned long port)
+{
+	return (u8) readb(port);
+}
+
+static u16 ide_mm_inw (unsigned long port)
+{
+	return (u16) readw(port);
+}
+
+static void ide_mm_insw (unsigned long port, void *addr, u32 count)
+{
+	__ide_mm_insw(port, addr, count);
+}
+
+static u32 ide_mm_inl (unsigned long port)
+{
+	return (u32) readl(port);
+}
+
+static void ide_mm_insl (unsigned long port, void *addr, u32 count)
+{
+	__ide_mm_insl(port, addr, count);
+}
+
+static void ide_mm_outb (u8 value, unsigned long port)
+{
+	writeb(value, port);
+}
+
+static void ide_mm_outbsync (ide_drive_t *drive, u8 value, unsigned long port)
+{
+	writeb(value, port);	
+}
+
+static void ide_mm_outw (u16 value, unsigned long port)
+{
+	writew(value, port);
+}
+
+static void ide_mm_outsw (unsigned long port, void *addr, u32 count)
+{
+	__ide_mm_outsw(port, addr, count);
+}
+
+static void ide_mm_outl (u32 value, unsigned long port)
+{
+	writel(value, port);
+}
+
+static void ide_mm_outsl (unsigned long port, void *addr, u32 count)
+{
+	__ide_mm_outsl(port, addr, count);
+}
+
+void default_hwif_mmiops (ide_hwif_t *hwif)
+{
+	hwif->OUTB	= ide_mm_outb;
+	/* Most systems will need to override OUTBSYNC, alas however
+	   this one is controller specific! */
+	hwif->OUTBSYNC	= ide_mm_outbsync;
+	hwif->OUTW	= ide_mm_outw;
+	hwif->OUTL	= ide_mm_outl;
+	hwif->OUTSW	= ide_mm_outsw;
+	hwif->OUTSL	= ide_mm_outsl;
+	hwif->INB	= ide_mm_inb;
+	hwif->INW	= ide_mm_inw;
+	hwif->INL	= ide_mm_inl;
+	hwif->INSW	= ide_mm_insw;
+	hwif->INSL	= ide_mm_insl;
+}
+
+EXPORT_SYMBOL(default_hwif_mmiops);
Index: drivers/ide/ide-probe.c
===================================================================
RCS file: /var/lib/cvs/linux-2.6/drivers/ide/ide-probe.c,v
retrieving revision 1.1.1.8
retrieving revision 1.6
diff -u -r1.1.1.8 -r1.6
--- a/drivers/ide/ide-probe.c	28 Feb 2004 12:51:56 -0000	1.1.1.8
+++ b/drivers/ide/ide-probe.c	28 Feb 2004 13:59:04 -0000	1.6
@@ -978,7 +978,7 @@
 	unsigned int index;
 	ide_hwgroup_t *hwgroup;
 	ide_hwif_t *match = NULL;
-
+	int ide_regs_gap;
 
 	BUG_ON(in_interrupt());
 	BUG_ON(irqs_disabled());	
@@ -1097,10 +1097,11 @@
 		spin_unlock_irq(&ide_lock);
 	}
 
+	ide_regs_gap = hwif->io_ports[IDE_ERROR_OFFSET] - hwif->io_ports[IDE_DATA_OFFSET];
 #if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__)
 	printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name,
 		hwif->io_ports[IDE_DATA_OFFSET],
-		hwif->io_ports[IDE_DATA_OFFSET]+7,
+		hwif->io_ports[IDE_DATA_OFFSET] + ide_regs_gap * 8 - 1,
 		hwif->io_ports[IDE_CONTROL_OFFSET], hwif->irq);
 #elif defined(__sparc__)
 	printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %s", hwif->name,
Index: drivers/ide/h8300/Makefile
===================================================================
RCS file: drivers/ide/h8300/Makefile
diff -N drivers/ide/h8300/Makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ b/drivers/ide/h8300/Makefile	28 Feb 2004 13:59:04 -0000	1.2
@@ -0,0 +1,2 @@
+obj-$(CONFIG_H8300H_H8MAX) := h8300-lowio.o
+obj-$(CONFIG_H8300H_AKI3068NET) := h8300-lowio.o
Index: drivers/ide/h8300/h8300-lowio.c
===================================================================
RCS file: drivers/ide/h8300/h8300-lowio.c
diff -N drivers/ide/h8300/h8300-lowio.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ b/drivers/ide/h8300/h8300-lowio.c	28 Feb 2004 14:32:02 -0000
@@ -0,0 +1,79 @@
+/* H8/300 IDE I/F I/O operations */
+
+/*
+ support target
+
+ AE-3068/AE-3069 + IDE Expand
+ H8MAX
+*/
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/ide.h>
+#include <asm/io.h>
+
+static void __ide_outb(u8 d, unsigned long a)
+{
+	outb(d,a); 
+}
+
+static void __ide_outbsync(ide_drive_t *drive, u8 d, unsigned long a)
+{
+	outb(d,a); 
+}
+
+static u8 __ide_inb(unsigned long a)
+{
+	return inb(a);
+}
+
+static void __ide_outw(u16 d, unsigned long a)
+{
+	return outw(d,a);
+}
+
+static u16 __ide_inw(unsigned long a)
+{
+	return inw(a);
+}
+
+static void __ide_outsw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned short *bp = (unsigned short *)buf;
+	while(len--)
+		outw(*bp++,addr);
+}
+
+static void __ide_insw(unsigned long addr, void *buf, u32 len)
+{
+	unsigned short *bp = (unsigned short *)buf;
+	while(len--)
+		*bp++ = inw(addr);
+}
+
+void default_hwif_iops(ide_hwif_t *hwif)
+{
+	hwif->OUTB 	= __ide_outb;
+	hwif->OUTBSYNC	= __ide_outbsync;
+	hwif->OUTW	= __ide_outw;
+	hwif->OUTL	= NULL;
+	hwif->OUTSW	= __ide_outsw;
+	hwif->OUTSL	= NULL;
+	hwif->INB	= __ide_inb;
+	hwif->INW	= __ide_inw;
+	hwif->INL	= NULL;
+	hwif->INSW	= __ide_insw;
+	hwif->INSL	= NULL;
+}
+
+void unplugged_hwif_iops (ide_hwif_t *hwif)
+{
+}
+
+void default_hwif_mmiops (ide_hwif_t *hwif)
+{
+}
+
+EXPORT_SYMBOL(default_hwif_iops);
+EXPORT_SYMBOL(unplugged_hwif_iops);
+EXPORT_SYMBOL(default_hwif_mmiops);

-- 
Yoshiori Sato
<ysato@users.sourceforge.jp>

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

* Re: H8/300 target support patch
  2004-02-28 17:02                                 ` Yoshinori Sato
@ 2004-02-28 17:55                                   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2004-02-28 17:55 UTC (permalink / raw)
  To: Yoshinori Sato; +Cc: Benjamin Herrenschmidt, linux-ide

On Saturday 28 of February 2004 18:02, Yoshinori Sato wrote:
> At Thu, 26 Feb 2004 20:26:51 +0100,
>
> Bartlomiej Zolnierkiewicz wrote:
> > On Thursday 26 of February 2004 17:46, Yoshinori Sato wrote:
> > > At Sun, 22 Feb 2004 18:28:18 +0100,
> > >
> > > Bartlomiej Zolnierkiewicz wrote:
> > > > On Sunday 22 of February 2004 18:08, Bartlomiej Zolnierkiewicz wrote:
> > > > > > I corrected it to initialize it with ide_init_default_hwifs.
> > > > > > A correction of ide.c becomes needless.
> > > > >
> > > > > NO!!!  ide_init_default_hwifs() should DIE!
> > > > > The same goes for ide_default_{irq,io_base}().
> > > > >
> > > > > They are not needed - you have driver(s) for H8/300 IDE
> > > > > controllers!
> > > >
> > > > It should be like that:
> > > >
> > > > You should have host drivers for your IDE controllers,
> > > > not inline functions for ide.c and ide-probe.c.
> > >
> > > I tuned to a driver of PC/AT wherever practicable.
> >
> > Just because original/legacy PC/AT driver is braindamaged (and dated)
> > doesn't mean your code should be, does it?  Hiding driver's code into
> > asm/ide.h causes MAJOR problems for IDE code reorganization.
> >
> > > Examination is necessary for a call method of h8300_hwif_iops.
> >
> > All ide-iops.c #ifdef-s won't be needed if you separate you driver
> > properly from asm/ide.h (thus overriding default_hwif_iops() ops
> > by ones used by your driver).
> >
> > Please revert to putting your code into ide/h8300/.
>
> I did overriding of default_hwif_iops in form to replace obj because
> it was not possible well.
>
> It is difference m with linux-2.6.4-rc1.

This change won't be needed if you correct your driver as asked.
BTW Your patch re-adds recently deleted unplugged_hwif_iops for no reason.

> Do not change asm/ide.h.

Please correct your patch to not abuse asm/ide.h (ide_init_default_hwifs(),
ide_default_irq() and ide_default_io_base() needs to die).

Cheers,
Bartlomiej


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

end of thread, other threads:[~2004-02-28 17:48 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-15  6:05 H8/300 target support patch Yoshinori Sato
2004-02-15 14:40 ` Bartlomiej Zolnierkiewicz
2004-02-16 16:09   ` Yoshinori Sato
2004-02-16 16:40     ` Bartlomiej Zolnierkiewicz
2004-02-16 22:07       ` Benjamin Herrenschmidt
2004-02-16 22:09     ` Benjamin Herrenschmidt
2004-02-17 11:33       ` Yoshinori Sato
2004-02-17 12:55         ` Benjamin Herrenschmidt
2004-02-19 16:12           ` Yoshinori Sato
2004-02-19 16:34             ` Bartlomiej Zolnierkiewicz
2004-02-20 12:28               ` Yoshinori Sato
2004-02-20 15:25                 ` Bartlomiej Zolnierkiewicz
2004-02-20 17:58                   ` Yoshinori Sato
2004-02-20 18:42                     ` Bartlomiej Zolnierkiewicz
2004-02-22 16:30                       ` Yoshinori Sato
2004-02-22 17:08                         ` Bartlomiej Zolnierkiewicz
2004-02-22 17:28                           ` Bartlomiej Zolnierkiewicz
2004-02-26 16:46                             ` Yoshinori Sato
2004-02-26 19:26                               ` Bartlomiej Zolnierkiewicz
2004-02-28 17:02                                 ` Yoshinori Sato
2004-02-28 17:55                                   ` Bartlomiej Zolnierkiewicz

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).