Commit Graph

87 Commits

Author SHA1 Message Date
bouyer 80b1feec65 Add sata registers to struct wdc_regs. Add wdc_sataprobe(), a function
probing drives using the standard SATA registers; taken from various
PCI sata drivers. Export wdc_drvprobe() too.
2006-10-25 17:33:02 +00:00
itohy f87d591722 A little effort against kernel bloat....
Exclude ATA DMA support if no ATA DMA capable drivers are compiled in.
2006-09-30 15:56:17 +00:00
itohy 6119b65726 Add PIOBM (busmastering transfer using ATA PIO mode) support.
The PIOBM is used by only one driver (will be added later,
stay tuned) and intruduce an attribute "ata_piobm" so that
it will be conditionally compiled in.
The "ata_dma" (busmastering transfer using ATA DMA mode) and
"ata_udma" (busmastering transfer using ATA Ultra DMA mode)
attributes are also added for consistency, but unused for now.
2006-09-07 12:46:47 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
bouyer d1278fcba8 Add an optionnal controller callback for channel reset. If the callback
is set to NULL, use the generic reset code.
Use this to work around a bug in some Acer IDE controllers (like the
one found in some sparc systems) where a controller disable/enable
is required after a reset to avoid data corruption when Ultra-DMA is
used. Workaround from opensolaris, thanks to Hiroki Sato for testing.
2005-08-06 22:07:24 +00:00
mycroft 1d50f417b8 Copyright maintenance. 2005-03-02 12:25:27 +00:00
perry f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
rearnsha 920296fb7f Add support for Artisea chips operating in DPA mode, which has a
16-bit view of the ATA command registers for extended commands.

Approved by briggs.
2005-02-11 21:11:15 +00:00
thorpej 218dbb60a6 Make some functions referenced only in wdc.c private to that file. 2004-08-21 01:51:46 +00:00
thorpej 3234a02f48 Move atabusconfig() to ata.c. 2004-08-20 22:02:40 +00:00
thorpej 9cc521a148 Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
2004-08-20 06:39:37 +00:00
thorpej 1600c8b8cd - Add and use a CHAN_TO_WDC() macro to get the wdc_softc from an
ata_channel.
- Add and use a CHAN_TO_WDC_REGS() macro to get the wdc_regs from an
  ata_channel.
- Add and use a CHAN_TO_PCIIDE() macro to get the pciide_softc from an
  ata_channel.
- Add and use a CHAN_TO_PCHAN() macro to get the pciide_channel from an
  ata_channel.  (This one just hides a cast, and is really just for
  consistency with the others.)
2004-08-19 23:25:35 +00:00
thorpej 4b51cecfc2 - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
  to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
  ata_channel.  Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
  maximum number of drives that can be present on the channel.  For now,
  this is always 2.  Add an ATA_MAXDRIVES constant that places an upper
  limit on this value, also currently 2.
2004-08-14 15:08:04 +00:00
thorpej ab20886f7b Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
2004-08-13 03:12:59 +00:00
thorpej 577bf67014 Move wdcstart() to ata.c and rename it to atastart(). 2004-08-13 02:16:40 +00:00
thorpej 996c3ca90e Move wdc_exec_xfer() to ata.c and rename it ata_exec_xfer(). 2004-08-13 02:10:43 +00:00
thorpej e6d61c5bc9 Move wdc_addref() and wdc_delref() to ata.c and rename them to
ata_*.
2004-08-12 22:39:40 +00:00
thorpej 2eaa5c6142 Move wdc_kill_pending() to ata.c and rename it ata_kill_pending(). 2004-08-12 22:33:45 +00:00
thorpej 2600c55e01 - Move wdc_xfer_pool, wdc_get_xfer(), wdc_free_xfer() to ata.c, and rename
to ata_*.
- Use a static initializer for the ata_xfer_pool.
2004-08-12 21:34:52 +00:00
thorpej 52ed169a28 Move wdc_probe_caps() to ata.c and rename it ata_probe_caps(). 2004-08-12 21:10:18 +00:00
thorpej 9939d3c63d Move wdc_print_modes() into ata.c and rename it ata_print_modes(). 2004-08-12 20:59:27 +00:00
thorpej 9167731c79 Rename some constants:
WDC_COMPLETE -> ATACMD_COMPLETE
WDC_QUEUED -> ATACMD_QUEUED
WDC_TRY_AGAIN -> ATACMD_TRY_AGAIN
2004-08-12 05:02:50 +00:00
thorpej 3ddac9b2da Rename "struct wdc_command" to "struct ata_command". 2004-08-12 04:57:19 +00:00
mycroft 6741190fbc Make datain_pio and dataout_pio function pointers in wdc_softc, which can
be overridden by the backend if desired.  Add experimental code to wdc_pcmcia
to use this in memory-mapped mode, disabled by default.
2004-08-11 18:41:46 +00:00
mycroft 04a46876e5 Add two helper functions -- wdc_datain_pio() and wdc_dataout_pio() -- which
encapsulate the logic for the various methods of transferring data.  Use these
throughout.
2004-08-11 17:49:27 +00:00
bouyer 1f5d4dd9dd Change wdc_kill_pending() to take a struct ata_drive_datas * as argument,
and kill only pending requests for this drive.
Implement a DRIVE_WAITDRAIN flag, which will cause the active command to
be killed once complete.
Other minor fixes.
Now it's possible to detach a ATA or ATAPI device from ioctl even when
a dd on the raw char partition is running.
2004-08-04 22:44:04 +00:00
bouyer 9b0cc941a3 Add
struct ata_xfer *active_xfer
to ata_queue. Now the active xfer isn't the head of the queue any more,
this makes a few things easier (this will also help for tagged queuing
support).
Remove the WDCF_ACTIVE flag, test active_xfer != NULL instead.
clean up wdc_free_xfer() and kill_xfer().
Clean up wdc_reset_channel(), and make it issue a ATAPI_SOFT_RESET if the
active command is ATAPI.
In wdc_atapi_get_params(), use AT_WAIT | AT_POLL for ATAPI_SOFT_RESET,
so that we'll use tsleep() instead of delay().
In wdc_atapi_start(), call wdc_dmawait() at the right place.
2004-08-04 18:24:10 +00:00
bouyer 73203a8277 Make it possible for (*dma_finish)() to abort quietly a DMA op. Use this
in wdc_reset_channel().
2004-08-02 22:20:54 +00:00
bouyer 495631e4d6 Clean up interraction between wdc_reset_channel and the kernel thread.
Move kill_xfer() after the reset, and stop the DMA engine if needed
(this will unload the DMA maps).
2004-08-02 22:02:35 +00:00
bouyer 011181ac3e Implement an atabus control device, and define some ATA bus control
IOCTLS. Implement ATABUSIORESET, which will reset the given ATA bus.
2004-08-01 21:40:41 +00:00
thorpej 2ecdd552dc Add the notion of "shadow registers" to the wdc driver. These shadow
registers are registers that overlap with others on many controllers, but
which may actually be distinct on some controllers.  Right now, the two
shadows are:

- wd_status (usually overlaps wd_command)
- wd_features (usually overlaps wd_error)

Add a new helper function, wdc_init_shadow_regs(), used to initialize
the shadow register handles on controllers where they do actually overlap.

Partially from Jordan Rhody @ Wasabi Systems, Inc.
2004-05-25 20:42:40 +00:00
bouyer fca16a87e1 Make wdc_channel->ch_flags volatile, and cast it to (void *) when used
in tsleep()/wakeup() to appease gcc. Otherwise, the ch_flags value may
be cached in a register in atabus_thread(), and when it sets the WDCF_TH_RUN
bit after tsleep() it may loose loose the changes made by an interrupt handler
or another thread.
Problem analysed by Jukka Andberg on tech-kern.
2004-04-13 19:51:06 +00:00
thorpej 197f2f50da More structure member namespace cleanup: thread -> ch_thread 2004-01-03 23:59:58 +00:00
thorpej a963286f8d More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
2004-01-03 22:56:52 +00:00
thorpej 3fb652250b More comment/whitespace tidy-up. 2004-01-03 19:31:09 +00:00
thorpej 5bd80d8373 Rename "struct channel_softc" to "struct wdc_channel". 2004-01-03 01:50:52 +00:00
thorpej 9bc0bf3f15 Prepend "wdc_" to wait_for_drq, wait_for_unbusy, and wait_for_ready. 2004-01-01 20:25:22 +00:00
thorpej 763657a529 Tidy up this file somewhat. 2004-01-01 20:18:33 +00:00
thorpej 527c829fa0 Rename:
- wdc_xfer to ata_xfer
- channel_queue to ata_queue
and move them to <dev/ata/atavar.h> so they can be used by non-wdc ATA
controllers.  Clean up the member names of these structures while at it.
2004-01-01 17:18:53 +00:00
thorpej ed96a1cec2 Move the drive probing code out of atabusconfig() and into a new
wdc_drvprobe() function.  wdc_drvprobe() is used if the controller
does not specify a custom one prior to calling wdcattach().  The
WDC_CAPABILITY_DRVPROBE bit is gone.
2003-12-30 17:18:11 +00:00
thorpej 0ad3db4759 Move most of the atabus layer into ata.c. 2003-12-30 16:28:37 +00:00
thorpej 9de2760c3e Add a (*drv_probe)() optional callback into the driver to probe for
drives on a channel.  Drivers should provide this if they have some
sort of intelligent probing mechanism.
2003-12-15 00:27:13 +00:00
bouyer 67e9511d69 Move WDC_NREG from wdcreg.h to wdcvar.h. First part of fix for
port-macppc/23604.
2003-12-03 12:01:18 +00:00
fvdl 6242a54566 There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.

To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.

	bus_space_write_4(tag, handle, offset, value)

becomes

	bus_space_write_4(tag, handles[offset], 0, value)

Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
2003-11-27 23:02:40 +00:00
wiz c5670263e0 Fix some typos. From Tom Cosgrove via jmc@openbsd. 2003-11-02 11:07:44 +00:00
bouyer 14cd9d8cff freese->freeze, as pointed out by Frederick Bruck. 2003-10-29 22:05:15 +00:00
bouyer 99d6009c2a Make the ATA mid-layer appears as atabus, as proposed in
http://mail-index.netbsd.org/tech-kern/2003/09/25/0006.html
This adds a device (atabus) between IDE controllers and wd or atapibus, to
have each ATA channel show up in the device tree. Later there will be atabus
devices in /dev, so that we can do IOCTL on them.
Each atabus has its own kernel thread, to handle operations that needs polling,
e.g. reset and others.

Device probing on each bus it defered to the atabus thread creation.
This allows to do the reset and basic device probes in parallel, which reduce
boot time on systems with several pciide controllers.
2003-10-08 10:58:12 +00:00
mycroft eefae40298 Hide the use of config_interrupts() in one place. 2003-09-25 19:29:48 +00:00
mycroft f9d629fb93 Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
   BSY clear, abort the command and ignore the drive.  (Do this by testing
   for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
   non-block command that reads data) -- we don't do this for block I/O, and
   empirically it doesn't clear on my CF cards at all, causing a pointless 1s
   delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
   and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
   overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
   as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.

Also remove the SINGLE_DRIVE nonsense again.
2003-09-23 09:19:22 +00:00
bouyer c6beeca692 Since we can't detect ghost drives in the wdc back-end, resurect
WDC_CAPABILITY_SINGLE_DRIVE.
2003-09-21 11:14:00 +00:00