Subject: needs MI wdc changes to support macppc's wdc
To: None <>
From: Izumi Tsutsui <>
List: tech-kern
Date: 10/25/1998 22:31:02
I'm working on the the macppc's obio wdc support.

I'd like to use the MI wdc.c for it, but offsets of registers
defined in wdcreg.h don't match macppc's wdc registers.
The offsets of macppc's wdc registers are aligned every 16 bytes.

Currently, I add following defines in /sys/dev/ic/wdcvar.h:

#if defined(macppc)

#define wdcregoff(chp, a)	(chp)->wdc->reg_offset[a]
#define wdcregoff(chp, a)	(a)

and add member `reg_offset[8]' in struct wdc_softc.

Then I modify bus_space_{read,write}_{1,2}() args from:

	bus_space_read_1(chp->cmd_iot, chp->cmd_ioh, wd_status);
	bus_space_read_1(chp->cmd_iot, chp->cmd_ioh,
			 wdcregoff(chp, wd_status));

in wdc.c, ata_wdc.c and atapi_wdc.c, and set reg_offset[]
in the each wdc attachment code like:

	for (i = 0; i < 8; i++)
		sc->sc_wdcdev.reg_offset[i] = i;

This implementation is suggested by Bouyer, Tsubai and Soda.
The patch for 981017 current source tree is available at:

I think using offsets' array is more generic but it would make some
overheads. WDC_NONCONTIG_REG is defined on only archs which
would have wdc with non-contiguous offsets, but I'm not sure
how much overheads are.

On the other hand, atari's wdc has also non-contiguous offsets
but atari's mb_bus_space_*() functions handle it as contiguous.
I heard that mac68k's wdc had non-contiguous offsets, too.

Any comments?
Izumi Tsutsui