Home | History | Annotate | Download | only in dev
History log of /src/sys/arch/macppc/dev/wdc_obio.c
RevisionDateAuthorComments
 1.63  05-Mar-2021  rin Convert to intr_establish_xname().
 1.62  26-Jan-2021  thorpej There is not much point in of_compatible() returning -1 for "no match"
and >= 0 for "match". Just make it return 0 for "no match" and >0 for
"match" so it can be treated like a boolean expression.

As such of_match_compatible() (a wrapper around of_compatible()) is now
obsolete, and will be removed once all call sites are converted to an
appropriate replacement.
 1.61  20-Oct-2017  jdolecek branches: 1.61.16;
move ata_queue_alloc(1) and ata_queue_free() calls to ata_channel_init()
and ata_channel_destroy() respectively, to make attachment code simpler,
and to make it easier to spot special queue manipulation like cmdide(4)

on topic of PR kern/52606
 1.60  07-Oct-2017  jdolecek Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

ATA subsystem was changed to support several outstanding commands, and use
NCQ xfers if supported by both the controller and the disk, including NCQ
error recovery. Set NCQ high priority for BPRIO_TIMECRITICAL xfers
if supported. Added FUA support.

Done some work towards MP-safe, all ATA code tsleep()/wakeup() replaced
by condvars, and switched most code from spl* to mutexes (separate
wd(4) and ata channel lock).

Introduced new option WD_CHAOS_MONKEY to facilitate testing of error
handling, fixed several uncovered issues. Also fixed several problems
with kernel dump to wd(4) disk.

Tested with ahcisata(4), mvsata(4), siisata(4), piixide(4) on amd64,
with and without port multiplier, both disk and ATAPI devices; other
drivers and archs mechanically adjusted and compile-tested. NCQ is
supported for ahcisata(4) and siisata(4) for any controller, for
mvsata(4) only Gen IIe ones for now. Also enabled ATAPI support in
mvsata(4).

Thanks to Matt Thomas for initial ATA infrastructure patch, and
Jonathan A.Kollasch for siisata(4) NCQ changes and general testing.

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.59  15-Jul-2016  macallan branches: 1.59.4;
- only unmap / free dbdma stuff when we actually mapped / allocated it
- use dbdma_free
now wdc_obio_detach() actually works without crashing
 1.58  31-Jul-2012  bouyer branches: 1.58.2; 1.58.16; 1.58.20;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.57  26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.56  24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.55  15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.54  02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.53  01-Jul-2011  dyoung branches: 1.53.2;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.52  18-Nov-2009  dyoung wdcactivate() is gone, don't use it.
 1.51  28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.50  30-Mar-2008  macallan branches: 1.50.2; 1.50.4;
free & unmap DMA memory and registers on detach()
Now removing and re-attaching a mediabay works again.
 1.49  18-Mar-2008  cube Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.48  25-Feb-2008  matt Convert to prototypes, de'__P, use device_private, switch to aprint_*,
make things static, and some minor constification.
 1.47  17-Oct-2007  garbled branches: 1.47.12; 1.47.16;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.46  07-Nov-2006  macallan branches: 1.46.8; 1.46.16; 1.46.26; 1.46.28; 1.46.30; 1.46.32;
allow IDE DMA on Heathrow again
 1.45  04-Sep-2006  macallan branches: 1.45.2; 1.45.4;
trying to use IDE DMA on a Heathrow macio is busted so disable it for now.
 1.44  29-Mar-2006  thorpej Use device_cfdata().
 1.43  16-Jan-2006  bouyer branches: 1.43.2; 1.43.4; 1.43.6; 1.43.8; 1.43.10;
properly use ata_channel->ch_ndrive:
- initialize it properly in the bus front-ends (all 2, exept in wdc_pcmcia.c
for the "Sandisk CompactFlash Card" where it's set to 1)
- remplace hardcoded '2' by ata_channel->ch_ndrive in MI IDE drivers.

From Christos Zoulas in kern/32501.
 1.42  11-Dec-2005  christos branches: 1.42.2;
merge ktrace-lwp.
 1.41  23-Aug-2004  aymeric branches: 1.41.12;
postpone the calling of wdc_init_shadow_regs(), to follow MI changes.
Thanks to Jukka Andberg for finding that bug.
 1.40  20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.39  14-Aug-2004  thorpej - 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.
 1.38  13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.37  25-May-2004  thorpej 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.
 1.36  04-Jan-2004  dbj attempt to make these compile again after recent wdc changes.
 1.35  03-Jan-2004  thorpej More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.34  03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.33  01-Jan-2004  thorpej 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.
 1.32  31-Dec-2003  thorpej Simplify allocation of the channel queue.
 1.31  27-Dec-2003  mjl Initialize some auto vars to appaise gcc3.
 1.30  03-Dec-2003  bouyer Adapt for new wdc regiosters array. Should fix port-macppc/23604.
 1.29  08-Oct-2003  bouyer Adapt for wdcattach() prototype change, and deal with atabus in
device_register().
 1.28  25-Sep-2003  mycroft Hide the use of config_interrupts() in one place.
 1.27  19-Sep-2003  mycroft 1) Use config_interrupts() to attach IDE and ATAPI drives. This eliminates
most polling.
2) Clean up some goofiness in pciide -- get rid of the whole "candisable" path
(it's gratuitous) and simplify the code by calling pciide_map_compat_intr(),
*_set_modes() and wdc_print_modes() from central locations.
3) Add a register writability and register ghost test to eliminate phantom
drives more quickly.
 1.26  15-Jul-2003  lukem __KERNEL_RCSID()
 1.25  19-Jun-2003  hamajima branches: 1.25.2;
Fix wdc_obio_dma_init() confused WDC_DMA_LBA48 with WDC_DMA_READ.
This was tested by jtb@netbsd.org.
 1.24  03-May-2003  wiz DMA, not dma nor Dma.
 1.23  02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.22  02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.21  27-Sep-2002  thorpej Declare all cfattach structures const.
 1.20  18-Jul-2002  bouyer Wrap debug printf in #ifdef DEBUG/#endif
 1.19  09-Jan-2002  dbj branches: 1.19.8; 1.19.10;
tweak timings
 1.18  07-Jan-2002  dbj Changes to the wdc(4) mi driver that add the WDC_CAPABILITY_SELECT
flag and a callback function which gets called whenever a target is
selected on a channel.

The macppc wdc driver needs to reprogram its timing register
differently for each target on a channel each time that target is
selected. I also changed the ATA4_TIME_TO_TICK to use a divisor of
15, which brings our timing calculations consistent with darwin.

These patches fix problems on my dual usb ibook with combo dvd/cdrw
drive because the hard drive supports udma and the combo drive does
not. Without turning off the udma timings in the configuration
register, I cannot access the non-udma combo drive.
 1.17  09-Sep-2001  bouyer branches: 1.17.4;
Properly initiatize sc->sc_wdcdev.set_modes for non-DMA controllers.
 1.16  02-Aug-2001  bouyer branches: 1.16.2;
Properly setup timings for ata-4 controllers, including UDMA modes.
Tested on a brand new ("dual USB ?") ibook.
 1.15  25-Jul-2001  bouyer Return() if piomode == -1 (i.e. we have no drives), avoid reading an array with
a negative offset.
Thanks to Andrew Cagney for pointing this out.
 1.14  22-Jul-2001  wiz bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.13  15-Jun-2001  bouyer branches: 1.13.2;
Pass WDC_CAPABILITY_MODE to the wdc core, so that it will set timings
on the drive side too.
Deal properly with the case where master and slave don't have the same timings,
and set PIO timings too.
 1.12  08-Jun-2001  matt Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.11  08-Nov-2000  wrstuden branches: 1.11.2;
Use wdc_print_modes() so that we get to see what DMA modes
are used with a drive.
 1.10  29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.9  23-May-2000  tsubai branches: 1.9.4;
Modify DMA access timings.
 1.8  14-Apr-2000  tsubai Make this compile.
 1.7  02-Apr-2000  tsubai Enable wdc1 (needed on StarMax).
 1.6  21-Jan-2000  tsubai Match "keylargo-ata".
 1.5  04-Oct-1999  tsubai branches: 1.5.2;
Make media-bay CD detachable.
 1.4  14-Jun-1999  tsubai * Don't use DMA interrupt.
* Stop DMA explicitly in finish routine.
 1.3  01-May-1999  tsubai Use "compatible" property to match.
 1.2  22-Jan-1999  tsubai branches: 1.2.2;
Match "ata0".
 1.1  10-Dec-1998  tsubai Add ata/atapi disk support.
 1.2.2.2  07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.2.2.1  06-May-1999  perry branches: 1.2.2.1.2;
pullup 1.2->1.3 (thorpej)
 1.2.2.1.2.1  21-Jun-1999  thorpej Sync w/ -current.
 1.5.2.2  22-Nov-2000  bouyer Sync with HEAD.
 1.5.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.9.4.1  16-Jan-2002  he Pull up revisions 1.13,1.15-1.19 (via patch, requested by dbj):
Add UDMA support and allow separate DMA timings to be programmed
for two different devices on the same wdc channel on the macppc.
The machine-independent driver is updated to optionally use the
WDC_CAPABILITY_SELECT callback whenever a target is selected on
a channel.
 1.11.2.1  21-Jun-2001  nathanw Catch up to -current.
 1.13.2.5  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.13.2.4  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.13.2.3  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.13.2.2  13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.13.2.1  03-Aug-2001  lukem update to -current
 1.16.2.1  01-Oct-2001  fvdl Catch up with -current.
 1.17.4.5  18-Oct-2002  nathanw Catch up to -current.
 1.17.4.4  01-Aug-2002  nathanw Catch up to -current.
 1.17.4.3  28-Feb-2002  nathanw Catch up to -current.
 1.17.4.2  11-Jan-2002  nathanw More catchup.
 1.17.4.1  09-Sep-2001  nathanw file wdc_obio.c was added on branch nathanw_sa on 2002-01-11 23:38:35 +0000
 1.19.10.2  24-Jun-2003  grant Pull up revision 1.25 (requested by hamajima in ticket #1328):

Fix wdc_obio_dma_init() confused WDC_DMA_LBA48 with WDC_DMA_READ.
This was tested by jtb@netbsd.org.
 1.19.10.1  19-Jul-2002  lukem Pull up revision 1.20 (requested by bouyer in ticket #519):
Wrap debug printf in #ifdef DEBUG/#endif
 1.19.8.1  21-Jul-2002  gehenna catch up with -current.
 1.25.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.25.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.25.2.2  25-Aug-2004  skrll Sync with HEAD.
 1.25.2.1  03-Aug-2004  skrll Sync with HEAD
 1.41.12.5  24-Mar-2008  yamt sync with head.
 1.41.12.4  27-Feb-2008  yamt sync with head.
 1.41.12.3  27-Oct-2007  yamt sync with head.
 1.41.12.2  30-Dec-2006  yamt sync with head.
 1.41.12.1  21-Jun-2006  yamt sync with head.
 1.42.2.1  01-Feb-2006  yamt sync with head.
 1.43.10.1  31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.43.8.1  19-Apr-2006  elad sync with head - hopefully this will work
 1.43.6.2  14-Sep-2006  yamt sync with head.
 1.43.6.1  01-Apr-2006  yamt sync with head.
 1.43.4.1  22-Apr-2006  simonb Sync with head.
 1.43.2.1  09-Sep-2006  rpaulo sync with head
 1.45.4.1  10-Dec-2006  yamt sync with head.
 1.45.2.1  18-Nov-2006  ad Sync with head.
 1.46.32.1  25-Oct-2007  bouyer Sync with HEAD.
 1.46.30.1  18-Oct-2007  yamt sync with head.
 1.46.28.2  23-Mar-2008  matt sync with HEAD
 1.46.28.1  06-Nov-2007  matt sync with HEAD
 1.46.26.1  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.46.16.8  12-Sep-2007  macallan remove some unused cargo-cult leftover, finish bus_space-ification, fix
some typos. Now UDMA66 with keylargo-ata should work again.
 1.46.16.7  08-Aug-2007  macallan use a level triggered interrupt if the firmware asks us to
 1.46.16.6  08-Aug-2007  macallan get rid of our own bus_space_tag - we provide a bus_space_handle_t for every
single WDC register anyway. Also request an edge-triggered IRQ since some
PIC drivers now actually honour the IRQ type.
 1.46.16.5  02-Aug-2007  macallan set pbs_limit to something sane
 1.46.16.4  02-Aug-2007  macallan adapt to new bus_space, now it works at least on my pb3400c
 1.46.16.3  19-Jun-2007  matt Simplify and don't allocate a separate bus space.
 1.46.16.2  07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.46.16.1  11-May-2007  macallan request the correct interrupt type in a couple drivers - necessary since
these days we actually do something with the type argument
 1.46.8.1  23-Oct-2007  ad Sync with head.
 1.47.16.2  02-Jun-2008  mjf Sync with HEAD.
 1.47.16.1  03-Apr-2008  mjf Sync with HEAD.
 1.47.12.1  24-Mar-2008  keiichi sync with head.
 1.50.4.2  11-Mar-2010  yamt sync with head
 1.50.4.1  16-May-2008  yamt sync with head.
 1.50.2.1  18-May-2008  yamt sync with head.
 1.53.2.1  30-Oct-2012  yamt sync with head
 1.58.20.1  26-Jul-2016  pgoyette Sync with HEAD
 1.58.16.1  05-Oct-2016  skrll Sync with HEAD
 1.58.2.1  03-Dec-2017  jdolecek update from HEAD
 1.59.4.2  27-Sep-2017  jdolecek change wdc_init_shadow_regs() to accept only struct wdc_regs, it doesn't
touch anything else

factor out the probe-only struct ata_channel initialization to wdcprobe(), to
reduce duplication of logic in individual drivers, and to actually work now
that more init is needed beyond the memset()
 1.59.4.1  24-Apr-2017  jdolecek use ata_queue_alloc() to dynamically allocate ata_queue for ata channel
 1.61.16.1  03-Apr-2021  thorpej Sync with HEAD.

RSS XML Feed