README.ide
==========

This is a copy of a posting Jeff Epler made to the pnp-list, describing
how he succeeded in getting his IDE port on a soundcard to work.
I think it's fairly clear...
The basic concept is to make an empty module with the sole purpose
of talking to the IDE driver to register a new set of addresses.
There is no driver code in the module, it is like a simple setserial
for the IDE driver.
---------------------------------------------------------------------------

Date: Mon, 6 Jan 1997 09:12:29 -0600
From: jepler@inetnebr.com (Jeff Epler)
To: pnp-list@redhat.com
Subject: SB16 PnP success with IDE interface
X-Mailing-List: <pnp-list@redhat.com> archive/latest/596

Hi.  I've just succeeded in using the IDE interface on a SB16 PnP card,
without resorting to initrd, rebooting after running isapnp, or other silly
things.

I'm using kernel 2.0.27, isapnp-1.8, and modutils 2.0.  I enabled
CONFIG_BLK_DEV_IDE_PCMCIA (and compiled ide in-kernel, which is the only
choice in 2.0.x), which is half the magic.  On the SB card I have a single
cdrom drive, configured as the master.

CONFIG_BLK_DEV_IDE_PCMCIA is misnamed, it allows for you to register
and unregister ide interfaces after boot-time.  While it may have been
useful only to the PCMCIA crowd at some time in the past, it's useful
to us now, while we're waiting for complete pnp support in the kernel.
In my case, the proper time to register the third ide interface (ide2)
is right after I run isapnp.

As nearly as I can figure, the way to call the routines ide_register and
ide_unregister are by a module.  I enclose below the source for 'ide2mod.c'.
Edit the definition of port, port1, and irq according to the resources you
can allocate to your sb16's ide interface.  Then, compile it
	gcc -DMODULE -c ide2mod.c -o ide2mod.o
and put it somewhere that's available when you run isapnp.

Then, (re-running isapnp to enable the ide interface if necessary), test it
by running as root
	insmod ide2mod.o
you should see output like this:

hde: NEC CD-ROM DRIVE:251, ATAPI CDROM drive
ide2 at 0x1e8-0x1ef,0x3ee on irq 11
ide_register(1e8, 3ee, 11)->2
Initialization of ide2mod failed

Don't be alarmed at the last line -- this merely means that the module is
not staying resident in kernel space.  The three earlier lines are the
important ones.  It shows that my cdrom drive has been recognized as
/dev/hde and that the address for ide2 is correct.

You can also unregister the interface with 
	insmod ide2mod.o do_register=0
which may be useful if you're fiddling around.

In /etc/rc, it's run like this:
	/sbin/isapnp /etc/isapnp.conf
	/sbin/insmod /boot/ide2mod.o

I hope this is of some use to someone out there.  If you have any
questions or suggestions, please mail them to jepler@inetnebr.com, or just
reply on the list.

Jeff

----------------------------------- ide2mod.c -----------------------------
#define MODULE

#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>

int port=0x1e8;
int port1=0x3ee; /* usually port + 0x206 for some reason */
int irq=11;
int index=2;
int do_register=1;
int res;

init_module() {
	if (do_register) {
		printk("ide_register(%x, %x, %d)->%d\n",
			port, port1, irq,
			res=ide_register(port, port1, irq));
	} else {
		printk("ide_unregister(%d)->%d\n",
			res=index, ide_unregister(index));
	}
	return res;
}

cleanup_module() {
}
---------------------------- end -- ide2mod.c -----------------------------

----------------------------------- part of /etc/isapnp -------------------
#
# Logical device id CTL2011
#
# Edit the entries below to uncomment out the configuration required.
# Note that only the first value of any range is given, this may be changed if required
# Don't forget to uncomment the activate (ACT Y) when happy

(CONFIGURE CTL002b/1079828 (LD 1
#     Compatible device id PNP0600
#     ANSI string -->IDE<--
	(INT 0 (IRQ 11 (MODE +E)))
	(IO 0 (BASE 0x01e8))
	(IO 1 (BASE 0x03ee))
	(ACT Y)
))
---------------------------- end -- part of /etc/isapnp -------------------
