4 * Copyright (C) 1997-2000 Linux/98 project,
5 * Kyoto University Microcomputer Club.
8 #include <linux/config.h>
9 #include <linux/kernel.h>
10 #include <linux/ioport.h>
11 #include <linux/ide.h>
12 #include <linux/init.h>
15 #include <asm/pc9800.h>
17 #define PC9800_IDE_BANKSELECT 0x432
19 #undef PC9800_IDE_DEBUG
21 static void pc9800_select(ide_drive_t *drive)
23 #ifdef PC9800_IDE_DEBUG
27 /* printk(KERN_DEBUG "pc9800_select(%s)\n", drive->name); */
29 outb(0x80, PC9800_IDE_BANKSELECT);
30 old = inb(PC9800_IDE_BANKSELECT);
31 if (old != HWIF(drive)->index)
32 printk(KERN_DEBUG "ide-pc9800: switching bank #%d -> #%d\n",
33 old, HWIF(drive)->index);
35 outb(HWIF(drive)->index, PC9800_IDE_BANKSELECT);
38 void __init ide_probe_for_pc9800(void)
42 if (!PC9800_9821_P() /* || !PC9821_IDEIF_DOUBLE_P() */)
45 if (!request_region(PC9800_IDE_BANKSELECT, 1, "ide0/1 bank")) {
47 "ide: bank select port (%#x) is already occupied!\n",
48 PC9800_IDE_BANKSELECT);
52 /* Do actual probing. */
53 if ((saved_bank = inb(PC9800_IDE_BANKSELECT)) == (u8) ~0
54 || (outb(saved_bank ^ 1, PC9800_IDE_BANKSELECT),
55 /* Next outb is dummy for reading status. */
56 outb(0x80, PC9800_IDE_BANKSELECT),
57 inb(PC9800_IDE_BANKSELECT) != (saved_bank ^ 1))) {
59 "ide: pc9800 type bank selecting port not found\n");
60 release_region(PC9800_IDE_BANKSELECT, 1);
64 /* Restore original value, just in case. */
65 outb(saved_bank, PC9800_IDE_BANKSELECT);
67 /* These ports are reseved by IDE I/F. */
68 if (!request_region(0x430, 1, "ide") ||
69 !request_region(0x435, 1, "ide")) {
71 "ide: IO port 0x430 and 0x435 are reserved for IDE"
72 " the card using these ports may not work\n");
75 if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET] == HD_DATA &&
76 ide_hwifs[1].io_ports[IDE_DATA_OFFSET] == HD_DATA) {
77 ide_hwifs[0].chipset = ide_pc9800;
78 ide_hwifs[0].mate = &ide_hwifs[1];
79 ide_hwifs[0].selectproc = pc9800_select;
80 ide_hwifs[1].chipset = ide_pc9800;
81 ide_hwifs[1].mate = &ide_hwifs[0];
82 ide_hwifs[1].selectproc = pc9800_select;