Skip to contentSkip to conversation

add support for PC-9800 architecture (IDE)

PATCH In review Osamu Tomita 1 participant 1 message Oct 28, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 9/23 add support for PC-9800 architecture (IDE)

This is a part 9/23 of patchset for add support NEC PC-9800 architecture, against 2.5.44.

Summary:
IDE driver modules
- IO port address change.
- add support PC-9800 specific feature. (shared IRQ, serialize)

diffstat:

 drivers/ide/Config.in       |    4 
 drivers/ide/ide-disk.c      |   67 +++
 drivers/ide/ide-geometry.c  |    2 
 drivers/ide/ide-probe.c     |   25 +
 drivers/ide/ide-proc.c      |    3 
 drivers/ide/ide.c           |   14 
 drivers/ide/legacy/Makefile |    5 
 drivers/ide/legacy/hd98.c   |  904 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/ide/legacy/pc9800.c |   82 +++
 include/asm-i386/ide.h      |   18 
 include/linux/hdreg.h       |   19 
 include/linux/ide.h         |    2 
 12 files changed, 1141 insertions(+), 4 deletions(-)

patch:

drivers/ide/Config.in +4 -0
diff -urN linux/drivers/ide/Config.in linux98/drivers/ide/Config.in
@@ -219,4 +219,8 @@
    define_bool CONFIG_BLK_DEV_IDE_MODES n
 fi
 
+if [ "$CONFIG_PC9800" = "y" ]; then
+   define_bool CONFIG_BLK_DEV_IDE_PC9800 y
+fi
+
 endmenu
drivers/ide/ide-disk.c +67 -0

79 lines not on this page · raw message

drivers/ide/ide-geometry.c +2 -0
diff -urN linux/drivers/ide/ide-geometry.c linux98/drivers/ide/ide-geometry.c
@@ -6,6 +6,7 @@
 #include <linux/mc146818rtc.h>
 #include <asm/io.h>
 
+#ifndef CONFIG_PC9800
 /*
  * We query CMOS about hard disks : it could be that we have a SCSI/ESDI/etc
  * controller that is BIOS compatible with ST-506, and thus showing up in our
@@ -81,6 +82,7 @@
 	}
 #endif
 }
+#endif /* !CONFIG_PC9800 */
 
 
 extern unsigned long current_capacity (ide_drive_t *);
drivers/ide/ide-probe.c +23 -2
diff -urN linux/drivers/ide/ide-probe.c linux98/drivers/ide/ide-probe.c
@@ -553,7 +553,11 @@
 
 	if (hwif->mmio == 2)
 		return 0;
+#ifndef CONFIG_PC9800
 	addr_errs  = hwif_check_region(hwif->io_ports[IDE_DATA_OFFSET], 1);
+#else
+	addr_errs  = hwif_check_region(hwif->io_ports[IDE_DATA_OFFSET], 2);
+#endif
 	for (i = IDE_ERROR_OFFSET; i <= IDE_STATUS_OFFSET; i++)
 		addr_errs += hwif_check_region(hwif->io_ports[i], 1);
 	if (hwif->io_ports[IDE_CONTROL_OFFSET])
@@ -601,7 +605,13 @@
 		return;
 	}
 
+#ifndef CONFIG_PC9800
 	for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
+#else
+	/* IDE_DATA_REG is actually word (16 bits) register */
+	hwif_request_region(hwif->io_ports[IDE_DATA_OFFSET], 2, hwif->name);
+	for (i = IDE_ERROR_OFFSET; i <= IDE_STATUS_OFFSET; i++)
+#endif
 		hwif_request_region(hwif->io_ports[i], 1, hwif->name);
 }
 
@@ -619,7 +629,7 @@
 
 	if (hwif->noprobe)
 		return;
-#ifdef CONFIG_BLK_DEV_IDE
+#if !defined(CONFIG_PC9800) && defined(CONFIG_BLK_DEV_IDE)
 	if (hwif->io_ports[IDE_DATA_OFFSET] == HD_DATA) {
 		extern void probe_cmos_for_drives(ide_hwif_t *);
 		probe_cmos_for_drives(hwif);
@@ -630,6 +640,9 @@
 #if CONFIG_BLK_DEV_PDC4030
 	    (hwif->chipset != ide_pdc4030 || hwif->channel == 0) &&
 #endif /* CONFIG_BLK_DEV_PDC4030 */
+#if CONFIG_BLK_DEV_IDE_PC9800
+	    (hwif->chipset != ide_pc9800 || !hwif->mate->present) &&
+#endif
 	    (hwif_check_regions(hwif))) {
 		u16 msgout = 0;
 		for (unit = 0; unit < MAX_DRIVES; ++unit) {
@@ -949,7 +962,7 @@
 	/* all CPUs; safe now that hwif->hwgroup is set up */
 	spin_unlock_irqrestore(&ide_lock, flags);
 
-#if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__)
+#if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__) && !defined(CONFIG_PC9800)
 	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,
@@ -959,6 +972,14 @@
 		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(CONFIG_PC9800)
+	printk("%s at 0x%03lx-0x%03lx,0x%03lx-0x%03lx on irq %d",
+		hwif->name,
+		hwif->io_ports[IDE_DATA_OFFSET],
+		hwif->io_ports[IDE_DATA_OFFSET]+15,
+		hwif->io_ports[IDE_CONTROL_OFFSET],
+		hwif->io_ports[IDE_CONTROL_OFFSET]+3,
+		hwif->irq);
 #else
 	printk("%s at %x on irq 0x%08x", hwif->name,
 		hwif->io_ports[IDE_DATA_OFFSET], hwif->irq);
drivers/ide/ide-proc.c +3 -0
diff -urN linux/drivers/ide/ide-proc.c linux98/drivers/ide/ide-proc.c
@@ -365,6 +365,9 @@
 		case ide_cy82c693:	name = "cy82c693";	break;
 		case ide_4drives:	name = "4drives";	break;
 		case ide_pmac:		name = "mac-io";	break;
+#ifdef CONFIG_PC9800
+		case ide_pc9800:	name = "pc9800";	break;
+#endif
 		default:		name = "(unknown)";	break;
 	}
 	len = sprintf(page, "%s\n", name);
drivers/ide/ide.c +13 -1
diff -urN linux/drivers/ide/ide.c linux98/drivers/ide/ide.c
@@ -1694,7 +1694,13 @@
 		hwif_release_region(hwif->io_ports[IDE_DATA_OFFSET], 8);
 		return;
 	}
-	for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
+#ifndef CONFIG_PC9800
+#define IDE_REGION_START IDE_DATA_OFFSET
+#else
+#define IDE_REGION_START IDE_ERROR_OFFSET
+	hwif_release_region(hwif->io_ports[IDE_DATA_OFFSET], 2);
+#endif
+	for (i = IDE_REGION_START; i <= IDE_STATUS_OFFSET; i++) {
 		if (hwif->io_ports[i]) {
 			hwif_release_region(hwif->io_ports[i], 1);
 		}
@@ -3057,6 +3063,12 @@
 	}
 #endif /* CONFIG_BLK_DEV_IDEPCI */
 
+#ifdef CONFIG_BLK_DEV_IDE_PC9800
+	{
+		extern void ide_probe_for_pc9800(void);
+		ide_probe_for_pc9800();
+	}
+#endif
 #ifdef CONFIG_ETRAX_IDE
 	{
 		extern void init_e100_ide(void);
drivers/ide/legacy/Makefile +5 -0
diff -urN linux/drivers/ide/legacy/Makefile linux98/drivers/ide/legacy/Makefile
@@ -2,6 +2,7 @@
 obj-$(CONFIG_BLK_DEV_ALI14XX)		+= ali14xx.o
 obj-$(CONFIG_BLK_DEV_DTC2278)		+= dtc2278.o
 obj-$(CONFIG_BLK_DEV_HT6560B)		+= ht6560b.o
+obj-$(CONFIG_BLK_DEV_IDE_PC9800)	+= pc9800.o
 obj-$(CONFIG_BLK_DEV_PDC4030)		+= pdc4030.o
 obj-$(CONFIG_BLK_DEV_QD65XX)		+= qd65xx.o
 obj-$(CONFIG_BLK_DEV_UMC8672)		+= umc8672.o
@@ -15,7 +16,11 @@
 obj-$(CONFIG_BLK_DEV_IDECS)		+= ide-cs.o
 
 # Last of all
+ifneq ($(CONFIG_PC9800),y)
 obj-$(CONFIG_BLK_DEV_HD)		+= hd.o
+else
+obj-$(CONFIG_BLK_DEV_HD)		+= hd98.o
+endif
 
 EXTRA_CFLAGS	:= -Idrivers/ide
 
drivers/ide/legacy/hd98.c +904 -0

904 lines not on this page · raw message

drivers/ide/legacy/pc9800.c +82 -0

82 lines not on this page · raw message

include/asm-i386/ide.h +18 -0
diff -urN linux/include/asm-i386/ide.h linux98/include/asm-i386/ide.h
@@ -26,6 +26,9 @@
 static __inline__ int ide_default_irq(ide_ioreg_t base)
 {
 	switch (base) {
+#ifdef CONFIG_PC9800
+		case 0x640: return 9;
+#endif /* CONFIG_PC9800 */
 		case 0x1f0: return 14;
 		case 0x170: return 15;
 		case 0x1e8: return 11;
@@ -39,7 +42,11 @@
 
 static __inline__ ide_ioreg_t ide_default_io_base(int index)
 {
+#ifndef CONFIG_PC9800
 	static unsigned long ata_io_base[MAX_HWIFS] = { 0x1f0, 0x170, 0x1e8, 0x168, 0x1e0, 0x160 };
+#else /* CONFIG_PC9800 */
+	static unsigned long ata_io_base[MAX_HWIFS] = { 0x640, 0x640, 0, 0, 0, 0 };
+#endif /* !CONFIG_PC9800 */
 
 	return ata_io_base[index];
 }
@@ -48,13 +55,24 @@
 {
 	ide_ioreg_t reg = data_port;
 	int i;
+#ifdef CONFIG_PC9800
+	ide_ioreg_t increment = data_port == 0x640 ? 2 : 1;
+#endif
 
 	for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
 		hw->io_ports[i] = reg;
+#ifndef CONFIG_PC9800
 		reg += 1;
+#else
+		reg += increment;
+#endif
 	}
 	if (ctrl_port) {
 		hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
+#ifdef CONFIG_PC9800
+	} else if (data_port == 0x640) {
+		hw->io_ports[IDE_CONTROL_OFFSET] = 0x74c;
+#endif
 	} else {
 		hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206;
 	}
include/linux/hdreg.h +19 -0
diff -urN linux/include/linux/hdreg.h linux98/include/linux/hdreg.h
@@ -5,11 +5,13 @@
  * This file contains some defines for the AT-hd-controller.
  * Various sources.
  */
+#include <linux/config.h>
 
 /* ide.c has its own port definitions in "ide.h" */
 
 #define HD_IRQ		14
 
+#ifndef CONFIG_PC9800
 /* Hd controller regs. Ref: IBM AT Bios-listing */
 #define HD_DATA		0x1f0		/* _CTL when writing */
 #define HD_ERROR	0x1f1		/* see err-bits */
@@ -25,6 +27,23 @@
 
 #define HD_CMD		0x3f6		/* used for resets */
 #define HD_ALTSTATUS	0x3f6		/* same as HD_STATUS but doesn't clear irq */
+#else /* CONFIG_PC9800 */
+/* Hd controller regs. for NEC PC-9800 */
+#define HD_DATA		0x640	/* _CTL when writing */
+#define HD_ERROR	0x642	/* see err-bits */
+#define HD_NSECTOR	0x644	/* nr of sectors to read/write */
+#define HD_SECTOR	0x646	/* starting sector */
+#define HD_LCYL		0x648	/* starting cylinder */
+#define HD_HCYL		0x64a	/* high byte of starting cyl */
+#define HD_CURRENT	0x64c	/* 101dhhhh , d=drive, hhhh=head */
+#define HD_STATUS	0x64e	/* see status-bits */
+#define HD_FEATURE	HD_ERROR	/* same io address, read=error, write=feature */
+#define HD_PRECOMP	HD_FEATURE	/* obsolete use of this port - predates IDE */
+#define HD_COMMAND	HD_STATUS	/* same io address, read=status, write=cmd */
+
+#define HD_CMD		0x74c	/* used for resets */
+#define HD_ALTSTATUS	0x74c	/* same as HD_STATUS but doesn't clear irq */
+#endif /* CONFIG_PC9800 */
 
 /* remainder is shared between hd.c, ide.c, ide-cd.c, and the hdparm utility */
 
include/linux/ide.h +1 -1
diff -urN linux/include/linux/ide.h linux98/include/linux/ide.h
@@ -286,7 +286,7 @@
 		ide_qd65xx,	ide_umc8672,	ide_ht6560b,
 		ide_pdc4030,	ide_rz1000,	ide_trm290,
 		ide_cmd646,	ide_cy82c693,	ide_4drives,
-		ide_pmac,	ide_etrax100,	ide_acorn
+		ide_pmac,	ide_etrax100,	ide_acorn,	ide_pc9800
 } hwif_chipset_t;
 
 typedef struct ide_io_ops_s {