Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild
authorLinus Torvalds <torvalds@g5.osdl.org>
Sun, 24 Sep 2006 21:24:14 +0000 (14:24 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 24 Sep 2006 21:24:14 +0000 (14:24 -0700)
* git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild: (28 commits)
  kbuild: add distclean info to 'make help' and more details for 'clean'
  dontdiff: add utsrelease.h
  kbuild: fix "mkdir -p" usage in scripts/package/mkspec
  kbuild: correct and clarify versioning info in Makefile
  kbuild: fixup Documentation/kbuild/modules.txt
  kbuild: Extend kbuild/defconfig tags support to exuberant ctags
  kbuild: fix for some typos in Documentation/makefiles.txt
  kbuild: clarify "make C=" build option
  Documentaion: update Documentation/Changes with minimum versions
  kbuild: update help in top level Makefile
  kbuild: fail kernel compilation in case of unresolved module symbols
  kbuild: remove debug left-over from Makefile.host
  kbuild: create output directory for hostprogs with O=.. build
  kbuild: add missing return statement in modpost.c:secref_whitelist()
  kbuild: preperly align SYSMAP output
  kbuild: make -rR is now default
  kbuild: make V=2 tell why a target is rebuild
  kbuild: modpost on vmlinux regardless of CONFIG_MODULES
  kbuild: ignore references from ".pci_fixup" to ".init.text"
  kbuild: linguistic fixes for Documentation/kbuild/makefiles.txt
  ...

467 files changed:
Documentation/DocBook/libata.tmpl
Documentation/networking/LICENSE.qla3xxx [new file with mode: 0644]
MAINTAINERS
drivers/Kconfig
drivers/Makefile
drivers/ata/Kconfig [new file with mode: 0644]
drivers/ata/Makefile [new file with mode: 0644]
drivers/ata/ahci.c [moved from drivers/scsi/ahci.c with 79% similarity]
drivers/ata/ata_generic.c [new file with mode: 0644]
drivers/ata/ata_piix.c [moved from drivers/scsi/ata_piix.c with 67% similarity]
drivers/ata/libata-core.c [moved from drivers/scsi/libata-core.c with 92% similarity]
drivers/ata/libata-eh.c [moved from drivers/scsi/libata-eh.c with 99% similarity]
drivers/ata/libata-scsi.c [moved from drivers/scsi/libata-scsi.c with 94% similarity]
drivers/ata/libata-sff.c [moved from drivers/scsi/libata-bmdma.c with 89% similarity]
drivers/ata/libata.h [moved from drivers/scsi/libata.h with 94% similarity]
drivers/ata/pata_ali.c [new file with mode: 0644]
drivers/ata/pata_amd.c [new file with mode: 0644]
drivers/ata/pata_artop.c [new file with mode: 0644]
drivers/ata/pata_atiixp.c [new file with mode: 0644]
drivers/ata/pata_cmd64x.c [new file with mode: 0644]
drivers/ata/pata_cs5520.c [new file with mode: 0644]
drivers/ata/pata_cs5530.c [new file with mode: 0644]
drivers/ata/pata_cs5535.c [new file with mode: 0644]
drivers/ata/pata_cypress.c [new file with mode: 0644]
drivers/ata/pata_efar.c [new file with mode: 0644]
drivers/ata/pata_hpt366.c [new file with mode: 0644]
drivers/ata/pata_hpt37x.c [new file with mode: 0644]
drivers/ata/pata_hpt3x2n.c [new file with mode: 0644]
drivers/ata/pata_hpt3x3.c [new file with mode: 0644]
drivers/ata/pata_isapnp.c [new file with mode: 0644]
drivers/ata/pata_it821x.c [new file with mode: 0644]
drivers/ata/pata_jmicron.c [new file with mode: 0644]
drivers/ata/pata_legacy.c [new file with mode: 0644]
drivers/ata/pata_mpiix.c [new file with mode: 0644]
drivers/ata/pata_netcell.c [new file with mode: 0644]
drivers/ata/pata_ns87410.c [new file with mode: 0644]
drivers/ata/pata_oldpiix.c [new file with mode: 0644]
drivers/ata/pata_opti.c [new file with mode: 0644]
drivers/ata/pata_optidma.c [new file with mode: 0644]
drivers/ata/pata_pcmcia.c [new file with mode: 0644]
drivers/ata/pata_pdc2027x.c [new file with mode: 0644]
drivers/ata/pata_pdc202xx_old.c [new file with mode: 0644]
drivers/ata/pata_qdi.c [new file with mode: 0644]
drivers/ata/pata_radisys.c [new file with mode: 0644]
drivers/ata/pata_rz1000.c [new file with mode: 0644]
drivers/ata/pata_sc1200.c [new file with mode: 0644]
drivers/ata/pata_serverworks.c [new file with mode: 0644]
drivers/ata/pata_sil680.c [new file with mode: 0644]
drivers/ata/pata_sis.c [new file with mode: 0644]
drivers/ata/pata_sl82c105.c [new file with mode: 0644]
drivers/ata/pata_triflex.c [new file with mode: 0644]
drivers/ata/pata_via.c [new file with mode: 0644]
drivers/ata/pdc_adma.c [moved from drivers/scsi/pdc_adma.c with 93% similarity]
drivers/ata/sata_mv.c [moved from drivers/scsi/sata_mv.c with 96% similarity]
drivers/ata/sata_nv.c [moved from drivers/scsi/sata_nv.c with 91% similarity]
drivers/ata/sata_promise.c [moved from drivers/scsi/sata_promise.c with 93% similarity]
drivers/ata/sata_promise.h [moved from drivers/scsi/sata_promise.h with 100% similarity]
drivers/ata/sata_qstor.c [moved from drivers/scsi/sata_qstor.c with 93% similarity]
drivers/ata/sata_sil.c [moved from drivers/scsi/sata_sil.c with 93% similarity]
drivers/ata/sata_sil24.c [moved from drivers/scsi/sata_sil24.c with 95% similarity]
drivers/ata/sata_sis.c [moved from drivers/scsi/sata_sis.c with 94% similarity]
drivers/ata/sata_svw.c [moved from drivers/scsi/sata_svw.c with 98% similarity]
drivers/ata/sata_sx4.c [moved from drivers/scsi/sata_sx4.c with 96% similarity]
drivers/ata/sata_uli.c [moved from drivers/scsi/sata_uli.c with 96% similarity]
drivers/ata/sata_via.c [moved from drivers/scsi/sata_via.c with 98% similarity]
drivers/ata/sata_vsc.c [moved from drivers/scsi/sata_vsc.c with 97% similarity]
drivers/isdn/i4l/Kconfig
drivers/net/3c501.c
drivers/net/3c501.h
drivers/net/3c503.c
drivers/net/3c503.h
drivers/net/3c505.c
drivers/net/3c505.h
drivers/net/3c507.c
drivers/net/3c509.c
drivers/net/3c515.c
drivers/net/3c523.c
drivers/net/3c523.h
drivers/net/3c527.c
drivers/net/3c527.h
drivers/net/3c59x.c
drivers/net/7990.c
drivers/net/7990.h
drivers/net/8139cp.c
drivers/net/8139too.c
drivers/net/82596.c
drivers/net/8390.c
drivers/net/8390.h
drivers/net/Kconfig
drivers/net/Makefile
drivers/net/Space.c
drivers/net/a2065.c
drivers/net/a2065.h
drivers/net/ac3200.c
drivers/net/acenic.c
drivers/net/acenic.h
drivers/net/acenic_firmware.h
drivers/net/amd8111e.c
drivers/net/amd8111e.h
drivers/net/apne.c
drivers/net/arcnet/com20020-pci.c
drivers/net/ariadne.c
drivers/net/arm/Kconfig
drivers/net/arm/Makefile
drivers/net/arm/at91_ether.c
drivers/net/arm/ep93xx_eth.c [new file with mode: 0644]
drivers/net/arm/etherh.c
drivers/net/at1700.c
drivers/net/atari_bionet.c
drivers/net/atari_pamsnet.c
drivers/net/atarilance.c
drivers/net/atp.c
drivers/net/au1000_eth.c
drivers/net/au1000_eth.h
drivers/net/b44.c
drivers/net/bmac.c
drivers/net/bmac.h
drivers/net/bnx2.c
drivers/net/bnx2.h
drivers/net/bonding/bond_main.c
drivers/net/bsd_comp.c
drivers/net/cassini.c
drivers/net/cassini.h
drivers/net/chelsio/cxgb2.c
drivers/net/cris/eth_v10.c
drivers/net/cs89x0.c
drivers/net/cs89x0.h
drivers/net/de600.c
drivers/net/de620.c
drivers/net/declance.c
drivers/net/defxx.c
drivers/net/defxx.h
drivers/net/depca.c
drivers/net/depca.h
drivers/net/dgrs.c
drivers/net/dgrs.h
drivers/net/dgrs_asstruct.h
drivers/net/dgrs_bcomm.h
drivers/net/dgrs_ether.h
drivers/net/dgrs_i82596.h
drivers/net/dl2k.c
drivers/net/dl2k.h
drivers/net/dummy.c
drivers/net/e100.c
drivers/net/e1000/e1000.h
drivers/net/e1000/e1000_ethtool.c
drivers/net/e1000/e1000_hw.c
drivers/net/e1000/e1000_hw.h
drivers/net/e1000/e1000_main.c
drivers/net/e1000/e1000_osdep.h
drivers/net/e1000/e1000_param.c
drivers/net/e2100.c
drivers/net/eepro.c
drivers/net/eepro100.c
drivers/net/eexpress.c
drivers/net/eexpress.h
drivers/net/ehea/Makefile [new file with mode: 0644]
drivers/net/ehea/ehea.h [new file with mode: 0644]
drivers/net/ehea/ehea_ethtool.c [new file with mode: 0644]
drivers/net/ehea/ehea_hcall.h [new file with mode: 0644]
drivers/net/ehea/ehea_hw.h [new file with mode: 0644]
drivers/net/ehea/ehea_main.c [new file with mode: 0644]
drivers/net/ehea/ehea_phyp.c [new file with mode: 0644]
drivers/net/ehea/ehea_phyp.h [new file with mode: 0644]
drivers/net/ehea/ehea_qmr.c [new file with mode: 0644]
drivers/net/ehea/ehea_qmr.h [new file with mode: 0644]
drivers/net/epic100.c
drivers/net/eql.c
drivers/net/eth16i.c
drivers/net/ewrk3.c
drivers/net/ewrk3.h
drivers/net/fealnx.c
drivers/net/fec.c
drivers/net/fec_8xx/fec_main.c
drivers/net/forcedeth.c
drivers/net/fs_enet/fs_enet-main.c
drivers/net/gianfar.c
drivers/net/gianfar.h
drivers/net/gianfar_ethtool.c
drivers/net/gianfar_mii.c
drivers/net/gianfar_mii.h
drivers/net/gianfar_sysfs.c
drivers/net/gt64240eth.h
drivers/net/gt96100eth.c [deleted file]
drivers/net/gt96100eth.h [deleted file]
drivers/net/hamachi.c
drivers/net/hp-plus.c
drivers/net/hp.c
drivers/net/hp100.c
drivers/net/hp100.h
drivers/net/hplance.c
drivers/net/ibm_emac/ibm_emac_core.c
drivers/net/ibmveth.c
drivers/net/ifb.c
drivers/net/ioc3-eth.c
drivers/net/irda/mcs7780.c
drivers/net/irda/w83977af_ir.c
drivers/net/isa-skeleton.c
drivers/net/iseries_veth.c
drivers/net/ixgb/ixgb.h
drivers/net/ixgb/ixgb_ethtool.c
drivers/net/ixgb/ixgb_hw.c
drivers/net/ixgb/ixgb_ids.h
drivers/net/ixgb/ixgb_main.c
drivers/net/ixgb/ixgb_osdep.h
drivers/net/jazzsonic.c
drivers/net/lance.c
drivers/net/lasi_82596.c
drivers/net/lne390.c
drivers/net/loopback.c
drivers/net/lp486e.c
drivers/net/mac8390.c
drivers/net/mac89x0.c
drivers/net/mace.c
drivers/net/macmace.c
drivers/net/macsonic.c
drivers/net/meth.c
drivers/net/mii.c
drivers/net/mv643xx_eth.c
drivers/net/myri10ge/myri10ge.c
drivers/net/myri10ge/myri10ge_mcp.h
drivers/net/myri_code.h
drivers/net/myri_sbus.c
drivers/net/natsemi.c
drivers/net/ne-h8300.c
drivers/net/ne.c
drivers/net/ne2.c
drivers/net/ne2k-pci.c
drivers/net/ne3210.c
drivers/net/netx-eth.c
drivers/net/ni5010.c
drivers/net/ni52.c
drivers/net/ni52.h
drivers/net/ni65.c
drivers/net/ni65.h
drivers/net/ns83820.c
drivers/net/oaknet.c
drivers/net/pci-skeleton.c
drivers/net/pcmcia/3c574_cs.c
drivers/net/pcmcia/3c589_cs.c
drivers/net/pcmcia/axnet_cs.c
drivers/net/pcmcia/fmvj18x_cs.c
drivers/net/pcmcia/ibmtr_cs.c
drivers/net/pcmcia/nmclan_cs.c
drivers/net/pcmcia/pcnet_cs.c
drivers/net/pcmcia/smc91c92_cs.c
drivers/net/pcmcia/xirc2ps_cs.c
drivers/net/pcnet32.c
drivers/net/phy/fixed.c
drivers/net/phy/smsc.c
drivers/net/phy/vitesse.c
drivers/net/plip.c
drivers/net/ppp_async.c
drivers/net/ppp_deflate.c
drivers/net/ppp_generic.c
drivers/net/ppp_synctty.c
drivers/net/pppoe.c
drivers/net/qla3xxx.c [new file with mode: 0644]
drivers/net/qla3xxx.h [new file with mode: 0644]
drivers/net/r8169.c
drivers/net/rionet.c
drivers/net/rrunner.c
drivers/net/rrunner.h
drivers/net/s2io-regs.h
drivers/net/s2io.c
drivers/net/s2io.h
drivers/net/saa9730.c
drivers/net/saa9730.h
drivers/net/sb1000.c
drivers/net/sb1250-mac.c
drivers/net/seeq8005.c
drivers/net/seeq8005.h
drivers/net/sgiseeq.h
drivers/net/shaper.c
drivers/net/sis190.c
drivers/net/sis900.c
drivers/net/sis900.h
drivers/net/sk98lin/skethtool.c
drivers/net/sk98lin/skge.c
drivers/net/sk_mca.c
drivers/net/sk_mca.h
drivers/net/skfp/skfddi.c
drivers/net/skge.c
drivers/net/skge.h
drivers/net/sky2.c
drivers/net/sky2.h
drivers/net/slhc.c
drivers/net/slip.c
drivers/net/slip.h
drivers/net/smc-mca.c
drivers/net/smc-ultra.c
drivers/net/smc-ultra32.c
drivers/net/smc911x.c
drivers/net/smc9194.c
drivers/net/smc9194.h
drivers/net/smc91x.c
drivers/net/sonic.c
drivers/net/sonic.h
drivers/net/spider_net.c
drivers/net/spider_net.h
drivers/net/spider_net_ethtool.c
drivers/net/starfire.c
drivers/net/stnic.c
drivers/net/sun3_82586.c
drivers/net/sun3_82586.h
drivers/net/sun3lance.c
drivers/net/sunbmac.c
drivers/net/sundance.c
drivers/net/sungem.c
drivers/net/sungem.h
drivers/net/sungem_phy.c
drivers/net/sungem_phy.h
drivers/net/sunhme.c
drivers/net/sunlance.c
drivers/net/sunqe.c
drivers/net/tc35815.c
drivers/net/tg3.c
drivers/net/tlan.c
drivers/net/tlan.h
drivers/net/tokenring/3c359.c
drivers/net/tokenring/lanstreamer.c
drivers/net/tulip/21142.c
drivers/net/tulip/de2104x.c
drivers/net/tulip/de4x5.c
drivers/net/tulip/dmfe.c
drivers/net/tulip/eeprom.c
drivers/net/tulip/interrupt.c
drivers/net/tulip/media.c
drivers/net/tulip/pnic.c
drivers/net/tulip/pnic2.c
drivers/net/tulip/timer.c
drivers/net/tulip/tulip.h
drivers/net/tulip/tulip_core.c
drivers/net/tulip/uli526x.c
drivers/net/tulip/winbond-840.c
drivers/net/tulip/xircom_cb.c
drivers/net/tulip/xircom_tulip_cb.c
drivers/net/tun.c
drivers/net/typhoon-firmware.h
drivers/net/typhoon.c
drivers/net/typhoon.h
drivers/net/ucc_geth.c
drivers/net/via-rhine.c
drivers/net/via-velocity.c
drivers/net/via-velocity.h
drivers/net/wan/cycx_main.c
drivers/net/wan/dlci.c
drivers/net/wan/dscc4.c
drivers/net/wan/farsync.c
drivers/net/wan/lmc/lmc_main.c
drivers/net/wan/pc300_drv.c
drivers/net/wan/pci200syn.c
drivers/net/wan/sdla.c
drivers/net/wan/wanxl.c
drivers/net/wd.c
drivers/net/wireless/Kconfig
drivers/net/wireless/airo.c
drivers/net/wireless/atmel_pci.c
drivers/net/wireless/bcm43xx/bcm43xx.h
drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
drivers/net/wireless/bcm43xx/bcm43xx_debugfs.h
drivers/net/wireless/bcm43xx/bcm43xx_dma.c
drivers/net/wireless/bcm43xx/bcm43xx_dma.h
drivers/net/wireless/bcm43xx/bcm43xx_ethtool.c
drivers/net/wireless/bcm43xx/bcm43xx_ethtool.h
drivers/net/wireless/bcm43xx/bcm43xx_leds.c
drivers/net/wireless/bcm43xx/bcm43xx_main.c
drivers/net/wireless/bcm43xx/bcm43xx_main.h
drivers/net/wireless/bcm43xx/bcm43xx_phy.c
drivers/net/wireless/bcm43xx/bcm43xx_pio.c
drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c
drivers/net/wireless/bcm43xx/bcm43xx_wx.c
drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
drivers/net/wireless/hostap/hostap.h
drivers/net/wireless/hostap/hostap_cs.c
drivers/net/wireless/hostap/hostap_ioctl.c
drivers/net/wireless/ipw2100.c
drivers/net/wireless/ipw2200.c
drivers/net/wireless/ipw2200.h
drivers/net/wireless/orinoco.c
drivers/net/wireless/orinoco.h
drivers/net/wireless/orinoco_nortel.c
drivers/net/wireless/orinoco_pci.c
drivers/net/wireless/orinoco_plx.c
drivers/net/wireless/orinoco_tmd.c
drivers/net/wireless/prism54/isl_ioctl.c
drivers/net/wireless/prism54/isl_ioctl.h
drivers/net/wireless/prism54/islpci_dev.c
drivers/net/wireless/prism54/islpci_dev.h
drivers/net/wireless/prism54/islpci_hotplug.c
drivers/net/wireless/ray_cs.c
drivers/net/wireless/wavelan_cs.c
drivers/net/wireless/wl3501_cs.c
drivers/net/wireless/zd1211rw/Makefile
drivers/net/wireless/zd1211rw/zd_chip.c
drivers/net/wireless/zd1211rw/zd_chip.h
drivers/net/wireless/zd1211rw/zd_def.h
drivers/net/wireless/zd1211rw/zd_ieee80211.h
drivers/net/wireless/zd1211rw/zd_mac.c
drivers/net/wireless/zd1211rw/zd_mac.h
drivers/net/wireless/zd1211rw/zd_netdev.c
drivers/net/wireless/zd1211rw/zd_rf.c
drivers/net/wireless/zd1211rw/zd_rf.h
drivers/net/wireless/zd1211rw/zd_rf_al2230.c
drivers/net/wireless/zd1211rw/zd_rf_al7230b.c [new file with mode: 0644]
drivers/net/wireless/zd1211rw/zd_usb.c
drivers/net/wireless/zd1211rw/zd_usb.h
drivers/net/yellowfin.c
drivers/net/znet.c
drivers/pci/quirks.c
drivers/scsi/Kconfig
drivers/scsi/Makefile
fs/affs/affs.h
fs/affs/super.c
fs/autofs/autofs_i.h
fs/autofs/inode.c
fs/autofs4/autofs_i.h
fs/autofs4/inode.c
fs/hpfs/hpfs_fn.h
fs/hpfs/super.c
fs/openpromfs/inode.c
include/asm-alpha/libata-portmap.h [new file with mode: 0644]
include/asm-arm/arch-ep93xx/ep93xx-regs.h
include/asm-arm/arch-ep93xx/platform.h
include/asm-generic/libata-portmap.h [new file with mode: 0644]
include/asm-i386/libata-portmap.h [new file with mode: 0644]
include/asm-ia64/libata-portmap.h [new file with mode: 0644]
include/asm-powerpc/libata-portmap.h [new file with mode: 0644]
include/asm-sparc/libata-portmap.h [new file with mode: 0644]
include/asm-sparc64/libata-portmap.h [new file with mode: 0644]
include/asm-x86_64/libata-portmap.h [new file with mode: 0644]
include/linux/Kbuild
include/linux/adfs_fs.h
include/linux/affs_fs.h [deleted file]
include/linux/ata.h
include/linux/coda_psdev.h
include/linux/efs_fs_sb.h
include/linux/ext2_fs.h
include/linux/ext3_fs.h
include/linux/hpfs_fs.h [deleted file]
include/linux/iso_fs.h
include/linux/jffs2.h
include/linux/libata.h
include/linux/magic.h [new file with mode: 0644]
include/linux/minix_fs.h
include/linux/msdos_fs.h
include/linux/ncp_fs.h
include/linux/netdevice.h
include/linux/nfs_fs.h
include/linux/openprom_fs.h [deleted file]
include/linux/proc_fs.h
include/linux/qnx4_fs.h
include/linux/reiserfs_fs.h
include/linux/smb.h
include/linux/usbdevice_fs.h
include/net/ieee80211.h
include/net/ieee80211softmac.h
net/core/ethtool.c
net/ieee80211/ieee80211_crypt_ccmp.c
net/ieee80211/ieee80211_crypt_tkip.c
net/ieee80211/ieee80211_crypt_wep.c
net/ieee80211/ieee80211_rx.c
net/ieee80211/ieee80211_tx.c
net/ieee80211/softmac/ieee80211softmac_assoc.c
net/ieee80211/softmac/ieee80211softmac_io.c
net/ieee80211/softmac/ieee80211softmac_module.c
net/ieee80211/softmac/ieee80211softmac_priv.h

index e97c3231454173e938f9554929420c441683a9de..065e8dc23e3adb4bd3d5d659ddf2a80741261b3a 100644 (file)
@@ -868,18 +868,18 @@ and other resources, etc.
 
   <chapter id="libataExt">
      <title>libata Library</title>
-!Edrivers/scsi/libata-core.c
+!Edrivers/ata/libata-core.c
   </chapter>
 
   <chapter id="libataInt">
      <title>libata Core Internals</title>
-!Idrivers/scsi/libata-core.c
+!Idrivers/ata/libata-core.c
   </chapter>
 
   <chapter id="libataScsiInt">
      <title>libata SCSI translation/emulation</title>
-!Edrivers/scsi/libata-scsi.c
-!Idrivers/scsi/libata-scsi.c
+!Edrivers/ata/libata-scsi.c
+!Idrivers/ata/libata-scsi.c
   </chapter>
 
   <chapter id="ataExceptions">
@@ -1600,12 +1600,12 @@ and other resources, etc.
 
   <chapter id="PiixInt">
      <title>ata_piix Internals</title>
-!Idrivers/scsi/ata_piix.c
+!Idrivers/ata/ata_piix.c
   </chapter>
 
   <chapter id="SILInt">
      <title>sata_sil Internals</title>
-!Idrivers/scsi/sata_sil.c
+!Idrivers/ata/sata_sil.c
   </chapter>
 
   <chapter id="libataThanks">
diff --git a/Documentation/networking/LICENSE.qla3xxx b/Documentation/networking/LICENSE.qla3xxx
new file mode 100644 (file)
index 0000000..2f2077e
--- /dev/null
@@ -0,0 +1,46 @@
+Copyright (c)  2003-2006 QLogic Corporation
+QLogic Linux Networking HBA Driver
+
+This program includes a device driver for Linux 2.6 that may be
+distributed with QLogic hardware specific firmware binary file.
+You may modify and redistribute the device driver code under the
+GNU General Public License as published by the Free Software
+Foundation (version 2 or a later version).
+
+You may redistribute the hardware specific firmware binary file
+under the following terms:
+
+       1. Redistribution of source code (only if applicable),
+          must retain the above copyright notice, this list of
+          conditions and the following disclaimer.
+
+       2. Redistribution in binary form must reproduce the above
+          copyright notice, this list of conditions and the
+          following disclaimer in the documentation and/or other
+          materials provided with the distribution.
+
+       3. The name of QLogic Corporation may not be used to
+          endorse or promote products derived from this software
+          without specific prior written permission
+
+REGARDLESS OF WHAT LICENSING MECHANISM IS USED OR APPLICABLE,
+THIS PROGRAM IS PROVIDED BY QLOGIC CORPORATION "AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+USER ACKNOWLEDGES AND AGREES THAT USE OF THIS PROGRAM WILL NOT
+CREATE OR GIVE GROUNDS FOR A LICENSE BY IMPLICATION, ESTOPPEL, OR
+OTHERWISE IN ANY INTELLECTUAL PROPERTY RIGHTS (PATENT, COPYRIGHT,
+TRADE SECRET, MASK WORK, OR OTHER PROPRIETARY RIGHT) EMBODIED IN
+ANY OTHER QLOGIC HARDWARE OR SOFTWARE EITHER SOLELY OR IN
+COMBINATION WITH THIS PROGRAM.
+
index ed9757ee4a67ee522d903396bee78ac83da62e7e..16af51ba44a53113d8d7bc0c6b7a3f88700592a5 100644 (file)
@@ -457,9 +457,9 @@ L:  linux-hams@vger.kernel.org
 W:     http://www.baycom.org/~tom/ham/ham.html
 S:     Maintained
 
-BCM43XX WIRELESS DRIVER
-P:     Michael Buesch
-M:     mb@bu3sch.de
+BCM43XX WIRELESS DRIVER (SOFTMAC BASED VERSION)
+P:     Larry Finger
+M:     Larry.Finger@lwfinger.net
 P:     Stefano Brivio
 M:     st3@riseup.net
 W:     http://bcm43xx.berlios.de/
@@ -2389,6 +2389,12 @@ M:       linux-driver@qlogic.com
 L:     linux-scsi@vger.kernel.org
 S:     Supported
 
+QLOGIC QLA3XXX NETWORK DRIVER
+P:     Ron Mercer
+M:     linux-driver@qlogic.com
+L:     netdev@vger.kernel.org
+S:     Supported
+
 QNX4 FILESYSTEM
 P:     Anders Larsen
 M:     al@alarsen.net
@@ -2641,6 +2647,18 @@ P:       Nicolas Pitre
 M:     nico@cam.org
 S:     Maintained
 
+SOFTMAC LAYER (IEEE 802.11)
+P:     Johannes Berg
+M:     johannes@sipsolutions.net
+P:     Joe Jezak
+M:     josejx@gentoo.org
+P:     Daniel Drake
+M:     dsd@gentoo.org
+W:     http://softmac.sipsolutions.net/
+L:     softmac-dev@sipsolutions.net
+L:     netdev@vger.kernel.org
+S:     Maintained
+
 SOFTWARE RAID (Multiple Disks) SUPPORT
 P:     Ingo Molnar
 M:     mingo@redhat.com
@@ -2922,8 +2940,8 @@ W:        http://www.auk.cx/tms380tr/
 S:     Maintained
 
 TULIP NETWORK DRIVER
-P:     Jeff Garzik
-M:     jgarzik@pobox.com
+P:     Valerie Henson
+M:     val_henson@linux.intel.com
 L:     tulip-users@lists.sourceforge.net
 W:     http://sourceforge.net/projects/tulip/
 S:     Maintained
@@ -3374,6 +3392,15 @@ W:       http://www.qsl.net/dl1bke/
 L:     linux-hams@vger.kernel.org
 S:     Maintained
 
+ZD1211RW WIRELESS DRIVER
+P:     Daniel Drake
+M:     dsd@gentoo.org
+P:     Ulrich Kunitz
+M:     kune@deine-taler.de
+W:     http://zd1211.ath.cx/wiki/DriverRewrite
+L:     zd1211-devs@lists.sourceforge.net (subscribers-only)
+S:     Maintained
+
 ZF MACHZ WATCHDOG
 P:     Fernando Fuganti
 M:     fuganti@netbank.com.br
index 8b11cebe65df5ad396f8fb975e158466f9dd859b..263e86ddc1a4d0740b3e524ced6703d3a991f3d2 100644 (file)
@@ -18,6 +18,8 @@ source "drivers/ide/Kconfig"
 
 source "drivers/scsi/Kconfig"
 
+source "drivers/ata/Kconfig"
+
 source "drivers/cdrom/Kconfig"
 
 source "drivers/md/Kconfig"
index fc2d744a4e4a75e3960589df663a84650c9a85b7..4ac14dab3079f8b8910a19d733d1ba2692d41c0b 100644 (file)
@@ -34,6 +34,7 @@ obj-$(CONFIG_PPC_PMAC)                += macintosh/
 obj-$(CONFIG_IDE)              += ide/
 obj-$(CONFIG_FC4)              += fc4/
 obj-$(CONFIG_SCSI)             += scsi/
+obj-$(CONFIG_ATA)              += ata/
 obj-$(CONFIG_FUSION)           += message/
 obj-$(CONFIG_IEEE1394)         += ieee1394/
 obj-y                          += cdrom/
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
new file mode 100644 (file)
index 0000000..5a8bdac
--- /dev/null
@@ -0,0 +1,484 @@
+#
+# SATA/PATA driver configuration
+#
+
+menu "Serial ATA (prod) and Parallel ATA (experimental) drivers"
+
+config ATA
+       tristate "ATA device support"
+       select SCSI
+       ---help---
+         If you want to use a ATA hard disk, ATA tape drive, ATA CD-ROM or
+         any other ATA device under Linux, say Y and make sure that you know
+         the name of your ATA host adapter (the card inside your computer
+         that "speaks" the ATA protocol, also called ATA controller),
+         because you will be asked for it.
+
+if ATA
+
+config SATA_AHCI
+       tristate "AHCI SATA support"
+       depends on PCI
+       help
+         This option enables support for AHCI Serial ATA.
+
+         If unsure, say N.
+
+config SATA_SVW
+       tristate "ServerWorks Frodo / Apple K2 SATA support"
+       depends on PCI
+       help
+         This option enables support for Broadcom/Serverworks/Apple K2
+         SATA support.
+
+         If unsure, say N.
+
+config ATA_PIIX
+       tristate "Intel PIIX/ICH SATA support"
+       depends on PCI
+       help
+         This option enables support for ICH5/6/7/8 Serial ATA.
+         If PATA support was enabled previously, this enables
+         support for select Intel PIIX/ICH PATA host controllers.
+
+         If unsure, say N.
+
+config SATA_MV
+       tristate "Marvell SATA support (HIGHLY EXPERIMENTAL)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the Marvell Serial ATA family.
+         Currently supports 88SX[56]0[48][01] chips.
+
+         If unsure, say N.
+
+config SATA_NV
+       tristate "NVIDIA SATA support"
+       depends on PCI
+       help
+         This option enables support for NVIDIA Serial ATA.
+
+         If unsure, say N.
+
+config PDC_ADMA
+       tristate "Pacific Digital ADMA support"
+       depends on PCI
+       help
+         This option enables support for Pacific Digital ADMA controllers
+
+         If unsure, say N.
+
+config SATA_QSTOR
+       tristate "Pacific Digital SATA QStor support"
+       depends on PCI
+       help
+         This option enables support for Pacific Digital Serial ATA QStor.
+
+         If unsure, say N.
+
+config SATA_PROMISE
+       tristate "Promise SATA TX2/TX4 support"
+       depends on PCI
+       help
+         This option enables support for Promise Serial ATA TX2/TX4.
+
+         If unsure, say N.
+
+config SATA_SX4
+       tristate "Promise SATA SX4 support"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for Promise Serial ATA SX4.
+
+         If unsure, say N.
+
+config SATA_SIL
+       tristate "Silicon Image SATA support"
+       depends on PCI
+       help
+         This option enables support for Silicon Image Serial ATA.
+
+         If unsure, say N.
+
+config SATA_SIL24
+       tristate "Silicon Image 3124/3132 SATA support"
+       depends on PCI
+       help
+         This option enables support for Silicon Image 3124/3132 Serial ATA.
+
+         If unsure, say N.
+
+config SATA_SIS
+       tristate "SiS 964/180 SATA support"
+       depends on PCI
+       help
+         This option enables support for SiS Serial ATA 964/180.
+
+         If unsure, say N.
+
+config SATA_ULI
+       tristate "ULi Electronics SATA support"
+       depends on PCI
+       help
+         This option enables support for ULi Electronics SATA.
+
+         If unsure, say N.
+
+config SATA_VIA
+       tristate "VIA SATA support"
+       depends on PCI
+       help
+         This option enables support for VIA Serial ATA.
+
+         If unsure, say N.
+
+config SATA_VITESSE
+       tristate "VITESSE VSC-7174 / INTEL 31244 SATA support"
+       depends on PCI
+       help
+         This option enables support for Vitesse VSC7174 and Intel 31244 Serial ATA.
+
+         If unsure, say N.
+
+config SATA_INTEL_COMBINED
+       bool
+       depends on IDE=y && !BLK_DEV_IDE_SATA && (SATA_AHCI || ATA_PIIX)
+       default y
+
+config PATA_ALI
+       tristate "ALi PATA support (Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the ALi ATA interfaces
+         found on the many ALi chipsets.
+
+         If unsure, say N.
+
+config PATA_AMD
+       tristate "AMD/NVidia PATA support (Experimental)"
+       depends on PCI
+       help
+         This option enables support for the AMD and NVidia PATA
+         interfaces found on the chipsets for Athlon/Athlon64.
+
+         If unsure, say N.
+
+config PATA_ARTOP
+       tristate "ARTOP 6210/6260 PATA support (Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for ARTOP PATA controllers.
+
+         If unsure, say N.
+
+config PATA_ATIIXP
+       tristate "ATI PATA support (Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the ATI ATA interfaces
+         found on the many ATI chipsets.
+
+         If unsure, say N.
+
+config PATA_CMD64X
+       tristate "CMD64x PATA support (Very Experimental)"
+       depends on PCI&& EXPERIMENTAL
+       help
+         This option enables support for the CMD64x series chips
+         except for the CMD640.
+
+         If unsure, say N.
+
+config PATA_CS5520
+       tristate "CS5510/5520 PATA support"
+       depends on PCI
+       help
+         This option enables support for the Cyrix 5510/5520
+         companion chip used with the MediaGX/Geode processor family.
+
+         If unsure, say N.
+
+config PATA_CS5530
+       tristate "CS5530 PATA support (Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the Cyrix/NatSemi/AMD CS5530
+         companion chip used with the MediaGX/Geode processor family.
+
+         If unsure, say N.
+
+config PATA_CS5535
+       tristate "CS5535 PATA support (Experimental)"
+       depends on PCI && X86 && !X86_64 && EXPERIMENTAL
+       help
+         This option enables support for the NatSemi/AMD CS5535
+         companion chip used with the Geode processor family.
+
+         If unsure, say N.
+
+config PATA_CYPRESS
+       tristate "Cypress CY82C693 PATA support (Very Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the Cypress/Contaq CY82C693
+         chipset found in some Alpha systems
+
+         If unsure, say N.
+
+config PATA_EFAR
+       tristate "EFAR SLC90E66 support"
+       depends on PCI
+       help
+         This option enables support for the EFAR SLC90E66
+         IDE controller found on some older machines.
+
+         If unsure, say N.
+
+config ATA_GENERIC
+       tristate "Generic ATA support"
+       depends on PCI
+       help
+         This option enables support for generic BIOS configured
+         ATA controllers via the new ATA layer
+
+         If unsure, say N.
+
+config PATA_HPT366
+       tristate "HPT 366/368 PATA support (Very Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the HPT 366 and 368
+         PATA controllers via the new ATA layer.
+
+         If unsure, say N.
+
+config PATA_HPT37X
+       tristate "HPT 370/370A/371/372/374/302 PATA support (Very Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the majority of the later HPT
+         PATA controllers via the new ATA layer.
+
+         If unsure, say N.
+
+config PATA_HPT3X2N
+       tristate "HPT 372N/302N PATA support (Very Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the N variant HPT PATA
+         controllers via the new ATA layer
+
+         If unsure, say N.
+
+config PATA_HPT3X3
+       tristate "HPT 343/363 PATA support (Experimental)"
+       depends on PCI
+       help
+         This option enables support for the HPT 343/363
+         PATA controllers via the new ATA layer
+
+         If unsure, say N.
+
+config PATA_ISAPNP
+       tristate "ISA Plug and Play PATA support (Very Experimental)"
+       depends on EXPERIMENTAL && ISAPNP
+       help
+         This option enables support for ISA plug & play ATA
+         controllers such as those found on old soundcards.
+
+         If unsure, say N.
+
+config PATA_IT821X
+       tristate "IT821x PATA support (Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the ITE 8211 and 8212
+         PATA controllers via the new ATA layer, including RAID
+         mode.
+
+         If unsure, say N.
+
+config PATA_JMICRON
+       tristate "JMicron PATA support"
+       depends on PCI
+       help
+         Enable support for the JMicron IDE controller, via the new
+         ATA layer.
+
+         If unsure, say N.
+
+config PATA_LEGACY
+       tristate "Legacy ISA PATA support (Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for ISA/VLB bus legacy PATA
+         ports and allows them to be accessed via the new ATA layer.
+
+         If unsure, say N.
+
+config PATA_TRIFLEX
+       tristate "Compaq Triflex PATA support"
+       depends on PCI
+       help
+         Enable support for the Compaq 'Triflex' IDE controller as found
+         on many Compaq Pentium-Pro systems, via the new ATA layer.
+
+         If unsure, say N.
+
+config PATA_MPIIX
+       tristate "Intel PATA MPIIX support"
+       depends on PCI
+       help
+         This option enables support for MPIIX PATA support.
+
+         If unsure, say N.
+
+config PATA_OLDPIIX
+       tristate "Intel PATA old PIIX support (Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for old(?) PIIX PATA support.
+
+         If unsure, say N.
+
+config PATA_NETCELL
+       tristate "NETCELL Revolution RAID support"
+       depends on PCI
+       help
+         This option enables support for the Netcell Revolution RAID
+         PATA controller.
+
+         If unsure, say N.
+
+config PATA_NS87410
+       tristate "Nat Semi NS87410 PATA support (Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the National Semiconductor
+         NS87410 PCI-IDE controller.
+
+         If unsure, say N.
+
+config PATA_OPTI
+       tristate "OPTI621/6215 PATA support (Very Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables full PIO support for the early Opti ATA
+         controllers found on some old motherboards.
+
+         If unsure, say N.
+
+config PATA_OPTIDMA
+       tristate "OPTI FireStar PATA support (Veyr Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables DMA/PIO support for the later OPTi
+         controllers found on some old motherboards and in some
+         latops
+
+         If unsure, say N.
+
+config PATA_PCMCIA
+       tristate "PCMCIA PATA support"
+       depends on PCMCIA
+       help
+         This option enables support for PCMCIA ATA interfaces, including
+         compact flash card adapters via the new ATA layer.
+
+         If unsure, say N.
+
+config PATA_PDC_OLD
+       tristate "Older Promise PATA controller support (Very Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the Promise 20246, 20262, 20263,
+         20265 and 20267 adapters.
+
+         If unsure, say N.
+
+config PATA_QDI
+       tristate "QDI VLB PATA support"
+       help
+         Support for QDI 6500 and 6580 PATA controllers on VESA local bus.
+
+config PATA_RADISYS
+       tristate "RADISYS 82600 PATA support (Very experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the RADISYS 82600
+         PATA controllers via the new ATA layer
+
+         If unsure, say N.
+
+config PATA_RZ1000
+       tristate "PC Tech RZ1000 PATA support"
+       depends on PCI
+       help
+         This option enables basic support for the PC Tech RZ1000/1
+         PATA controllers via the new ATA layer
+
+         If unsure, say N.
+
+config PATA_SC1200
+       tristate "SC1200 PATA support (Raving Lunatic)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the NatSemi/AMD SC1200 SoC
+         companion chip used with the Geode processor family.
+
+         If unsure, say N.
+
+config PATA_SERVERWORKS
+       tristate "SERVERWORKS OSB4/CSB5/CSB6/HT1000 PATA support (Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for the Serverworks OSB4/CSB5/CSB6 and
+         HT1000 PATA controllers, via the new ATA layer.
+
+         If unsure, say N.
+
+config PATA_PDC2027X
+       tristate "Promise PATA 2027x support"
+       depends on PCI
+       help
+         This option enables support for Promise PATA pdc20268 to pdc20277 host adapters.
+
+         If unsure, say N.
+
+config PATA_SIL680
+       tristate "CMD / Silicon Image 680 PATA support"
+       depends on PCI
+       help
+         This option enables support for CMD / Silicon Image 680 PATA.
+
+         If unsure, say N.
+
+config PATA_SIS
+       tristate "SiS PATA support (Experimental)"
+       depends on PCI && EXPERIMENTAL
+       help
+         This option enables support for SiS PATA controllers
+
+         If unsure, say N.
+
+config PATA_VIA
+       tristate "VIA PATA support"
+       depends on PCI
+       help
+         This option enables support for the VIA PATA interfaces
+         found on the many VIA chipsets.
+
+         If unsure, say N.
+
+config PATA_WINBOND
+       tristate "Winbond SL82C105 PATA support"
+       depends on PCI
+       help
+         This option enables support for SL82C105 PATA devices found in the
+         Netwinder and some other systems
+
+         If unsure, say N.
+
+endif
+endmenu
+
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
new file mode 100644 (file)
index 0000000..72243a6
--- /dev/null
@@ -0,0 +1,62 @@
+
+obj-$(CONFIG_ATA)              += libata.o
+
+obj-$(CONFIG_SATA_AHCI)                += ahci.o
+obj-$(CONFIG_SATA_SVW)         += sata_svw.o
+obj-$(CONFIG_ATA_PIIX)         += ata_piix.o
+obj-$(CONFIG_SATA_PROMISE)     += sata_promise.o
+obj-$(CONFIG_SATA_QSTOR)       += sata_qstor.o
+obj-$(CONFIG_SATA_SIL)         += sata_sil.o
+obj-$(CONFIG_SATA_SIL24)       += sata_sil24.o
+obj-$(CONFIG_SATA_VIA)         += sata_via.o
+obj-$(CONFIG_SATA_VITESSE)     += sata_vsc.o
+obj-$(CONFIG_SATA_SIS)         += sata_sis.o
+obj-$(CONFIG_SATA_SX4)         += sata_sx4.o
+obj-$(CONFIG_SATA_NV)          += sata_nv.o
+obj-$(CONFIG_SATA_ULI)         += sata_uli.o
+obj-$(CONFIG_SATA_MV)          += sata_mv.o
+obj-$(CONFIG_PDC_ADMA)         += pdc_adma.o
+
+obj-$(CONFIG_PATA_ALI)         += pata_ali.o
+obj-$(CONFIG_PATA_AMD)         += pata_amd.o
+obj-$(CONFIG_PATA_ARTOP)       += pata_artop.o
+obj-$(CONFIG_PATA_ATIIXP)      += pata_atiixp.o
+obj-$(CONFIG_PATA_CMD64X)      += pata_cmd64x.o
+obj-$(CONFIG_PATA_CS5520)      += pata_cs5520.o
+obj-$(CONFIG_PATA_CS5530)      += pata_cs5530.o
+obj-$(CONFIG_PATA_CS5535)      += pata_cs5535.o
+obj-$(CONFIG_PATA_CYPRESS)     += pata_cypress.o
+obj-$(CONFIG_PATA_EFAR)                += pata_efar.o
+obj-$(CONFIG_PATA_HPT366)      += pata_hpt366.o
+obj-$(CONFIG_PATA_HPT37X)      += pata_hpt37x.o
+obj-$(CONFIG_PATA_HPT3X2N)     += pata_hpt3x2n.o
+obj-$(CONFIG_PATA_HPT3X3)      += pata_hpt3x3.o
+obj-$(CONFIG_PATA_ISAPNP)      += pata_isapnp.o
+obj-$(CONFIG_PATA_IT821X)      += pata_it821x.o
+obj-$(CONFIG_PATA_JMICRON)     += pata_jmicron.o
+obj-$(CONFIG_PATA_NETCELL)     += pata_netcell.o
+obj-$(CONFIG_PATA_NS87410)     += pata_ns87410.o
+obj-$(CONFIG_PATA_OPTI)                += pata_opti.o
+obj-$(CONFIG_PATA_OPTIDMA)     += pata_optidma.o
+obj-$(CONFIG_PATA_MPIIX)       += pata_mpiix.o
+obj-$(CONFIG_PATA_OLDPIIX)     += pata_oldpiix.o
+obj-$(CONFIG_PATA_PCMCIA)      += pata_pcmcia.o
+obj-$(CONFIG_PATA_PDC2027X)    += pata_pdc2027x.o
+obj-$(CONFIG_PATA_PDC_OLD)     += pata_pdc202xx_old.o
+obj-$(CONFIG_PATA_QDI)         += pata_qdi.o
+obj-$(CONFIG_PATA_RADISYS)     += pata_radisys.o
+obj-$(CONFIG_PATA_RZ1000)      += pata_rz1000.o
+obj-$(CONFIG_PATA_SC1200)      += pata_sc1200.o
+obj-$(CONFIG_PATA_SERVERWORKS) += pata_serverworks.o
+obj-$(CONFIG_PATA_SIL680)      += pata_sil680.o
+obj-$(CONFIG_PATA_VIA)         += pata_via.o
+obj-$(CONFIG_PATA_WINBOND)     += pata_sl82c105.o
+obj-$(CONFIG_PATA_SIS)         += pata_sis.o
+obj-$(CONFIG_PATA_TRIFLEX)     += pata_triflex.o
+# Should be last but one libata driver
+obj-$(CONFIG_ATA_GENERIC)      += ata_generic.o
+# Should be last libata driver
+obj-$(CONFIG_PATA_LEGACY)      += pata_legacy.o
+
+libata-objs    := libata-core.o libata-scsi.o libata-sff.o libata-eh.o
+
similarity index 79%
rename from drivers/scsi/ahci.c
rename to drivers/ata/ahci.c
index 904c25fb4ba4a26678bf81e9b8bc4315714bed5f..1aabc81d82f1dcc96a3dd8929f8b59d68fa6b3e3 100644 (file)
@@ -92,7 +92,9 @@ enum {
        HOST_AHCI_EN            = (1 << 31), /* AHCI enabled */
 
        /* HOST_CAP bits */
+       HOST_CAP_SSC            = (1 << 14), /* Slumber capable */
        HOST_CAP_CLO            = (1 << 24), /* Command List Override support */
+       HOST_CAP_SSS            = (1 << 27), /* Staggered Spin-up */
        HOST_CAP_NCQ            = (1 << 30), /* Native Command Queueing */
        HOST_CAP_64             = (1 << 31), /* PCI DAC (64-bit DMA) support */
 
@@ -155,6 +157,7 @@ enum {
        PORT_CMD_SPIN_UP        = (1 << 1), /* Spin up device */
        PORT_CMD_START          = (1 << 0), /* Enable port DMA engine */
 
+       PORT_CMD_ICC_MASK       = (0xf << 28), /* i/f ICC state mask */
        PORT_CMD_ICC_ACTIVE     = (0x1 << 28), /* Put i/f in active state */
        PORT_CMD_ICC_PARTIAL    = (0x2 << 28), /* Put i/f in partial state */
        PORT_CMD_ICC_SLUMBER    = (0x6 << 28), /* Put i/f in slumber state */
@@ -212,6 +215,10 @@ static void ahci_freeze(struct ata_port *ap);
 static void ahci_thaw(struct ata_port *ap);
 static void ahci_error_handler(struct ata_port *ap);
 static void ahci_post_internal_cmd(struct ata_queued_cmd *qc);
+static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg);
+static int ahci_port_resume(struct ata_port *ap);
+static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
+static int ahci_pci_device_resume(struct pci_dev *pdev);
 static void ahci_remove_one (struct pci_dev *pdev);
 
 static struct scsi_host_template ahci_sht = {
@@ -231,6 +238,8 @@ static struct scsi_host_template ahci_sht = {
        .slave_configure        = ata_scsi_slave_config,
        .slave_destroy          = ata_scsi_slave_destroy,
        .bios_param             = ata_std_bios_param,
+       .suspend                = ata_scsi_device_suspend,
+       .resume                 = ata_scsi_device_resume,
 };
 
 static const struct ata_port_operations ahci_ops = {
@@ -257,6 +266,9 @@ static const struct ata_port_operations ahci_ops = {
        .error_handler          = ahci_error_handler,
        .post_internal_cmd      = ahci_post_internal_cmd,
 
+       .port_suspend           = ahci_port_suspend,
+       .port_resume            = ahci_port_resume,
+
        .port_start             = ahci_port_start,
        .port_stop              = ahci_port_stop,
 };
@@ -265,7 +277,7 @@ static const struct ata_port_info ahci_port_info[] = {
        /* board_ahci */
        {
                .sht            = &ahci_sht,
-               .host_flags     = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
+               .flags          = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
                                  ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
                                  ATA_FLAG_SKIP_D2H_BSY,
                .pio_mask       = 0x1f, /* pio0-4 */
@@ -275,7 +287,7 @@ static const struct ata_port_info ahci_port_info[] = {
        /* board_ahci_vt8251 */
        {
                .sht            = &ahci_sht,
-               .host_flags     = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
+               .flags          = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
                                  ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
                                  ATA_FLAG_SKIP_D2H_BSY |
                                  AHCI_FLAG_RESET_NEEDS_CLO | AHCI_FLAG_NO_NCQ,
@@ -350,6 +362,14 @@ static const struct pci_device_id ahci_pci_tbl[] = {
        { PCI_VENDOR_ID_NVIDIA, 0x044f, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
          board_ahci },         /* MCP65 */
 
+       /* SiS */
+       { PCI_VENDOR_ID_SI, 0x1184, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+         board_ahci }, /* SiS 966 */
+       { PCI_VENDOR_ID_SI, 0x1185, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+         board_ahci }, /* SiS 966 */
+       { PCI_VENDOR_ID_SI, 0x0186, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+         board_ahci }, /* SiS 968 */
+
        { }     /* terminate list */
 };
 
@@ -358,6 +378,8 @@ static struct pci_driver ahci_pci_driver = {
        .name                   = DRV_NAME,
        .id_table               = ahci_pci_tbl,
        .probe                  = ahci_init_one,
+       .suspend                = ahci_pci_device_suspend,
+       .resume                 = ahci_pci_device_resume,
        .remove                 = ahci_remove_one,
 };
 
@@ -372,177 +394,288 @@ static inline void __iomem *ahci_port_base (void __iomem *base, unsigned int por
        return (void __iomem *) ahci_port_base_ul((unsigned long)base, port);
 }
 
-static int ahci_port_start(struct ata_port *ap)
+static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in)
 {
-       struct device *dev = ap->host_set->dev;
-       struct ahci_host_priv *hpriv = ap->host_set->private_data;
-       struct ahci_port_priv *pp;
-       void __iomem *mmio = ap->host_set->mmio_base;
-       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
-       void *mem;
-       dma_addr_t mem_dma;
-       int rc;
-
-       pp = kmalloc(sizeof(*pp), GFP_KERNEL);
-       if (!pp)
-               return -ENOMEM;
-       memset(pp, 0, sizeof(*pp));
+       unsigned int sc_reg;
 
-       rc = ata_pad_alloc(ap, dev);
-       if (rc) {
-               kfree(pp);
-               return rc;
+       switch (sc_reg_in) {
+       case SCR_STATUS:        sc_reg = 0; break;
+       case SCR_CONTROL:       sc_reg = 1; break;
+       case SCR_ERROR:         sc_reg = 2; break;
+       case SCR_ACTIVE:        sc_reg = 3; break;
+       default:
+               return 0xffffffffU;
        }
 
-       mem = dma_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, GFP_KERNEL);
-       if (!mem) {
-               ata_pad_free(ap, dev);
-               kfree(pp);
-               return -ENOMEM;
-       }
-       memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ);
+       return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
+}
 
-       /*
-        * First item in chunk of DMA memory: 32-slot command table,
-        * 32 bytes each in size
-        */
-       pp->cmd_slot = mem;
-       pp->cmd_slot_dma = mem_dma;
 
-       mem += AHCI_CMD_SLOT_SZ;
-       mem_dma += AHCI_CMD_SLOT_SZ;
+static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in,
+                              u32 val)
+{
+       unsigned int sc_reg;
 
-       /*
-        * Second item: Received-FIS area
-        */
-       pp->rx_fis = mem;
-       pp->rx_fis_dma = mem_dma;
+       switch (sc_reg_in) {
+       case SCR_STATUS:        sc_reg = 0; break;
+       case SCR_CONTROL:       sc_reg = 1; break;
+       case SCR_ERROR:         sc_reg = 2; break;
+       case SCR_ACTIVE:        sc_reg = 3; break;
+       default:
+               return;
+       }
 
-       mem += AHCI_RX_FIS_SZ;
-       mem_dma += AHCI_RX_FIS_SZ;
+       writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
+}
 
-       /*
-        * Third item: data area for storing a single command
-        * and its scatter-gather table
-        */
-       pp->cmd_tbl = mem;
-       pp->cmd_tbl_dma = mem_dma;
+static void ahci_start_engine(void __iomem *port_mmio)
+{
+       u32 tmp;
 
-       ap->private_data = pp;
+       /* start DMA */
+       tmp = readl(port_mmio + PORT_CMD);
+       tmp |= PORT_CMD_START;
+       writel(tmp, port_mmio + PORT_CMD);
+       readl(port_mmio + PORT_CMD); /* flush */
+}
 
-       if (hpriv->cap & HOST_CAP_64)
-               writel((pp->cmd_slot_dma >> 16) >> 16, port_mmio + PORT_LST_ADDR_HI);
-       writel(pp->cmd_slot_dma & 0xffffffff, port_mmio + PORT_LST_ADDR);
-       readl(port_mmio + PORT_LST_ADDR); /* flush */
+static int ahci_stop_engine(void __iomem *port_mmio)
+{
+       u32 tmp;
 
-       if (hpriv->cap & HOST_CAP_64)
-               writel((pp->rx_fis_dma >> 16) >> 16, port_mmio + PORT_FIS_ADDR_HI);
-       writel(pp->rx_fis_dma & 0xffffffff, port_mmio + PORT_FIS_ADDR);
-       readl(port_mmio + PORT_FIS_ADDR); /* flush */
+       tmp = readl(port_mmio + PORT_CMD);
 
-       writel(PORT_CMD_ICC_ACTIVE | PORT_CMD_FIS_RX |
-              PORT_CMD_POWER_ON | PORT_CMD_SPIN_UP |
-              PORT_CMD_START, port_mmio + PORT_CMD);
-       readl(port_mmio + PORT_CMD); /* flush */
+       /* check if the HBA is idle */
+       if ((tmp & (PORT_CMD_START | PORT_CMD_LIST_ON)) == 0)
+               return 0;
+
+       /* setting HBA to idle */
+       tmp &= ~PORT_CMD_START;
+       writel(tmp, port_mmio + PORT_CMD);
+
+       /* wait for engine to stop. This could be as long as 500 msec */
+       tmp = ata_wait_register(port_mmio + PORT_CMD,
+                               PORT_CMD_LIST_ON, PORT_CMD_LIST_ON, 1, 500);
+       if (tmp & PORT_CMD_LIST_ON)
+               return -EIO;
 
        return 0;
 }
 
+static void ahci_start_fis_rx(void __iomem *port_mmio, u32 cap,
+                             dma_addr_t cmd_slot_dma, dma_addr_t rx_fis_dma)
+{
+       u32 tmp;
 
-static void ahci_port_stop(struct ata_port *ap)
+       /* set FIS registers */
+       if (cap & HOST_CAP_64)
+               writel((cmd_slot_dma >> 16) >> 16, port_mmio + PORT_LST_ADDR_HI);
+       writel(cmd_slot_dma & 0xffffffff, port_mmio + PORT_LST_ADDR);
+
+       if (cap & HOST_CAP_64)
+               writel((rx_fis_dma >> 16) >> 16, port_mmio + PORT_FIS_ADDR_HI);
+       writel(rx_fis_dma & 0xffffffff, port_mmio + PORT_FIS_ADDR);
+
+       /* enable FIS reception */
+       tmp = readl(port_mmio + PORT_CMD);
+       tmp |= PORT_CMD_FIS_RX;
+       writel(tmp, port_mmio + PORT_CMD);
+
+       /* flush */
+       readl(port_mmio + PORT_CMD);
+}
+
+static int ahci_stop_fis_rx(void __iomem *port_mmio)
 {
-       struct device *dev = ap->host_set->dev;
-       struct ahci_port_priv *pp = ap->private_data;
-       void __iomem *mmio = ap->host_set->mmio_base;
-       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        u32 tmp;
 
+       /* disable FIS reception */
        tmp = readl(port_mmio + PORT_CMD);
-       tmp &= ~(PORT_CMD_START | PORT_CMD_FIS_RX);
+       tmp &= ~PORT_CMD_FIS_RX;
        writel(tmp, port_mmio + PORT_CMD);
-       readl(port_mmio + PORT_CMD); /* flush */
 
-       /* spec says 500 msecs for each PORT_CMD_{START,FIS_RX} bit, so
-        * this is slightly incorrect.
-        */
-       msleep(500);
+       /* wait for completion, spec says 500ms, give it 1000 */
+       tmp = ata_wait_register(port_mmio + PORT_CMD, PORT_CMD_FIS_ON,
+                               PORT_CMD_FIS_ON, 10, 1000);
+       if (tmp & PORT_CMD_FIS_ON)
+               return -EBUSY;
 
-       ap->private_data = NULL;
-       dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ,
-                         pp->cmd_slot, pp->cmd_slot_dma);
-       ata_pad_free(ap, dev);
-       kfree(pp);
+       return 0;
 }
 
-static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in)
+static void ahci_power_up(void __iomem *port_mmio, u32 cap)
 {
-       unsigned int sc_reg;
+       u32 cmd;
 
-       switch (sc_reg_in) {
-       case SCR_STATUS:        sc_reg = 0; break;
-       case SCR_CONTROL:       sc_reg = 1; break;
-       case SCR_ERROR:         sc_reg = 2; break;
-       case SCR_ACTIVE:        sc_reg = 3; break;
-       default:
-               return 0xffffffffU;
+       cmd = readl(port_mmio + PORT_CMD) & ~PORT_CMD_ICC_MASK;
+
+       /* spin up device */
+       if (cap & HOST_CAP_SSS) {
+               cmd |= PORT_CMD_SPIN_UP;
+               writel(cmd, port_mmio + PORT_CMD);
        }
 
-       return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
+       /* wake up link */
+       writel(cmd | PORT_CMD_ICC_ACTIVE, port_mmio + PORT_CMD);
 }
 
+static void ahci_power_down(void __iomem *port_mmio, u32 cap)
+{
+       u32 cmd, scontrol;
 
-static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in,
-                              u32 val)
+       cmd = readl(port_mmio + PORT_CMD) & ~PORT_CMD_ICC_MASK;
+
+       if (cap & HOST_CAP_SSC) {
+               /* enable transitions to slumber mode */
+               scontrol = readl(port_mmio + PORT_SCR_CTL);
+               if ((scontrol & 0x0f00) > 0x100) {
+                       scontrol &= ~0xf00;
+                       writel(scontrol, port_mmio + PORT_SCR_CTL);
+               }
+
+               /* put device into slumber mode */
+               writel(cmd | PORT_CMD_ICC_SLUMBER, port_mmio + PORT_CMD);
+
+               /* wait for the transition to complete */
+               ata_wait_register(port_mmio + PORT_CMD, PORT_CMD_ICC_SLUMBER,
+                                 PORT_CMD_ICC_SLUMBER, 1, 50);
+       }
+
+       /* put device into listen mode */
+       if (cap & HOST_CAP_SSS) {
+               /* first set PxSCTL.DET to 0 */
+               scontrol = readl(port_mmio + PORT_SCR_CTL);
+               scontrol &= ~0xf;
+               writel(scontrol, port_mmio + PORT_SCR_CTL);
+
+               /* then set PxCMD.SUD to 0 */
+               cmd &= ~PORT_CMD_SPIN_UP;
+               writel(cmd, port_mmio + PORT_CMD);
+       }
+}
+
+static void ahci_init_port(void __iomem *port_mmio, u32 cap,
+                          dma_addr_t cmd_slot_dma, dma_addr_t rx_fis_dma)
 {
-       unsigned int sc_reg;
+       /* power up */
+       ahci_power_up(port_mmio, cap);
 
-       switch (sc_reg_in) {
-       case SCR_STATUS:        sc_reg = 0; break;
-       case SCR_CONTROL:       sc_reg = 1; break;
-       case SCR_ERROR:         sc_reg = 2; break;
-       case SCR_ACTIVE:        sc_reg = 3; break;
-       default:
-               return;
+       /* enable FIS reception */
+       ahci_start_fis_rx(port_mmio, cap, cmd_slot_dma, rx_fis_dma);
+
+       /* enable DMA */
+       ahci_start_engine(port_mmio);
+}
+
+static int ahci_deinit_port(void __iomem *port_mmio, u32 cap, const char **emsg)
+{
+       int rc;
+
+       /* disable DMA */
+       rc = ahci_stop_engine(port_mmio);
+       if (rc) {
+               *emsg = "failed to stop engine";
+               return rc;
        }
 
-       writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
+       /* disable FIS reception */
+       rc = ahci_stop_fis_rx(port_mmio);
+       if (rc) {
+               *emsg = "failed stop FIS RX";
+               return rc;
+       }
+
+       /* put device into slumber mode */
+       ahci_power_down(port_mmio, cap);
+
+       return 0;
 }
 
-static int ahci_stop_engine(struct ata_port *ap)
+static int ahci_reset_controller(void __iomem *mmio, struct pci_dev *pdev)
 {
-       void __iomem *mmio = ap->host_set->mmio_base;
-       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
-       int work;
-       u32 tmp;
+       u32 cap_save, tmp;
 
-       tmp = readl(port_mmio + PORT_CMD);
-       tmp &= ~PORT_CMD_START;
-       writel(tmp, port_mmio + PORT_CMD);
+       cap_save = readl(mmio + HOST_CAP);
+       cap_save &= ( (1<<28) | (1<<17) );
+       cap_save |= (1 << 27);
+
+       /* global controller reset */
+       tmp = readl(mmio + HOST_CTL);
+       if ((tmp & HOST_RESET) == 0) {
+               writel(tmp | HOST_RESET, mmio + HOST_CTL);
+               readl(mmio + HOST_CTL); /* flush */
+       }
 
-       /* wait for engine to stop.  TODO: this could be
-        * as long as 500 msec
+       /* reset must complete within 1 second, or
+        * the hardware should be considered fried.
         */
-       work = 1000;
-       while (work-- > 0) {
-               tmp = readl(port_mmio + PORT_CMD);
-               if ((tmp & PORT_CMD_LIST_ON) == 0)
-                       return 0;
-               udelay(10);
+       ssleep(1);
+
+       tmp = readl(mmio + HOST_CTL);
+       if (tmp & HOST_RESET) {
+               dev_printk(KERN_ERR, &pdev->dev,
+                          "controller reset failed (0x%x)\n", tmp);
+               return -EIO;
        }
 
-       return -EIO;
+       writel(HOST_AHCI_EN, mmio + HOST_CTL);
+       (void) readl(mmio + HOST_CTL);  /* flush */
+       writel(cap_save, mmio + HOST_CAP);
+       writel(0xf, mmio + HOST_PORTS_IMPL);
+       (void) readl(mmio + HOST_PORTS_IMPL);   /* flush */
+
+       if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
+               u16 tmp16;
+
+               /* configure PCS */
+               pci_read_config_word(pdev, 0x92, &tmp16);
+               tmp16 |= 0xf;
+               pci_write_config_word(pdev, 0x92, tmp16);
+       }
+
+       return 0;
 }
 
-static void ahci_start_engine(struct ata_port *ap)
+static void ahci_init_controller(void __iomem *mmio, struct pci_dev *pdev,
+                                int n_ports, u32 cap)
 {
-       void __iomem *mmio = ap->host_set->mmio_base;
-       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
+       int i, rc;
        u32 tmp;
 
-       tmp = readl(port_mmio + PORT_CMD);
-       tmp |= PORT_CMD_START;
-       writel(tmp, port_mmio + PORT_CMD);
-       readl(port_mmio + PORT_CMD); /* flush */
+       for (i = 0; i < n_ports; i++) {
+               void __iomem *port_mmio = ahci_port_base(mmio, i);
+               const char *emsg = NULL;
+
+#if 0 /* BIOSen initialize this incorrectly */
+               if (!(hpriv->port_map & (1 << i)))
+                       continue;
+#endif
+
+               /* make sure port is not active */
+               rc = ahci_deinit_port(port_mmio, cap, &emsg);
+               if (rc)
+                       dev_printk(KERN_WARNING, &pdev->dev,
+                                  "%s (%d)\n", emsg, rc);
+
+               /* clear SError */
+               tmp = readl(port_mmio + PORT_SCR_ERR);
+               VPRINTK("PORT_SCR_ERR 0x%x\n", tmp);
+               writel(tmp, port_mmio + PORT_SCR_ERR);
+
+               /* clear port IRQ */
+               tmp = readl(port_mmio + PORT_IRQ_STAT);
+               VPRINTK("PORT_IRQ_STAT 0x%x\n", tmp);
+               if (tmp)
+                       writel(tmp, port_mmio + PORT_IRQ_STAT);
+
+               writel(1 << i, mmio + HOST_IRQ_STAT);
+       }
+
+       tmp = readl(mmio + HOST_CTL);
+       VPRINTK("HOST_CTL 0x%x\n", tmp);
+       writel(tmp | HOST_IRQ_EN, mmio + HOST_CTL);
+       tmp = readl(mmio + HOST_CTL);
+       VPRINTK("HOST_CTL 0x%x\n", tmp);
 }
 
 static unsigned int ahci_dev_classify(struct ata_port *ap)
@@ -576,7 +709,7 @@ static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
 static int ahci_clo(struct ata_port *ap)
 {
        void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
-       struct ahci_host_priv *hpriv = ap->host_set->private_data;
+       struct ahci_host_priv *hpriv = ap->host->private_data;
        u32 tmp;
 
        if (!(hpriv->cap & HOST_CAP_CLO))
@@ -608,7 +741,7 @@ static int ahci_prereset(struct ata_port *ap)
 static int ahci_softreset(struct ata_port *ap, unsigned int *class)
 {
        struct ahci_port_priv *pp = ap->private_data;
-       void __iomem *mmio = ap->host_set->mmio_base;
+       void __iomem *mmio = ap->host->mmio_base;
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        const u32 cmd_fis_len = 5; /* five dwords */
        const char *reason = NULL;
@@ -626,7 +759,7 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class)
        }
 
        /* prepare for SRST (AHCI-1.1 10.4.1) */
-       rc = ahci_stop_engine(ap);
+       rc = ahci_stop_engine(port_mmio);
        if (rc) {
                reason = "failed to stop engine";
                goto fail_restart;
@@ -647,7 +780,7 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class)
        }
 
        /* restart engine */
-       ahci_start_engine(ap);
+       ahci_start_engine(port_mmio);
 
        ata_tf_init(ap->device, &tf);
        fis = pp->cmd_tbl;
@@ -706,7 +839,7 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class)
        return 0;
 
  fail_restart:
-       ahci_start_engine(ap);
+       ahci_start_engine(port_mmio);
  fail:
        ata_port_printk(ap, KERN_ERR, "softreset failed (%s)\n", reason);
        return rc;
@@ -717,11 +850,13 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class)
        struct ahci_port_priv *pp = ap->private_data;
        u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
        struct ata_taskfile tf;
+       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        int rc;
 
        DPRINTK("ENTER\n");
 
-       ahci_stop_engine(ap);
+       ahci_stop_engine(port_mmio);
 
        /* clear D2H reception area to properly wait for D2H FIS */
        ata_tf_init(ap->device, &tf);
@@ -730,7 +865,7 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class)
 
        rc = sata_std_hardreset(ap, class);
 
-       ahci_start_engine(ap);
+       ahci_start_engine(port_mmio);
 
        if (rc == 0 && ata_port_online(ap))
                *class = ahci_dev_classify(ap);
@@ -904,7 +1039,7 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
 
 static void ahci_host_intr(struct ata_port *ap)
 {
-       void __iomem *mmio = ap->host_set->mmio_base;
+       void __iomem *mmio = ap->host->mmio_base;
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        struct ata_eh_info *ehi = &ap->eh_info;
        u32 status, qc_active;
@@ -940,7 +1075,7 @@ static void ahci_host_intr(struct ata_port *ap)
                return;
 
        /* ignore interim PIO setup fis interrupts */
-       if (ata_tag_valid(ap->active_tag) && (status & PORT_IRQ_PIOS_FIS)) 
+       if (ata_tag_valid(ap->active_tag) && (status & PORT_IRQ_PIOS_FIS))
                return;
 
        if (ata_ratelimit())
@@ -956,7 +1091,7 @@ static void ahci_irq_clear(struct ata_port *ap)
 
 static irqreturn_t ahci_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
 {
-       struct ata_host_set *host_set = dev_instance;
+       struct ata_host *host = dev_instance;
        struct ahci_host_priv *hpriv;
        unsigned int i, handled = 0;
        void __iomem *mmio;
@@ -964,8 +1099,8 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance, struct pt_regs *r
 
        VPRINTK("ENTER\n");
 
-       hpriv = host_set->private_data;
-       mmio = host_set->mmio_base;
+       hpriv = host->private_data;
+       mmio = host->mmio_base;
 
        /* sigh.  0xffffffff is a valid return from h/w */
        irq_stat = readl(mmio + HOST_IRQ_STAT);
@@ -973,22 +1108,22 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance, struct pt_regs *r
        if (!irq_stat)
                return IRQ_NONE;
 
-        spin_lock(&host_set->lock);
+        spin_lock(&host->lock);
 
-        for (i = 0; i < host_set->n_ports; i++) {
+        for (i = 0; i < host->n_ports; i++) {
                struct ata_port *ap;
 
                if (!(irq_stat & (1 << i)))
                        continue;
 
-               ap = host_set->ports[i];
+               ap = host->ports[i];
                if (ap) {
                        ahci_host_intr(ap);
                        VPRINTK("port %u\n", i);
                } else {
                        VPRINTK("port %u (no irq)\n", i);
                        if (ata_ratelimit())
-                               dev_printk(KERN_WARNING, host_set->dev,
+                               dev_printk(KERN_WARNING, host->dev,
                                        "interrupt on disabled port %u\n", i);
                }
 
@@ -1000,7 +1135,7 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance, struct pt_regs *r
                handled = 1;
        }
 
-       spin_unlock(&host_set->lock);
+       spin_unlock(&host->lock);
 
        VPRINTK("EXIT\n");
 
@@ -1022,7 +1157,7 @@ static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
 
 static void ahci_freeze(struct ata_port *ap)
 {
-       void __iomem *mmio = ap->host_set->mmio_base;
+       void __iomem *mmio = ap->host->mmio_base;
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
 
        /* turn IRQ off */
@@ -1031,7 +1166,7 @@ static void ahci_freeze(struct ata_port *ap)
 
 static void ahci_thaw(struct ata_port *ap)
 {
-       void __iomem *mmio = ap->host_set->mmio_base;
+       void __iomem *mmio = ap->host->mmio_base;
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        u32 tmp;
 
@@ -1046,10 +1181,13 @@ static void ahci_thaw(struct ata_port *ap)
 
 static void ahci_error_handler(struct ata_port *ap)
 {
+       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
+
        if (!(ap->pflags & ATA_PFLAG_FROZEN)) {
                /* restart engine */
-               ahci_stop_engine(ap);
-               ahci_start_engine(ap);
+               ahci_stop_engine(port_mmio);
+               ahci_start_engine(port_mmio);
        }
 
        /* perform recovery */
@@ -1060,15 +1198,176 @@ static void ahci_error_handler(struct ata_port *ap)
 static void ahci_post_internal_cmd(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
+       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
 
        if (qc->flags & ATA_QCFLAG_FAILED)
                qc->err_mask |= AC_ERR_OTHER;
 
        if (qc->err_mask) {
                /* make DMA engine forget about the failed command */
-               ahci_stop_engine(ap);
-               ahci_start_engine(ap);
+               ahci_stop_engine(port_mmio);
+               ahci_start_engine(port_mmio);
+       }
+}
+
+static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg)
+{
+       struct ahci_host_priv *hpriv = ap->host->private_data;
+       struct ahci_port_priv *pp = ap->private_data;
+       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
+       const char *emsg = NULL;
+       int rc;
+
+       rc = ahci_deinit_port(port_mmio, hpriv->cap, &emsg);
+       if (rc) {
+               ata_port_printk(ap, KERN_ERR, "%s (%d)\n", emsg, rc);
+               ahci_init_port(port_mmio, hpriv->cap,
+                              pp->cmd_slot_dma, pp->rx_fis_dma);
+       }
+
+       return rc;
+}
+
+static int ahci_port_resume(struct ata_port *ap)
+{
+       struct ahci_port_priv *pp = ap->private_data;
+       struct ahci_host_priv *hpriv = ap->host->private_data;
+       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
+
+       ahci_init_port(port_mmio, hpriv->cap, pp->cmd_slot_dma, pp->rx_fis_dma);
+
+       return 0;
+}
+
+static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
+{
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       void __iomem *mmio = host->mmio_base;
+       u32 ctl;
+
+       if (mesg.event == PM_EVENT_SUSPEND) {
+               /* AHCI spec rev1.1 section 8.3.3:
+                * Software must disable interrupts prior to requesting a
+                * transition of the HBA to D3 state.
+                */
+               ctl = readl(mmio + HOST_CTL);
+               ctl &= ~HOST_IRQ_EN;
+               writel(ctl, mmio + HOST_CTL);
+               readl(mmio + HOST_CTL); /* flush */
+       }
+
+       return ata_pci_device_suspend(pdev, mesg);
+}
+
+static int ahci_pci_device_resume(struct pci_dev *pdev)
+{
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       struct ahci_host_priv *hpriv = host->private_data;
+       void __iomem *mmio = host->mmio_base;
+       int rc;
+
+       ata_pci_device_do_resume(pdev);
+
+       if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
+               rc = ahci_reset_controller(mmio, pdev);
+               if (rc)
+                       return rc;
+
+               ahci_init_controller(mmio, pdev, host->n_ports, hpriv->cap);
        }
+
+       ata_host_resume(host);
+
+       return 0;
+}
+
+static int ahci_port_start(struct ata_port *ap)
+{
+       struct device *dev = ap->host->dev;
+       struct ahci_host_priv *hpriv = ap->host->private_data;
+       struct ahci_port_priv *pp;
+       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
+       void *mem;
+       dma_addr_t mem_dma;
+       int rc;
+
+       pp = kmalloc(sizeof(*pp), GFP_KERNEL);
+       if (!pp)
+               return -ENOMEM;
+       memset(pp, 0, sizeof(*pp));
+
+       rc = ata_pad_alloc(ap, dev);
+       if (rc) {
+               kfree(pp);
+               return rc;
+       }
+
+       mem = dma_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, GFP_KERNEL);
+       if (!mem) {
+               ata_pad_free(ap, dev);
+               kfree(pp);
+               return -ENOMEM;
+       }
+       memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ);
+
+       /*
+        * First item in chunk of DMA memory: 32-slot command table,
+        * 32 bytes each in size
+        */
+       pp->cmd_slot = mem;
+       pp->cmd_slot_dma = mem_dma;
+
+       mem += AHCI_CMD_SLOT_SZ;
+       mem_dma += AHCI_CMD_SLOT_SZ;
+
+       /*
+        * Second item: Received-FIS area
+        */
+       pp->rx_fis = mem;
+       pp->rx_fis_dma = mem_dma;
+
+       mem += AHCI_RX_FIS_SZ;
+       mem_dma += AHCI_RX_FIS_SZ;
+
+       /*
+        * Third item: data area for storing a single command
+        * and its scatter-gather table
+        */
+       pp->cmd_tbl = mem;
+       pp->cmd_tbl_dma = mem_dma;
+
+       ap->private_data = pp;
+
+       /* initialize port */
+       ahci_init_port(port_mmio, hpriv->cap, pp->cmd_slot_dma, pp->rx_fis_dma);
+
+       return 0;
+}
+
+static void ahci_port_stop(struct ata_port *ap)
+{
+       struct device *dev = ap->host->dev;
+       struct ahci_host_priv *hpriv = ap->host->private_data;
+       struct ahci_port_priv *pp = ap->private_data;
+       void __iomem *mmio = ap->host->mmio_base;
+       void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
+       const char *emsg = NULL;
+       int rc;
+
+       /* de-initialize port */
+       rc = ahci_deinit_port(port_mmio, hpriv->cap, &emsg);
+       if (rc)
+               ata_port_printk(ap, KERN_WARNING, "%s (%d)\n", emsg, rc);
+
+       ap->private_data = NULL;
+       dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ,
+                         pp->cmd_slot, pp->cmd_slot_dma);
+       ata_pad_free(ap, dev);
+       kfree(pp);
 }
 
 static void ahci_setup_port(struct ata_ioports *port, unsigned long base,
@@ -1089,47 +1388,12 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
        struct ahci_host_priv *hpriv = probe_ent->private_data;
        struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
        void __iomem *mmio = probe_ent->mmio_base;
-       u32 tmp, cap_save;
-       unsigned int i, j, using_dac;
+       unsigned int i, using_dac;
        int rc;
-       void __iomem *port_mmio;
-
-       cap_save = readl(mmio + HOST_CAP);
-       cap_save &= ( (1<<28) | (1<<17) );
-       cap_save |= (1 << 27);
 
-       /* global controller reset */
-       tmp = readl(mmio + HOST_CTL);
-       if ((tmp & HOST_RESET) == 0) {
-               writel(tmp | HOST_RESET, mmio + HOST_CTL);
-               readl(mmio + HOST_CTL); /* flush */
-       }
-
-       /* reset must complete within 1 second, or
-        * the hardware should be considered fried.
-        */
-       ssleep(1);
-
-       tmp = readl(mmio + HOST_CTL);
-       if (tmp & HOST_RESET) {
-               dev_printk(KERN_ERR, &pdev->dev,
-                          "controller reset failed (0x%x)\n", tmp);
-               return -EIO;
-       }
-
-       writel(HOST_AHCI_EN, mmio + HOST_CTL);
-       (void) readl(mmio + HOST_CTL);  /* flush */
-       writel(cap_save, mmio + HOST_CAP);
-       writel(0xf, mmio + HOST_PORTS_IMPL);
-       (void) readl(mmio + HOST_PORTS_IMPL);   /* flush */
-
-       if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
-               u16 tmp16;
-
-               pci_read_config_word(pdev, 0x92, &tmp16);
-               tmp16 |= 0xf;
-               pci_write_config_word(pdev, 0x92, tmp16);
-       }
+       rc = ahci_reset_controller(mmio, pdev);
+       if (rc)
+               return rc;
 
        hpriv->cap = readl(mmio + HOST_CAP);
        hpriv->port_map = readl(mmio + HOST_PORTS_IMPL);
@@ -1165,63 +1429,10 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
                }
        }
 
-       for (i = 0; i < probe_ent->n_ports; i++) {
-#if 0 /* BIOSen initialize this incorrectly */
-               if (!(hpriv->port_map & (1 << i)))
-                       continue;
-#endif
-
-               port_mmio = ahci_port_base(mmio, i);
-               VPRINTK("mmio %p  port_mmio %p\n", mmio, port_mmio);
-
-               ahci_setup_port(&probe_ent->port[i],
-                               (unsigned long) mmio, i);
+       for (i = 0; i < probe_ent->n_ports; i++)
+               ahci_setup_port(&probe_ent->port[i], (unsigned long) mmio, i);
 
-               /* make sure port is not active */
-               tmp = readl(port_mmio + PORT_CMD);
-               VPRINTK("PORT_CMD 0x%x\n", tmp);
-               if (tmp & (PORT_CMD_LIST_ON | PORT_CMD_FIS_ON |
-                          PORT_CMD_FIS_RX | PORT_CMD_START)) {
-                       tmp &= ~(PORT_CMD_LIST_ON | PORT_CMD_FIS_ON |
-                                PORT_CMD_FIS_RX | PORT_CMD_START);
-                       writel(tmp, port_mmio + PORT_CMD);
-                       readl(port_mmio + PORT_CMD); /* flush */
-
-                       /* spec says 500 msecs for each bit, so
-                        * this is slightly incorrect.
-                        */
-                       msleep(500);
-               }
-
-               writel(PORT_CMD_SPIN_UP, port_mmio + PORT_CMD);
-
-               j = 0;
-               while (j < 100) {
-                       msleep(10);
-                       tmp = readl(port_mmio + PORT_SCR_STAT);
-                       if ((tmp & 0xf) == 0x3)
-                               break;
-                       j++;
-               }
-
-               tmp = readl(port_mmio + PORT_SCR_ERR);
-               VPRINTK("PORT_SCR_ERR 0x%x\n", tmp);
-               writel(tmp, port_mmio + PORT_SCR_ERR);
-
-               /* ack any pending irq events for this port */
-               tmp = readl(port_mmio + PORT_IRQ_STAT);
-               VPRINTK("PORT_IRQ_STAT 0x%x\n", tmp);
-               if (tmp)
-                       writel(tmp, port_mmio + PORT_IRQ_STAT);
-
-               writel(1 << i, mmio + HOST_IRQ_STAT);
-       }
-
-       tmp = readl(mmio + HOST_CTL);
-       VPRINTK("HOST_CTL 0x%x\n", tmp);
-       writel(tmp | HOST_IRQ_EN, mmio + HOST_CTL);
-       tmp = readl(mmio + HOST_CTL);
-       VPRINTK("HOST_CTL 0x%x\n", tmp);
+       ahci_init_controller(mmio, pdev, probe_ent->n_ports, hpriv->cap);
 
        pci_set_master(pdev);
 
@@ -1370,7 +1581,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        memset(hpriv, 0, sizeof(*hpriv));
 
        probe_ent->sht          = ahci_port_info[board_idx].sht;
-       probe_ent->host_flags   = ahci_port_info[board_idx].host_flags;
+       probe_ent->port_flags   = ahci_port_info[board_idx].flags;
        probe_ent->pio_mask     = ahci_port_info[board_idx].pio_mask;
        probe_ent->udma_mask    = ahci_port_info[board_idx].udma_mask;
        probe_ent->port_ops     = ahci_port_info[board_idx].port_ops;
@@ -1388,9 +1599,9 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        if (rc)
                goto err_out_hpriv;
 
-       if (!(probe_ent->host_flags & AHCI_FLAG_NO_NCQ) &&
+       if (!(probe_ent->port_flags & AHCI_FLAG_NO_NCQ) &&
            (hpriv->cap & HOST_CAP_NCQ))
-               probe_ent->host_flags |= ATA_FLAG_NCQ;
+               probe_ent->port_flags |= ATA_FLAG_NCQ;
 
        ahci_print_info(probe_ent);
 
@@ -1421,27 +1632,27 @@ err_out:
 static void ahci_remove_one (struct pci_dev *pdev)
 {
        struct device *dev = pci_dev_to_dev(pdev);
-       struct ata_host_set *host_set = dev_get_drvdata(dev);
-       struct ahci_host_priv *hpriv = host_set->private_data;
+       struct ata_host *host = dev_get_drvdata(dev);
+       struct ahci_host_priv *hpriv = host->private_data;
        unsigned int i;
        int have_msi;
 
-       for (i = 0; i < host_set->n_ports; i++)
-               ata_port_detach(host_set->ports[i]);
+       for (i = 0; i < host->n_ports; i++)
+               ata_port_detach(host->ports[i]);
 
        have_msi = hpriv->flags & AHCI_FLAG_MSI;
-       free_irq(host_set->irq, host_set);
+       free_irq(host->irq, host);
 
-       for (i = 0; i < host_set->n_ports; i++) {
-               struct ata_port *ap = host_set->ports[i];
+       for (i = 0; i < host->n_ports; i++) {
+               struct ata_port *ap = host->ports[i];
 
-               ata_scsi_release(ap->host);
-               scsi_host_put(ap->host);
+               ata_scsi_release(ap->scsi_host);
+               scsi_host_put(ap->scsi_host);
        }
 
        kfree(hpriv);
-       pci_iounmap(pdev, host_set->mmio_base);
-       kfree(host_set);
+       pci_iounmap(pdev, host->mmio_base);
+       kfree(host);
 
        if (have_msi)
                pci_disable_msi(pdev);
@@ -1454,7 +1665,7 @@ static void ahci_remove_one (struct pci_dev *pdev)
 
 static int __init ahci_init(void)
 {
-       return pci_module_init(&ahci_pci_driver);
+       return pci_register_driver(&ahci_pci_driver);
 }
 
 static void __exit ahci_exit(void)
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
new file mode 100644 (file)
index 0000000..1d1c30a
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+ *  ata_generic.c - Generic PATA/SATA controller driver.
+ *  Copyright 2005 Red Hat Inc <alan@redhat.com>, all rights reserved.
+ *
+ *  Elements from ide/pci/generic.c
+ *         Copyright (C) 2001-2002     Andre Hedrick <andre@linux-ide.org>
+ *         Portions (C) Copyright 2002  Red Hat Inc <alan@redhat.com>
+ *
+ *  May be copied or modified under the terms of the GNU General Public License
+ *
+ *  Driver for PCI IDE interfaces implementing the standard bus mastering
+ *  interface functionality. This assumes the BIOS did the drive set up and
+ *  tuning for us. By default we do not grab all IDE class devices as they
+ *  may have other drivers or need fixups to avoid problems. Instead we keep
+ *  a default list of stuff without documentation/driver that appears to
+ *  work.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/blkdev.h>
+#include <linux/delay.h>
+#include <scsi/scsi_host.h>
+#include <linux/libata.h>
+
+#define DRV_NAME "ata_generic"
+#define DRV_VERSION "0.2.6"
+
+/*
+ *     A generic parallel ATA driver using libata
+ */
+
+/**
+ *     generic_pre_reset               -       probe begin
+ *     @ap: ATA port
+ *
+ *     Set up cable type and use generic probe init
+ */
+
+static int generic_pre_reset(struct ata_port *ap)
+{
+       ap->cbl = ATA_CBL_PATA80;
+       return ata_std_prereset(ap);
+}
+
+
+/**
+ *     generic_error_handler - Probe specified port on PATA host controller
+ *     @ap: Port to probe
+ *     @classes:
+ *
+ *     LOCKING:
+ *     None (inherited from caller).
+ */
+
+
+static void generic_error_handler(struct ata_port *ap)
+{
+       ata_bmdma_drive_eh(ap, generic_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
+}
+
+/**
+ *     generic_set_mode        -       mode setting
+ *     @ap: interface to set up
+ *
+ *     Use a non standard set_mode function. We don't want to be tuned.
+ *     The BIOS configured everything. Our job is not to fiddle. We
+ *     read the dma enabled bits from the PCI configuration of the device
+ *     and respect them.
+ */
+
+static void generic_set_mode(struct ata_port *ap)
+{
+       int dma_enabled = 0;
+       int i;
+
+       /* Bits 5 and 6 indicate if DMA is active on master/slave */
+       if (ap->ioaddr.bmdma_addr)
+               dma_enabled = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+
+       for (i = 0; i < ATA_MAX_DEVICES; i++) {
+               struct ata_device *dev = &ap->device[i];
+               if (ata_dev_enabled(dev)) {
+                       /* We don't really care */
+                       dev->pio_mode = XFER_PIO_0;
+                       dev->dma_mode = XFER_MW_DMA_0;
+                       /* We do need the right mode information for DMA or PIO
+                          and this comes from the current configuration flags */
+                       if (dma_enabled & (1 << (5 + i))) {
+                               dev->xfer_mode = XFER_MW_DMA_0;
+                               dev->xfer_shift = ATA_SHIFT_MWDMA;
+                               dev->flags &= ~ATA_DFLAG_PIO;
+                       } else {
+                               dev->xfer_mode = XFER_PIO_0;
+                               dev->xfer_shift = ATA_SHIFT_PIO;
+                               dev->flags |= ATA_DFLAG_PIO;
+                       }
+               }
+       }
+}
+
+static struct scsi_host_template generic_sht = {
+       .module                 = THIS_MODULE,
+       .name                   = DRV_NAME,
+       .ioctl                  = ata_scsi_ioctl,
+       .queuecommand           = ata_scsi_queuecmd,
+       .can_queue              = ATA_DEF_QUEUE,
+       .this_id                = ATA_SHT_THIS_ID,
+       .sg_tablesize           = LIBATA_MAX_PRD,
+       .max_sectors            = ATA_MAX_SECTORS,
+       .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
+       .emulated               = ATA_SHT_EMULATED,
+       .use_clustering         = ATA_SHT_USE_CLUSTERING,
+       .proc_name              = DRV_NAME,
+       .dma_boundary           = ATA_DMA_BOUNDARY,
+       .slave_configure        = ata_scsi_slave_config,
+       .bios_param             = ata_std_bios_param,
+};
+
+static struct ata_port_operations generic_port_ops = {
+       .set_mode       = generic_set_mode,
+
+       .port_disable   = ata_port_disable,
+       .tf_load        = ata_tf_load,
+       .tf_read        = ata_tf_read,
+       .check_status   = ata_check_status,
+       .exec_command   = ata_exec_command,
+       .dev_select     = ata_std_dev_select,
+
+       .bmdma_setup    = ata_bmdma_setup,
+       .bmdma_start    = ata_bmdma_start,
+       .bmdma_stop     = ata_bmdma_stop,
+       .bmdma_status   = ata_bmdma_status,
+
+       .data_xfer      = ata_pio_data_xfer,
+
+       .freeze         = ata_bmdma_freeze,
+       .thaw           = ata_bmdma_thaw,
+       .error_handler  = generic_error_handler,
+       .post_internal_cmd = ata_bmdma_post_internal_cmd,
+
+       .qc_prep        = ata_qc_prep,
+       .qc_issue       = ata_qc_issue_prot,
+       .eng_timeout    = ata_eng_timeout,
+       .irq_handler    = ata_interrupt,
+       .irq_clear      = ata_bmdma_irq_clear,
+
+       .port_start     = ata_port_start,
+       .port_stop      = ata_port_stop,
+       .host_stop      = ata_host_stop
+};
+
+static int all_generic_ide;            /* Set to claim all devices */
+
+/**
+ *     ata_generic_init                -       attach generic IDE
+ *     @dev: PCI device found
+ *     @id: match entry
+ *
+ *     Called each time a matching IDE interface is found. We check if the
+ *     interface is one we wish to claim and if so we perform any chip
+ *     specific hacks then let the ATA layer do the heavy lifting.
+ */
+
+static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id *id)
+{
+       u16 command;
+       static struct ata_port_info info = {
+               .sht = &generic_sht,
+               .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
+               .pio_mask = 0x1f,
+               .mwdma_mask = 0x07,
+               .udma_mask = 0x3f,
+               .port_ops = &generic_port_ops
+       };
+       static struct ata_port_info *port_info[2] = { &info, &info };
+
+       /* Don't use the generic entry unless instructed to do so */
+       if (id->driver_data == 1 && all_generic_ide == 0)
+               return -ENODEV;
+
+       /* Devices that need care */
+       if (dev->vendor == PCI_VENDOR_ID_UMC &&
+           dev->device == PCI_DEVICE_ID_UMC_UM8886A &&
+           (!(PCI_FUNC(dev->devfn) & 1)))
+               return -ENODEV;
+
+       if (dev->vendor == PCI_VENDOR_ID_OPTI &&
+           dev->device == PCI_DEVICE_ID_OPTI_82C558 &&
+           (!(PCI_FUNC(dev->devfn) & 1)))
+               return -ENODEV;
+
+       /* Don't re-enable devices in generic mode or we will break some
+          motherboards with disabled and unused IDE controllers */
+       pci_read_config_word(dev, PCI_COMMAND, &command);
+       if (!(command & PCI_COMMAND_IO))
+               return -ENODEV;
+
+       if (dev->vendor == PCI_VENDOR_ID_AL)
+               ata_pci_clear_simplex(dev);
+
+       return ata_pci_init_one(dev, port_info, 2);
+}
+
+static struct pci_device_id ata_generic[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE), },
+       { PCI_DEVICE(PCI_VENDOR_ID_HOLTEK, PCI_DEVICE_ID_HOLTEK_6565), },
+       { PCI_DEVICE(PCI_VENDOR_ID_UMC,    PCI_DEVICE_ID_UMC_UM8673F), },
+       { PCI_DEVICE(PCI_VENDOR_ID_UMC,    PCI_DEVICE_ID_UMC_UM8886A), },
+       { PCI_DEVICE(PCI_VENDOR_ID_UMC,    PCI_DEVICE_ID_UMC_UM8886BF), },
+       { PCI_DEVICE(PCI_VENDOR_ID_HINT,   PCI_DEVICE_ID_HINT_VXPROII_IDE), },
+       { PCI_DEVICE(PCI_VENDOR_ID_VIA,    PCI_DEVICE_ID_VIA_82C561), },
+       { PCI_DEVICE(PCI_VENDOR_ID_OPTI,   PCI_DEVICE_ID_OPTI_82C558), },
+       { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO), },
+       { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), },
+       { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2),  },
+       /* Must come last. If you add entries adjust this table appropriately */
+       { PCI_ANY_ID,           PCI_ANY_ID,                        PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL, 1},
+       { 0, },
+};
+
+static struct pci_driver ata_generic_pci_driver = {
+       .name           = DRV_NAME,
+       .id_table       = ata_generic,
+       .probe          = ata_generic_init_one,
+       .remove         = ata_pci_remove_one
+};
+
+static int __init ata_generic_init(void)
+{
+       return pci_module_init(&ata_generic_pci_driver);
+}
+
+
+static void __exit ata_generic_exit(void)
+{
+       pci_unregister_driver(&ata_generic_pci_driver);
+}
+
+
+MODULE_AUTHOR("Alan Cox");
+MODULE_DESCRIPTION("low-level driver for generic ATA");
+MODULE_LICENSE("GPL");
+MODULE_DEVICE_TABLE(pci, ata_generic);
+MODULE_VERSION(DRV_VERSION);
+
+module_init(ata_generic_init);
+module_exit(ata_generic_exit);
+
+module_param(all_generic_ide, int, 0);
similarity index 67%
rename from drivers/scsi/ata_piix.c
rename to drivers/ata/ata_piix.c
index a9bb3cb7e89b1f925c300c66390c5f897820a39c..ab2ecccf7798093c5673a55f499481d1b8ba3eb9 100644 (file)
@@ -93,7 +93,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME       "ata_piix"
-#define DRV_VERSION    "2.00"
+#define DRV_VERSION    "2.00ac6"
 
 enum {
        PIIX_IOCFG              = 0x54, /* IDE I/O configuration register */
@@ -116,15 +116,18 @@ enum {
        PIIX_80C_SEC            = (1 << 7) | (1 << 6),
 
        /* controller IDs */
-       piix4_pata              = 0,
-       ich5_pata               = 1,
-       ich5_sata               = 2,
-       esb_sata                = 3,
-       ich6_sata               = 4,
-       ich6_sata_ahci          = 5,
-       ich6m_sata_ahci         = 6,
-       ich7m_sata_ahci         = 7,
-       ich8_sata_ahci          = 8,
+       piix_pata_33            = 0,    /* PIIX3 or 4 at 33Mhz */
+       ich_pata_33             = 1,    /* ICH up to UDMA 33 only */
+       ich_pata_66             = 2,    /* ICH up to 66 Mhz */
+       ich_pata_100            = 3,    /* ICH up to UDMA 100 */
+       ich_pata_133            = 4,    /* ICH up to UDMA 133 */
+       ich5_sata               = 5,
+       esb_sata                = 6,
+       ich6_sata               = 7,
+       ich6_sata_ahci          = 8,
+       ich6m_sata_ahci         = 9,
+       ich7m_sata_ahci         = 10,
+       ich8_sata_ahci          = 11,
 
        /* constants for mapping table */
        P0                      = 0,  /* port 0 */
@@ -152,20 +155,55 @@ struct piix_host_priv {
 
 static int piix_init_one (struct pci_dev *pdev,
                                    const struct pci_device_id *ent);
-static void piix_host_stop(struct ata_host_set *host_set);
-static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev);
-static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev);
+static void piix_host_stop(struct ata_host *host);
 static void piix_pata_error_handler(struct ata_port *ap);
+static void ich_pata_error_handler(struct ata_port *ap);
 static void piix_sata_error_handler(struct ata_port *ap);
+static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev);
+static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev);
+static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev);
 
 static unsigned int in_module_init = 1;
 
 static const struct pci_device_id piix_pci_tbl[] = {
 #ifdef ATA_ENABLE_PATA
-       { 0x8086, 0x7111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix4_pata },
-       { 0x8086, 0x24db, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_pata },
-       { 0x8086, 0x25a2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_pata },
-       { 0x8086, 0x27df, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_pata },
+       /* Intel PIIX4 for the 430TX/440BX/MX chipset: UDMA 33 */
+       /* Also PIIX4E (fn3 rev 2) and PIIX4M (fn3 rev 3) */
+       { 0x8086, 0x7111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_33 },
+       { 0x8086, 0x24db, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
+       { 0x8086, 0x25a2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
+       /* Intel PIIX4 */
+       { 0x8086, 0x7199, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_33 },
+       /* Intel PIIX4 */
+       { 0x8086, 0x7601, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_33 },
+       /* Intel PIIX */
+       { 0x8086, 0x84CA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_33 },
+       /* Intel ICH (i810, i815, i840) UDMA 66*/
+       { 0x8086, 0x2411, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_66 },
+       /* Intel ICH0 : UDMA 33*/
+       { 0x8086, 0x2421, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_33 },
+       /* Intel ICH2M */
+       { 0x8086, 0x244A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
+       /* Intel ICH2 (i810E2, i845, 850, 860) UDMA 100 */
+       { 0x8086, 0x244B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
+       /*  Intel ICH3M */
+       { 0x8086, 0x248A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
+       /* Intel ICH3 (E7500/1) UDMA 100 */
+       { 0x8086, 0x248B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
+       /* Intel ICH4 (i845GV, i845E, i852, i855) UDMA 100 */
+       { 0x8086, 0x24CA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
+       { 0x8086, 0x24CB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
+       /* Intel ICH5 */
+       { 0x8086, 0x24DB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_133 },
+       /* C-ICH (i810E2) */
+       { 0x8086, 0x245B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
+       /* ESB (855GME/875P + 6300ESB) UDMA 100  */
+       { 0x8086, 0x25A2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
+       /* ICH6 (and 6) (i915) UDMA 100 */
+       { 0x8086, 0x266F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
+       /* ICH7/7-R (i945, i975) UDMA 100*/
+       { 0x8086, 0x27DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_133 },
+       { 0x8086, 0x269E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
 #endif
 
        /* NOTE: The following PCI ids must be kept in sync with the
@@ -264,6 +302,39 @@ static const struct ata_port_operations piix_pata_ops = {
        .host_stop              = piix_host_stop,
 };
 
+static const struct ata_port_operations ich_pata_ops = {
+       .port_disable           = ata_port_disable,
+       .set_piomode            = piix_set_piomode,
+       .set_dmamode            = ich_set_dmamode,
+       .mode_filter            = ata_pci_default_filter,
+
+       .tf_load                = ata_tf_load,
+       .tf_read                = ata_tf_read,
+       .check_status           = ata_check_status,
+       .exec_command           = ata_exec_command,
+       .dev_select             = ata_std_dev_select,
+
+       .bmdma_setup            = ata_bmdma_setup,
+       .bmdma_start            = ata_bmdma_start,
+       .bmdma_stop             = ata_bmdma_stop,
+       .bmdma_status           = ata_bmdma_status,
+       .qc_prep                = ata_qc_prep,
+       .qc_issue               = ata_qc_issue_prot,
+       .data_xfer              = ata_pio_data_xfer,
+
+       .freeze                 = ata_bmdma_freeze,
+       .thaw                   = ata_bmdma_thaw,
+       .error_handler          = ich_pata_error_handler,
+       .post_internal_cmd      = ata_bmdma_post_internal_cmd,
+
+       .irq_handler            = ata_interrupt,
+       .irq_clear              = ata_bmdma_irq_clear,
+
+       .port_start             = ata_port_start,
+       .port_stop              = ata_port_stop,
+       .host_stop              = ata_host_stop,
+};
+
 static const struct ata_port_operations piix_sata_ops = {
        .port_disable           = ata_port_disable,
 
@@ -379,38 +450,59 @@ static const struct piix_map_db *piix_map_db_table[] = {
 };
 
 static struct ata_port_info piix_port_info[] = {
-       /* piix4_pata */
+       /* piix_pata_33: 0:  PIIX3 or 4 at 33MHz */
        {
                .sht            = &piix_sht,
-               .host_flags     = ATA_FLAG_SLAVE_POSS,
+               .flags          = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
                .pio_mask       = 0x1f, /* pio0-4 */
-#if 0
-               .mwdma_mask     = 0x06, /* mwdma1-2 */
-#else
-               .mwdma_mask     = 0x00, /* mwdma broken */
-#endif
+               .mwdma_mask     = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */
                .udma_mask      = ATA_UDMA_MASK_40C,
                .port_ops       = &piix_pata_ops,
        },
 
-       /* ich5_pata */
+       /* ich_pata_33: 1       ICH0 - ICH at 33Mhz*/
+       {
+               .sht            = &piix_sht,
+               .flags          = ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS,
+               .pio_mask       = 0x1f, /* pio 0-4 */
+               .mwdma_mask     = 0x06, /* Check: maybe 0x07  */
+               .udma_mask      = ATA_UDMA2, /* UDMA33 */
+               .port_ops       = &ich_pata_ops,
+       },
+       /* ich_pata_66: 2       ICH controllers up to 66MHz */
+       {
+               .sht            = &piix_sht,
+               .flags          = ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS,
+               .pio_mask       = 0x1f, /* pio 0-4 */
+               .mwdma_mask     = 0x06, /* MWDMA0 is broken on chip */
+               .udma_mask      = ATA_UDMA4,
+               .port_ops       = &ich_pata_ops,
+       },
+
+       /* ich_pata_100: 3 */
        {
                .sht            = &piix_sht,
-               .host_flags     = ATA_FLAG_SLAVE_POSS | PIIX_FLAG_CHECKINTR,
+               .flags          = ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS | PIIX_FLAG_CHECKINTR,
                .pio_mask       = 0x1f, /* pio0-4 */
-#if 0
                .mwdma_mask     = 0x06, /* mwdma1-2 */
-#else
-               .mwdma_mask     = 0x00, /* mwdma broken */
-#endif
-               .udma_mask      = 0x3f, /* udma0-5 */
-               .port_ops       = &piix_pata_ops,
+               .udma_mask      = ATA_UDMA5, /* udma0-5 */
+               .port_ops       = &ich_pata_ops,
+       },
+
+       /* ich_pata_133: 4      ICH with full UDMA6 */
+       {
+               .sht            = &piix_sht,
+               .flags          = ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS | PIIX_FLAG_CHECKINTR,
+               .pio_mask       = 0x1f, /* pio 0-4 */
+               .mwdma_mask     = 0x06, /* Check: maybe 0x07  */
+               .udma_mask      = ATA_UDMA6, /* UDMA133 */
+               .port_ops       = &ich_pata_ops,
        },
 
-       /* ich5_sata */
+       /* ich5_sata: 5 */
        {
                .sht            = &piix_sht,
-               .host_flags     = ATA_FLAG_SATA | PIIX_FLAG_CHECKINTR |
+               .flags          = ATA_FLAG_SATA | PIIX_FLAG_CHECKINTR |
                                  PIIX_FLAG_IGNORE_PCS,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
@@ -418,10 +510,10 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
-       /* i6300esb_sata */
+       /* i6300esb_sata: 6 */
        {
                .sht            = &piix_sht,
-               .host_flags     = ATA_FLAG_SATA |
+               .flags          = ATA_FLAG_SATA |
                                  PIIX_FLAG_CHECKINTR | PIIX_FLAG_IGNORE_PCS,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
@@ -429,10 +521,10 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
-       /* ich6_sata */
+       /* ich6_sata: 7 */
        {
                .sht            = &piix_sht,
-               .host_flags     = ATA_FLAG_SATA |
+               .flags          = ATA_FLAG_SATA |
                                  PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
@@ -440,10 +532,10 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
-       /* ich6_sata_ahci */
+       /* ich6_sata_ahci: 8 */
        {
                .sht            = &piix_sht,
-               .host_flags     = ATA_FLAG_SATA |
+               .flags          = ATA_FLAG_SATA |
                                  PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
                                  PIIX_FLAG_AHCI,
                .pio_mask       = 0x1f, /* pio0-4 */
@@ -452,10 +544,10 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
-       /* ich6m_sata_ahci */
+       /* ich6m_sata_ahci: 9 */
        {
                .sht            = &piix_sht,
-               .host_flags     = ATA_FLAG_SATA |
+               .flags          = ATA_FLAG_SATA |
                                  PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
                                  PIIX_FLAG_AHCI,
                .pio_mask       = 0x1f, /* pio0-4 */
@@ -464,10 +556,10 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
-       /* ich7m_sata_ahci */
+       /* ich7m_sata_ahci: 10 */
        {
                .sht            = &piix_sht,
-               .host_flags     = ATA_FLAG_SATA |
+               .flags          = ATA_FLAG_SATA |
                                  PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
                                  PIIX_FLAG_AHCI,
                .pio_mask       = 0x1f, /* pio0-4 */
@@ -476,10 +568,10 @@ static struct ata_port_info piix_port_info[] = {
                .port_ops       = &piix_sata_ops,
        },
 
-       /* ich8_sata_ahci */
+       /* ich8_sata_ahci: 11 */
        {
                .sht            = &piix_sht,
-               .host_flags     = ATA_FLAG_SATA |
+               .flags          = ATA_FLAG_SATA |
                                  PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
                                  PIIX_FLAG_AHCI,
                .pio_mask       = 0x1f, /* pio0-4 */
@@ -487,6 +579,7 @@ static struct ata_port_info piix_port_info[] = {
                .udma_mask      = 0x7f, /* udma0-6 */
                .port_ops       = &piix_sata_ops,
        },
+
 };
 
 static struct pci_bits piix_enable_bits[] = {
@@ -515,9 +608,10 @@ MODULE_PARM_DESC(force_pcs, "force honoring or ignoring PCS to work around "
  *     LOCKING:
  *     None (inherited from caller).
  */
-static void piix_pata_cbl_detect(struct ata_port *ap)
+
+static void ich_pata_cbl_detect(struct ata_port *ap)
 {
-       struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
+       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
        u8 tmp, mask;
 
        /* no 80c support in host controller? */
@@ -525,7 +619,7 @@ static void piix_pata_cbl_detect(struct ata_port *ap)
                goto cbl40;
 
        /* check BIOS cable detect results */
-       mask = ap->hard_port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC;
+       mask = ap->port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC;
        pci_read_config_byte(pdev, PIIX_IOCFG, &tmp);
        if ((tmp & mask) == 0)
                goto cbl40;
@@ -535,30 +629,26 @@ static void piix_pata_cbl_detect(struct ata_port *ap)
 
 cbl40:
        ap->cbl = ATA_CBL_PATA40;
-       ap->udma_mask &= ATA_UDMA_MASK_40C;
 }
 
 /**
  *     piix_pata_prereset - prereset for PATA host controller
  *     @ap: Target port
  *
- *     Prereset including cable detection.
  *
  *     LOCKING:
  *     None (inherited from caller).
  */
 static int piix_pata_prereset(struct ata_port *ap)
 {
-       struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
+       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
 
-       if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->hard_port_no])) {
+       if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no])) {
                ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
                ap->eh_context.i.action &= ~ATA_EH_RESET_MASK;
                return 0;
        }
-
-       piix_pata_cbl_detect(ap);
-
+       ap->cbl = ATA_CBL_PATA40;
        return ata_std_prereset(ap);
 }
 
@@ -568,6 +658,36 @@ static void piix_pata_error_handler(struct ata_port *ap)
                           ata_std_postreset);
 }
 
+
+/**
+ *     ich_pata_prereset - prereset for PATA host controller
+ *     @ap: Target port
+ *
+ *
+ *     LOCKING:
+ *     None (inherited from caller).
+ */
+static int ich_pata_prereset(struct ata_port *ap)
+{
+       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
+
+       if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no])) {
+               ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
+               ap->eh_context.i.action &= ~ATA_EH_RESET_MASK;
+               return 0;
+       }
+
+       ich_pata_cbl_detect(ap);
+
+       return ata_std_prereset(ap);
+}
+
+static void ich_pata_error_handler(struct ata_port *ap)
+{
+       ata_bmdma_drive_eh(ap, ich_pata_prereset, ata_std_softreset, NULL,
+                          ata_std_postreset);
+}
+
 /**
  *     piix_sata_present_mask - determine present mask for SATA host controller
  *     @ap: Target port
@@ -583,10 +703,10 @@ static void piix_pata_error_handler(struct ata_port *ap)
  */
 static unsigned int piix_sata_present_mask(struct ata_port *ap)
 {
-       struct pci_dev *pdev = to_pci_dev(ap->host_set->dev);
-       struct piix_host_priv *hpriv = ap->host_set->private_data;
+       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
+       struct piix_host_priv *hpriv = ap->host->private_data;
        const unsigned int *map = hpriv->map;
-       int base = 2 * ap->hard_port_no;
+       int base = 2 * ap->port_no;
        unsigned int present_mask = 0;
        int port, i;
        u16 pcs;
@@ -663,12 +783,19 @@ static void piix_sata_error_handler(struct ata_port *ap)
 static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev)
 {
        unsigned int pio        = adev->pio_mode - XFER_PIO_0;
-       struct pci_dev *dev     = to_pci_dev(ap->host_set->dev);
+       struct pci_dev *dev     = to_pci_dev(ap->host->dev);
        unsigned int is_slave   = (adev->devno != 0);
-       unsigned int master_port= ap->hard_port_no ? 0x42 : 0x40;
+       unsigned int master_port= ap->port_no ? 0x42 : 0x40;
        unsigned int slave_port = 0x44;
        u16 master_data;
        u8 slave_data;
+       u8 udma_enable;
+       int control = 0;
+
+       /*
+        *      See Intel Document 298600-004 for the timing programing rules
+        *      for ICH controllers.
+        */
 
        static const     /* ISP  RTC */
        u8 timings[][2] = { { 0, 0 },
@@ -677,20 +804,30 @@ static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev)
                            { 2, 1 },
                            { 2, 3 }, };
 
+       if (pio >= 2)
+               control |= 1;   /* TIME1 enable */
+       if (ata_pio_need_iordy(adev))
+               control |= 2;   /* IE enable */
+
+       /* Intel specifies that the PPE functionality is for disk only */
+       if (adev->class == ATA_DEV_ATA)
+               control |= 4;   /* PPE enable */
+
        pci_read_config_word(dev, master_port, &master_data);
        if (is_slave) {
+               /* Enable SITRE (seperate slave timing register) */
                master_data |= 0x4000;
-               /* enable PPE, IE and TIME */
-               master_data |= 0x0070;
+               /* enable PPE1, IE1 and TIME1 as needed */
+               master_data |= (control << 4);
                pci_read_config_byte(dev, slave_port, &slave_data);
-               slave_data &= (ap->hard_port_no ? 0x0f : 0xf0);
-               slave_data |=
-                       (timings[pio][0] << 2) |
-                       (timings[pio][1] << (ap->hard_port_no ? 4 : 0));
+               slave_data &= (ap->port_no ? 0x0f : 0xf0);
+               /* Load the timing nibble for this slave */
+               slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->port_no ? 4 : 0);
        } else {
+               /* Master keeps the bits in a different format */
                master_data &= 0xccf8;
-               /* enable PPE, IE and TIME */
-               master_data |= 0x0007;
+               /* Enable PPE, IE and TIME as appropriate */
+               master_data |= control;
                master_data |=
                        (timings[pio][0] << 12) |
                        (timings[pio][1] << 8);
@@ -698,13 +835,23 @@ static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev)
        pci_write_config_word(dev, master_port, master_data);
        if (is_slave)
                pci_write_config_byte(dev, slave_port, slave_data);
+
+       /* Ensure the UDMA bit is off - it will be turned back on if
+          UDMA is selected */
+
+       if (ap->udma_mask) {
+               pci_read_config_byte(dev, 0x48, &udma_enable);
+               udma_enable &= ~(1 << (2 * ap->port_no + adev->devno));
+               pci_write_config_byte(dev, 0x48, udma_enable);
+       }
 }
 
 /**
- *     piix_set_dmamode - Initialize host controller PATA PIO timings
+ *     do_pata_set_dmamode - Initialize host controller PATA PIO timings
  *     @ap: Port whose timings we are configuring
- *     @adev: um
+ *     @adev: Drive in question
  *     @udma: udma mode, 0 - 6
+ *     @is_ich: set if the chip is an ICH device
  *
  *     Set UDMA mode for device, in host controller PCI config space.
  *
@@ -712,70 +859,140 @@ static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev)
  *     None (inherited from caller).
  */
 
-static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev)
+static void do_pata_set_dmamode (struct ata_port *ap, struct ata_device *adev, int isich)
 {
-       unsigned int udma       = adev->dma_mode; /* FIXME: MWDMA too */
-       struct pci_dev *dev     = to_pci_dev(ap->host_set->dev);
-       u8 maslave              = ap->hard_port_no ? 0x42 : 0x40;
-       u8 speed                = udma;
-       unsigned int drive_dn   = (ap->hard_port_no ? 2 : 0) + adev->devno;
-       int a_speed             = 3 << (drive_dn * 4);
-       int u_flag              = 1 << drive_dn;
-       int v_flag              = 0x01 << drive_dn;
-       int w_flag              = 0x10 << drive_dn;
-       int u_speed             = 0;
-       int                     sitre;
-       u16                     reg4042, reg4a;
-       u8                      reg48, reg54, reg55;
-
-       pci_read_config_word(dev, maslave, &reg4042);
-       DPRINTK("reg4042 = 0x%04x\n", reg4042);
-       sitre = (reg4042 & 0x4000) ? 1 : 0;
-       pci_read_config_byte(dev, 0x48, &reg48);
-       pci_read_config_word(dev, 0x4a, &reg4a);
-       pci_read_config_byte(dev, 0x54, &reg54);
-       pci_read_config_byte(dev, 0x55, &reg55);
-
-       switch(speed) {
-               case XFER_UDMA_4:
-               case XFER_UDMA_2:       u_speed = 2 << (drive_dn * 4); break;
-               case XFER_UDMA_6:
-               case XFER_UDMA_5:
-               case XFER_UDMA_3:
-               case XFER_UDMA_1:       u_speed = 1 << (drive_dn * 4); break;
-               case XFER_UDMA_0:       u_speed = 0 << (drive_dn * 4); break;
-               case XFER_MW_DMA_2:
-               case XFER_MW_DMA_1:     break;
-               default:
-                       BUG();
-                       return;
-       }
+       struct pci_dev *dev     = to_pci_dev(ap->host->dev);
+       u8 master_port          = ap->port_no ? 0x42 : 0x40;
+       u16 master_data;
+       u8 speed                = adev->dma_mode;
+       int devid               = adev->devno + 2 * ap->port_no;
+       u8 udma_enable;
+
+       static const     /* ISP  RTC */
+       u8 timings[][2] = { { 0, 0 },
+                           { 0, 0 },
+                           { 1, 0 },
+                           { 2, 1 },
+                           { 2, 3 }, };
+
+       pci_read_config_word(dev, master_port, &master_data);
+       pci_read_config_byte(dev, 0x48, &udma_enable);
 
        if (speed >= XFER_UDMA_0) {
-               if (!(reg48 & u_flag))
-                       pci_write_config_byte(dev, 0x48, reg48 | u_flag);
-               if (speed == XFER_UDMA_5) {
-                       pci_write_config_byte(dev, 0x55, (u8) reg55|w_flag);
-               } else {
-                       pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
+               unsigned int udma = adev->dma_mode - XFER_UDMA_0;
+               u16 udma_timing;
+               u16 ideconf;
+               int u_clock, u_speed;
+
+               /*
+                * UDMA is handled by a combination of clock switching and
+                * selection of dividers
+                *
+                * Handy rule: Odd modes are UDMATIMx 01, even are 02
+                *             except UDMA0 which is 00
+                */
+               u_speed = min(2 - (udma & 1), udma);
+               if (udma == 5)
+                       u_clock = 0x1000;       /* 100Mhz */
+               else if (udma > 2)
+                       u_clock = 1;            /* 66Mhz */
+               else
+                       u_clock = 0;            /* 33Mhz */
+
+               udma_enable |= (1 << devid);
+
+               /* Load the CT/RP selection */
+               pci_read_config_word(dev, 0x4A, &udma_timing);
+               udma_timing &= ~(3 << (4 * devid));
+               udma_timing |= u_speed << (4 * devid);
+               pci_write_config_word(dev, 0x4A, udma_timing);
+
+               if (isich) {
+                       /* Select a 33/66/100Mhz clock */
+                       pci_read_config_word(dev, 0x54, &ideconf);
+                       ideconf &= ~(0x1001 << devid);
+                       ideconf |= u_clock << devid;
+                       /* For ICH or later we should set bit 10 for better
+                          performance (WR_PingPong_En) */
+                       pci_write_config_word(dev, 0x54, ideconf);
                }
-               if ((reg4a & a_speed) != u_speed)
-                       pci_write_config_word(dev, 0x4a, (reg4a & ~a_speed) | u_speed);
-               if (speed > XFER_UDMA_2) {
-                       if (!(reg54 & v_flag))
-                               pci_write_config_byte(dev, 0x54, reg54 | v_flag);
-               } else
-                       pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
        } else {
-               if (reg48 & u_flag)
-                       pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
-               if (reg4a & a_speed)
-                       pci_write_config_word(dev, 0x4a, reg4a & ~a_speed);
-               if (reg54 & v_flag)
-                       pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
-               if (reg55 & w_flag)
-                       pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
+               /*
+                * MWDMA is driven by the PIO timings. We must also enable
+                * IORDY unconditionally along with TIME1. PPE has already
+                * been set when the PIO timing was set.
+                */
+               unsigned int mwdma      = adev->dma_mode - XFER_MW_DMA_0;
+               unsigned int control;
+               u8 slave_data;
+               const unsigned int needed_pio[3] = {
+                       XFER_PIO_0, XFER_PIO_3, XFER_PIO_4
+               };
+               int pio = needed_pio[mwdma] - XFER_PIO_0;
+
+               control = 3;    /* IORDY|TIME1 */
+
+               /* If the drive MWDMA is faster than it can do PIO then
+                  we must force PIO into PIO0 */
+
+               if (adev->pio_mode < needed_pio[mwdma])
+                       /* Enable DMA timing only */
+                       control |= 8;   /* PIO cycles in PIO0 */
+
+               if (adev->devno) {      /* Slave */
+                       master_data &= 0xFF4F;  /* Mask out IORDY|TIME1|DMAONLY */
+                       master_data |= control << 4;
+                       pci_read_config_byte(dev, 0x44, &slave_data);
+                       slave_data &= (0x0F + 0xE1 * ap->port_no);
+                       /* Load the matching timing */
+                       slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->port_no ? 4 : 0);
+                       pci_write_config_byte(dev, 0x44, slave_data);
+               } else {        /* Master */
+                       master_data &= 0xCCF4;  /* Mask out IORDY|TIME1|DMAONLY
+                                                  and master timing bits */
+                       master_data |= control;
+                       master_data |=
+                               (timings[pio][0] << 12) |
+                               (timings[pio][1] << 8);
+               }
+               udma_enable &= ~(1 << devid);
+               pci_write_config_word(dev, master_port, master_data);
        }
+       /* Don't scribble on 0x48 if the controller does not support UDMA */
+       if (ap->udma_mask)
+               pci_write_config_byte(dev, 0x48, udma_enable);
+}
+
+/**
+ *     piix_set_dmamode - Initialize host controller PATA DMA timings
+ *     @ap: Port whose timings we are configuring
+ *     @adev: um
+ *
+ *     Set MW/UDMA mode for device, in host controller PCI config space.
+ *
+ *     LOCKING:
+ *     None (inherited from caller).
+ */
+
+static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev)
+{
+       do_pata_set_dmamode(ap, adev, 0);
+}
+
+/**
+ *     ich_set_dmamode - Initialize host controller PATA DMA timings
+ *     @ap: Port whose timings we are configuring
+ *     @adev: um
+ *
+ *     Set MW/UDMA mode for device, in host controller PCI config space.
+ *
+ *     LOCKING:
+ *     None (inherited from caller).
+ */
+
+static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev)
+{
+       do_pata_set_dmamode(ap, adev, 1);
 }
 
 #define AHCI_PCI_BAR 5
@@ -867,13 +1084,13 @@ static void __devinit piix_init_pcs(struct pci_dev *pdev,
        if (force_pcs == 1) {
                dev_printk(KERN_INFO, &pdev->dev,
                           "force ignoring PCS (0x%x)\n", new_pcs);
-               pinfo[0].host_flags |= PIIX_FLAG_IGNORE_PCS;
-               pinfo[1].host_flags |= PIIX_FLAG_IGNORE_PCS;
+               pinfo[0].flags |= PIIX_FLAG_IGNORE_PCS;
+               pinfo[1].flags |= PIIX_FLAG_IGNORE_PCS;
        } else if (force_pcs == 2) {
                dev_printk(KERN_INFO, &pdev->dev,
                           "force honoring PCS (0x%x)\n", new_pcs);
-               pinfo[0].host_flags &= ~PIIX_FLAG_IGNORE_PCS;
-               pinfo[1].host_flags &= ~PIIX_FLAG_IGNORE_PCS;
+               pinfo[0].flags &= ~PIIX_FLAG_IGNORE_PCS;
+               pinfo[1].flags &= ~PIIX_FLAG_IGNORE_PCS;
        }
 }
 
@@ -904,7 +1121,7 @@ static void __devinit piix_init_sata_map(struct pci_dev *pdev,
 
                case IDE:
                        WARN_ON((i & 1) || map[i + 1] != IDE);
-                       pinfo[i / 2] = piix_port_info[ich5_pata];
+                       pinfo[i / 2] = piix_port_info[ich_pata_100];
                        pinfo[i / 2].private_data = hpriv;
                        i++;
                        printk(" IDE IDE");
@@ -913,7 +1130,7 @@ static void __devinit piix_init_sata_map(struct pci_dev *pdev,
                default:
                        printk(" P%d", map[i]);
                        if (i & 1)
-                               pinfo[i / 2].host_flags |= ATA_FLAG_SLAVE_POSS;
+                               pinfo[i / 2].flags |= ATA_FLAG_SLAVE_POSS;
                        break;
                }
        }
@@ -948,7 +1165,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        struct ata_port_info port_info[2];
        struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] };
        struct piix_host_priv *hpriv;
-       unsigned long host_flags;
+       unsigned long port_flags;
 
        if (!printed_version++)
                dev_printk(KERN_DEBUG, &pdev->dev,
@@ -967,9 +1184,9 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        port_info[0].private_data = hpriv;
        port_info[1].private_data = hpriv;
 
-       host_flags = port_info[0].host_flags;
+       port_flags = port_info[0].flags;
 
-       if (host_flags & PIIX_FLAG_AHCI) {
+       if (port_flags & PIIX_FLAG_AHCI) {
                u8 tmp;
                pci_read_config_byte(pdev, PIIX_SCC, &tmp);
                if (tmp == PIIX_AHCI_DEVICE) {
@@ -980,7 +1197,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        }
 
        /* Initialize SATA map */
-       if (host_flags & ATA_FLAG_SATA) {
+       if (port_flags & ATA_FLAG_SATA) {
                piix_init_sata_map(pdev, port_info,
                                   piix_map_db_table[ent->driver_data]);
                piix_init_pcs(pdev, port_info,
@@ -993,7 +1210,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
         * MSI is disabled (and it is disabled, as we don't use
         * message-signalled interrupts currently).
         */
-       if (host_flags & PIIX_FLAG_CHECKINTR)
+       if (port_flags & PIIX_FLAG_CHECKINTR)
                pci_intx(pdev, 1);
 
        if (piix_check_450nx_errata(pdev)) {
@@ -1008,19 +1225,21 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        return ata_pci_init_one(pdev, ppinfo, 2);
 }
 
-static void piix_host_stop(struct ata_host_set *host_set)
+static void piix_host_stop(struct ata_host *host)
 {
-       if (host_set->next == NULL)
-               kfree(host_set->private_data);
-       ata_host_stop(host_set);
+       struct piix_host_priv *hpriv = host->private_data;
+
+       ata_host_stop(host);
+
+       kfree(hpriv);
 }
 
 static int __init piix_init(void)
 {
        int rc;
 
-       DPRINTK("pci_module_init\n");
-       rc = pci_module_init(&piix_pci_driver);
+       DPRINTK("pci_register_driver\n");
+       rc = pci_register_driver(&piix_pci_driver);
        if (rc)
                return rc;
 
@@ -1037,4 +1256,3 @@ static void __exit piix_exit(void)
 
 module_init(piix_init);
 module_exit(piix_exit);
-
similarity index 92%
rename from drivers/scsi/libata-core.c
rename to drivers/ata/libata-core.c
index 427b73a3886a83e7d0b6b0bc4cf272044db129e7..753b0152afd16f15dd655bafacff32d1dc5dd473 100644 (file)
@@ -50,7 +50,6 @@
 #include <linux/jiffies.h>
 #include <linux/scatterlist.h>
 #include <scsi/scsi.h>
-#include "scsi_priv.h"
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
@@ -387,9 +386,13 @@ static const char *ata_mode_string(unsigned int xfer_mask)
                "PIO2",
                "PIO3",
                "PIO4",
+               "PIO5",
+               "PIO6",
                "MWDMA0",
                "MWDMA1",
                "MWDMA2",
+               "MWDMA3",
+               "MWDMA4",
                "UDMA/16",
                "UDMA/25",
                "UDMA/33",
@@ -613,8 +616,11 @@ ata_dev_try_classify(struct ata_port *ap, unsigned int device, u8 *r_err)
        if (r_err)
                *r_err = err;
 
-       /* see if device passed diags */
-       if (err == 1)
+       /* see if device passed diags: if master then continue and warn later */
+       if (err == 0 && device == 0)
+               /* diagnostic fail : do nothing _YET_ */
+               ap->device[device].horkage |= ATA_HORKAGE_DIAGNOSTIC;
+       else if (err == 1)
                /* do nothing */ ;
        else if ((device == 0) && (err == 0x81))
                /* do nothing */ ;
@@ -876,6 +882,23 @@ static unsigned int ata_id_xfermask(const u16 *id)
 
        mwdma_mask = id[ATA_ID_MWDMA_MODES] & 0x07;
 
+       if (ata_id_is_cfa(id)) {
+               /*
+                *      Process compact flash extended modes
+                */
+               int pio = id[163] & 0x7;
+               int dma = (id[163] >> 3) & 7;
+
+               if (pio)
+                       pio_mask |= (1 << 5);
+               if (pio > 1)
+                       pio_mask |= (1 << 6);
+               if (dma)
+                       mwdma_mask |= (1 << 3);
+               if (dma > 1)
+                       mwdma_mask |= (1 << 4);
+       }
+
        udma_mask = 0;
        if (id[ATA_ID_FIELD_VALID] & (1 << 2))
                udma_mask = id[ATA_ID_UDMA_MODES] & 0xff;
@@ -1320,7 +1343,7 @@ static void ata_dev_config_ncq(struct ata_device *dev,
        }
 
        if (ap->flags & ATA_FLAG_NCQ) {
-               hdepth = min(ap->host->can_queue, ATA_MAX_QUEUE - 1);
+               hdepth = min(ap->scsi_host->can_queue, ATA_MAX_QUEUE - 1);
                dev->flags |= ATA_DFLAG_NCQ;
        }
 
@@ -1334,12 +1357,13 @@ static void ata_set_port_max_cmd_len(struct ata_port *ap)
 {
        int i;
 
-       if (ap->host) {
-               ap->host->max_cmd_len = 0;
+       if (ap->scsi_host) {
+               unsigned int len = 0;
+
                for (i = 0; i < ATA_MAX_DEVICES; i++)
-                       ap->host->max_cmd_len = max_t(unsigned int,
-                                                     ap->host->max_cmd_len,
-                                                     ap->device[i].cdb_len);
+                       len = max(len, ap->device[i].cdb_len);
+
+               ap->scsi_host->max_cmd_len = len;
        }
 }
 
@@ -1362,6 +1386,7 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
        struct ata_port *ap = dev->ap;
        const u16 *id = dev->id;
        unsigned int xfer_mask;
+       char revbuf[7];         /* XYZ-99\0 */
        int rc;
 
        if (!ata_dev_enabled(dev) && ata_msg_info(ap)) {
@@ -1405,6 +1430,15 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
 
        /* ATA-specific feature tests */
        if (dev->class == ATA_DEV_ATA) {
+               if (ata_id_is_cfa(id)) {
+                       if (id[162] & 1) /* CPRM may make this media unusable */
+                               ata_dev_printk(dev, KERN_WARNING, "ata%u: device %u  supports DRM functions and may not be fully accessable.\n",
+                                       ap->id, dev->devno);
+                       snprintf(revbuf, 7, "CFA");
+               }
+               else
+                       snprintf(revbuf, 7, "ATA-%d",  ata_id_major_version(id));
+
                dev->n_sectors = ata_id_n_sectors(id);
 
                if (ata_id_has_lba(id)) {
@@ -1423,9 +1457,9 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
 
                        /* print device info to dmesg */
                        if (ata_msg_drv(ap) && print_info)
-                               ata_dev_printk(dev, KERN_INFO, "ATA-%d, "
+                               ata_dev_printk(dev, KERN_INFO, "%s, "
                                        "max %s, %Lu sectors: %s %s\n",
-                                       ata_id_major_version(id),
+                                       revbuf,
                                        ata_mode_string(xfer_mask),
                                        (unsigned long long)dev->n_sectors,
                                        lba_desc, ncq_desc);
@@ -1446,9 +1480,9 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
 
                        /* print device info to dmesg */
                        if (ata_msg_drv(ap) && print_info)
-                               ata_dev_printk(dev, KERN_INFO, "ATA-%d, "
+                               ata_dev_printk(dev, KERN_INFO, "%s, "
                                        "max %s, %Lu sectors: CHS %u/%u/%u\n",
-                                       ata_id_major_version(id),
+                                       revbuf,
                                        ata_mode_string(xfer_mask),
                                        (unsigned long long)dev->n_sectors,
                                        dev->cylinders, dev->heads,
@@ -1492,6 +1526,18 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
                                       cdb_intr_string);
        }
 
+       if (dev->horkage & ATA_HORKAGE_DIAGNOSTIC) {
+               /* Let the user know. We don't want to disallow opens for
+                  rescue purposes, or in case the vendor is just a blithering
+                  idiot */
+                if (print_info) {
+                       ata_dev_printk(dev, KERN_WARNING,
+"Drive reports diagnostics failure. This may indicate a drive\n");
+                       ata_dev_printk(dev, KERN_WARNING,
+"fault or invalid emulation. Contact drive vendor for information.\n");
+               }
+       }
+
        ata_set_port_max_cmd_len(ap);
 
        /* limit bridge transfers to udma5, 200 sectors */
@@ -1533,7 +1579,7 @@ err_out_nosup:
  *     Zero on success, negative errno otherwise.
  */
 
-static int ata_bus_probe(struct ata_port *ap)
+int ata_bus_probe(struct ata_port *ap)
 {
        unsigned int classes[ATA_MAX_DEVICES];
        int tries[ATA_MAX_DEVICES];
@@ -1637,7 +1683,7 @@ static int ata_bus_probe(struct ata_port *ap)
  *     Modify @ap data structure such that the system
  *     thinks that the entire port is enabled.
  *
- *     LOCKING: host_set lock, or some other form of
+ *     LOCKING: host lock, or some other form of
  *     serialization.
  */
 
@@ -1775,7 +1821,7 @@ struct ata_device *ata_dev_pair(struct ata_device *adev)
  *     never attempt to probe or communicate with devices
  *     on this port.
  *
- *     LOCKING: host_set lock, or some other form of
+ *     LOCKING: host lock, or some other form of
  *     serialization.
  */
 
@@ -1906,10 +1952,11 @@ int sata_set_spd(struct ata_port *ap)
  * drivers/ide/ide-timing.h and was originally written by Vojtech Pavlik
  */
 /*
- * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
+ * PIO 0-4, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
  * These were taken from ATA/ATAPI-6 standard, rev 0a, except
- * for PIO 5, which is a nonstandard extension and UDMA6, which
- * is currently supported only by Maxtor drives.
+ * for UDMA6, which is currently supported only by Maxtor drives.
+ *
+ * For PIO 5/6 MWDMA 3/4 see the CFA specification 3.0.
  */
 
 static const struct ata_timing ata_timing[] = {
@@ -1919,6 +1966,8 @@ static const struct ata_timing ata_timing[] = {
        { XFER_UDMA_4,     0,   0,   0,   0,   0,   0,   0,  30 },
        { XFER_UDMA_3,     0,   0,   0,   0,   0,   0,   0,  45 },
 
+       { XFER_MW_DMA_4,  25,   0,   0,   0,  55,  20,  80,   0 },
+       { XFER_MW_DMA_3,  25,   0,   0,   0,  65,  25, 100,   0 },
        { XFER_UDMA_2,     0,   0,   0,   0,   0,   0,   0,  60 },
        { XFER_UDMA_1,     0,   0,   0,   0,   0,   0,   0,  80 },
        { XFER_UDMA_0,     0,   0,   0,   0,   0,   0,   0, 120 },
@@ -1933,7 +1982,8 @@ static const struct ata_timing ata_timing[] = {
        { XFER_SW_DMA_1,  90,   0,   0,   0, 240, 240, 480,   0 },
        { XFER_SW_DMA_0, 120,   0,   0,   0, 480, 480, 960,   0 },
 
-/*     { XFER_PIO_5,     20,  50,  30, 100,  50,  30, 100,   0 }, */
+       { XFER_PIO_6,     10,  55,  20,  80,  55,  20,  80,   0 },
+       { XFER_PIO_5,     15,  65,  25, 100,  65,  25, 100,   0 },
        { XFER_PIO_4,     25,  70,  25, 120,  70,  25, 120,   0 },
        { XFER_PIO_3,     30,  80,  70, 180,  80,  70, 180,   0 },
 
@@ -2229,8 +2279,8 @@ int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
        /* Record simplex status. If we selected DMA then the other
         * host channels are not permitted to do so.
         */
-       if (used_dma && (ap->host_set->flags & ATA_HOST_SIMPLEX))
-               ap->host_set->simplex_claimed = 1;
+       if (used_dma && (ap->host->flags & ATA_HOST_SIMPLEX))
+               ap->host->simplex_claimed = 1;
 
        /* step5: chip specific finalisation */
        if (ap->ops->post_set_mode)
@@ -2252,7 +2302,7 @@ int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
  *     other threads.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 static inline void ata_tf_to_host(struct ata_port *ap,
@@ -2416,7 +2466,7 @@ static unsigned int ata_bus_softreset(struct ata_port *ap,
  *
  *     LOCKING:
  *     PCI/etc. bus probe sem.
- *     Obtains host_set lock.
+ *     Obtains host lock.
  *
  *     SIDE EFFECTS:
  *     Sets ATA_FLAG_DISABLED if bus reset fails.
@@ -3045,20 +3095,16 @@ static int ata_dma_blacklisted(const struct ata_device *dev)
  *     known limits including host controller limits, device
  *     blacklist, etc...
  *
- *     FIXME: The current implementation limits all transfer modes to
- *     the fastest of the lowested device on the port.  This is not
- *     required on most controllers.
- *
  *     LOCKING:
  *     None.
  */
 static void ata_dev_xfermask(struct ata_device *dev)
 {
        struct ata_port *ap = dev->ap;
-       struct ata_host_set *hs = ap->host_set;
+       struct ata_host *host = ap->host;
        unsigned long xfer_mask;
-       int i;
 
+       /* controller modes available */
        xfer_mask = ata_pack_xfermask(ap->pio_mask,
                                      ap->mwdma_mask, ap->udma_mask);
 
@@ -3068,34 +3114,31 @@ static void ata_dev_xfermask(struct ata_device *dev)
        if (ap->cbl == ATA_CBL_PATA40)
                xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA);
 
-       /* FIXME: Use port-wide xfermask for now */
-       for (i = 0; i < ATA_MAX_DEVICES; i++) {
-               struct ata_device *d = &ap->device[i];
+       xfer_mask &= ata_pack_xfermask(dev->pio_mask,
+                                      dev->mwdma_mask, dev->udma_mask);
+       xfer_mask &= ata_id_xfermask(dev->id);
 
-               if (ata_dev_absent(d))
-                       continue;
-
-               if (ata_dev_disabled(d)) {
-                       /* to avoid violating device selection timing */
-                       xfer_mask &= ata_pack_xfermask(d->pio_mask,
-                                                      UINT_MAX, UINT_MAX);
-                       continue;
-               }
-
-               xfer_mask &= ata_pack_xfermask(d->pio_mask,
-                                              d->mwdma_mask, d->udma_mask);
-               xfer_mask &= ata_id_xfermask(d->id);
-               if (ata_dma_blacklisted(d))
-                       xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
+       /*
+        *      CFA Advanced TrueIDE timings are not allowed on a shared
+        *      cable
+        */
+       if (ata_dev_pair(dev)) {
+               /* No PIO5 or PIO6 */
+               xfer_mask &= ~(0x03 << (ATA_SHIFT_PIO + 5));
+               /* No MWDMA3 or MWDMA 4 */
+               xfer_mask &= ~(0x03 << (ATA_SHIFT_MWDMA + 3));
        }
 
-       if (ata_dma_blacklisted(dev))
+       if (ata_dma_blacklisted(dev)) {
+               xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
                ata_dev_printk(dev, KERN_WARNING,
                               "device is on DMA blacklist, disabling DMA\n");
+       }
 
-       if (hs->flags & ATA_HOST_SIMPLEX) {
-               if (hs->simplex_claimed)
-                       xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
+       if ((host->flags & ATA_HOST_SIMPLEX) && host->simplex_claimed) {
+               xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
+               ata_dev_printk(dev, KERN_WARNING, "simplex DMA is claimed by "
+                              "other device, disabling DMA\n");
        }
 
        if (ap->ops->mode_filter)
@@ -3185,7 +3228,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev,
  *     Unmap all mapped DMA memory associated with this command.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 static void ata_sg_clean(struct ata_queued_cmd *qc)
@@ -3245,7 +3288,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc)
  *     associated with the current disk command.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  */
 static void ata_fill_sg(struct ata_queued_cmd *qc)
@@ -3297,7 +3340,7 @@ static void ata_fill_sg(struct ata_queued_cmd *qc)
  *     supplied PACKET command.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS: 0 when ATAPI DMA can be used
  *               nonzero otherwise
@@ -3319,7 +3362,7 @@ int ata_check_atapi_dma(struct ata_queued_cmd *qc)
  *     Prepare ATA taskfile for submission.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 void ata_qc_prep(struct ata_queued_cmd *qc)
 {
@@ -3341,7 +3384,7 @@ void ata_noop_qc_prep(struct ata_queued_cmd *qc) { }
  *     to point to a single memory buffer, @buf of byte length @buflen.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)
@@ -3372,7 +3415,7 @@ void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen)
  *     elements.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
@@ -3391,7 +3434,7 @@ void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
  *     DMA-map the memory buffer associated with queued_cmd @qc.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     Zero on success, negative on error.
@@ -3460,7 +3503,7 @@ skip_map:
  *     DMA-map the scatter-gather table associated with queued_cmd @qc.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     Zero on success, negative on error.
@@ -3969,7 +4012,7 @@ static inline int ata_hsm_ok_in_wq(struct ata_port *ap, struct ata_queued_cmd *q
  *     Finish @qc which is running on standard HSM.
  *
  *     LOCKING:
- *     If @in_wq is zero, spin_lock_irqsave(host_set lock).
+ *     If @in_wq is zero, spin_lock_irqsave(host lock).
  *     Otherwise, none on entry and grabs host lock.
  */
 static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
@@ -3981,8 +4024,8 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
                if (in_wq) {
                        spin_lock_irqsave(ap->lock, flags);
 
-                       /* EH might have kicked in while host_set lock
-                        * is released.
+                       /* EH might have kicked in while host lock is
+                        * released.
                         */
                        qc = ata_qc_from_tag(ap, qc->tag);
                        if (qc) {
@@ -4347,7 +4390,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev)
  *     in case something prevents using it.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 void ata_qc_free(struct ata_queued_cmd *qc)
 {
@@ -4400,7 +4443,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
  *     command has completed, with either an ok or not-ok status.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 void ata_qc_complete(struct ata_queued_cmd *qc)
 {
@@ -4463,7 +4506,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
  *     and commands are completed accordingly.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     Number of completed commands on success, -errno otherwise.
@@ -4534,7 +4577,7 @@ static inline int ata_should_dma_map(struct ata_queued_cmd *qc)
  *     writing the taskfile to hardware, starting the command.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 void ata_qc_issue(struct ata_queued_cmd *qc)
 {
@@ -4595,7 +4638,7 @@ err:
  *     May be used as the qc_issue() entry in ata_port_operations.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     Zero on success, AC_ERR_* mask on failure
@@ -4724,7 +4767,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
  *     handled via polling with interrupts disabled (nIEN bit).
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     One if interrupt was handled, zero if not (shared irq).
@@ -4811,14 +4854,14 @@ idle_irq:
 /**
  *     ata_interrupt - Default ATA host interrupt handler
  *     @irq: irq line (unused)
- *     @dev_instance: pointer to our ata_host_set information structure
+ *     @dev_instance: pointer to our ata_host information structure
  *     @regs: unused
  *
  *     Default interrupt handler for PCI IDE devices.  Calls
  *     ata_host_intr() for each port that is not disabled.
  *
  *     LOCKING:
- *     Obtains host_set lock during operation.
+ *     Obtains host lock during operation.
  *
  *     RETURNS:
  *     IRQ_NONE or IRQ_HANDLED.
@@ -4826,18 +4869,18 @@ idle_irq:
 
 irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
 {
-       struct ata_host_set *host_set = dev_instance;
+       struct ata_host *host = dev_instance;
        unsigned int i;
        unsigned int handled = 0;
        unsigned long flags;
 
        /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */
-       spin_lock_irqsave(&host_set->lock, flags);
+       spin_lock_irqsave(&host->lock, flags);
 
-       for (i = 0; i < host_set->n_ports; i++) {
+       for (i = 0; i < host->n_ports; i++) {
                struct ata_port *ap;
 
-               ap = host_set->ports[i];
+               ap = host->ports[i];
                if (ap &&
                    !(ap->flags & ATA_FLAG_DISABLED)) {
                        struct ata_queued_cmd *qc;
@@ -4849,7 +4892,7 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
                }
        }
 
-       spin_unlock_irqrestore(&host_set->lock, flags);
+       spin_unlock_irqrestore(&host->lock, flags);
 
        return IRQ_RETVAL(handled);
 }
@@ -5014,15 +5057,15 @@ int ata_flush_cache(struct ata_device *dev)
        return 0;
 }
 
-static int ata_host_set_request_pm(struct ata_host_set *host_set,
-                                  pm_message_t mesg, unsigned int action,
-                                  unsigned int ehi_flags, int wait)
+static int ata_host_request_pm(struct ata_host *host, pm_message_t mesg,
+                              unsigned int action, unsigned int ehi_flags,
+                              int wait)
 {
        unsigned long flags;
        int i, rc;
 
-       for (i = 0; i < host_set->n_ports; i++) {
-               struct ata_port *ap = host_set->ports[i];
+       for (i = 0; i < host->n_ports; i++) {
+               struct ata_port *ap = host->ports[i];
 
                /* Previous resume operation might still be in
                 * progress.  Wait for PM_PENDING to clear.
@@ -5062,11 +5105,11 @@ static int ata_host_set_request_pm(struct ata_host_set *host_set,
 }
 
 /**
- *     ata_host_set_suspend - suspend host_set
- *     @host_set: host_set to suspend
+ *     ata_host_suspend - suspend host
+ *     @host: host to suspend
  *     @mesg: PM message
  *
- *     Suspend @host_set.  Actual operation is performed by EH.  This
+ *     Suspend @host.  Actual operation is performed by EH.  This
  *     function requests EH to perform PM operations and waits for EH
  *     to finish.
  *
@@ -5076,11 +5119,11 @@ static int ata_host_set_request_pm(struct ata_host_set *host_set,
  *     RETURNS:
  *     0 on success, -errno on failure.
  */
-int ata_host_set_suspend(struct ata_host_set *host_set, pm_message_t mesg)
+int ata_host_suspend(struct ata_host *host, pm_message_t mesg)
 {
        int i, j, rc;
 
-       rc = ata_host_set_request_pm(host_set, mesg, 0, ATA_EHI_QUIET, 1);
+       rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1);
        if (rc)
                goto fail;
 
@@ -5088,8 +5131,8 @@ int ata_host_set_suspend(struct ata_host_set *host_set, pm_message_t mesg)
         * This happens if hotplug occurs between completion of device
         * suspension and here.
         */
-       for (i = 0; i < host_set->n_ports; i++) {
-               struct ata_port *ap = host_set->ports[i];
+       for (i = 0; i < host->n_ports; i++) {
+               struct ata_port *ap = host->ports[i];
 
                for (j = 0; j < ATA_MAX_DEVICES; j++) {
                        struct ata_device *dev = &ap->device[j];
@@ -5104,30 +5147,30 @@ int ata_host_set_suspend(struct ata_host_set *host_set, pm_message_t mesg)
                }
        }
 
-       host_set->dev->power.power_state = mesg;
+       host->dev->power.power_state = mesg;
        return 0;
 
  fail:
-       ata_host_set_resume(host_set);
+       ata_host_resume(host);
        return rc;
 }
 
 /**
- *     ata_host_set_resume - resume host_set
- *     @host_set: host_set to resume
+ *     ata_host_resume - resume host
+ *     @host: host to resume
  *
- *     Resume @host_set.  Actual operation is performed by EH.  This
+ *     Resume @host.  Actual operation is performed by EH.  This
  *     function requests EH to perform PM operations and returns.
  *     Note that all resume operations are performed parallely.
  *
  *     LOCKING:
  *     Kernel thread context (may sleep).
  */
-void ata_host_set_resume(struct ata_host_set *host_set)
+void ata_host_resume(struct ata_host *host)
 {
-       ata_host_set_request_pm(host_set, PMSG_ON, ATA_EH_SOFTRESET,
-                               ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 0);
-       host_set->dev->power.power_state = PMSG_ON;
+       ata_host_request_pm(host, PMSG_ON, ATA_EH_SOFTRESET,
+                           ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 0);
+       host->dev->power.power_state = PMSG_ON;
 }
 
 /**
@@ -5184,10 +5227,10 @@ void ata_port_stop (struct ata_port *ap)
        ata_pad_free(ap, dev);
 }
 
-void ata_host_stop (struct ata_host_set *host_set)
+void ata_host_stop (struct ata_host *host)
 {
-       if (host_set->mmio_base)
-               iounmap(host_set->mmio_base);
+       if (host->mmio_base)
+               iounmap(host->mmio_base);
 }
 
 /**
@@ -5209,7 +5252,7 @@ void ata_dev_init(struct ata_device *dev)
 
        /* High bits of dev->flags are used to record warm plug
         * requests which occur asynchronously.  Synchronize using
-        * host_set lock.
+        * host lock.
         */
        spin_lock_irqsave(ap->lock, flags);
        dev->flags &= ~ATA_DFLAG_INIT_MASK;
@@ -5223,46 +5266,42 @@ void ata_dev_init(struct ata_device *dev)
 }
 
 /**
- *     ata_host_init - Initialize an ata_port structure
+ *     ata_port_init - Initialize an ata_port structure
  *     @ap: Structure to initialize
- *     @host: associated SCSI mid-layer structure
- *     @host_set: Collection of hosts to which @ap belongs
+ *     @host: Collection of hosts to which @ap belongs
  *     @ent: Probe information provided by low-level driver
  *     @port_no: Port number associated with this ata_port
  *
- *     Initialize a new ata_port structure, and its associated
- *     scsi_host.
+ *     Initialize a new ata_port structure.
  *
  *     LOCKING:
  *     Inherited from caller.
  */
-static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
-                         struct ata_host_set *host_set,
-                         const struct ata_probe_ent *ent, unsigned int port_no)
+void ata_port_init(struct ata_port *ap, struct ata_host *host,
+                  const struct ata_probe_ent *ent, unsigned int port_no)
 {
        unsigned int i;
 
-       host->max_id = 16;
-       host->max_lun = 1;
-       host->max_channel = 1;
-       host->unique_id = ata_unique_id++;
-       host->max_cmd_len = 12;
-
-       ap->lock = &host_set->lock;
+       ap->lock = &host->lock;
        ap->flags = ATA_FLAG_DISABLED;
-       ap->id = host->unique_id;
-       ap->host = host;
+       ap->id = ata_unique_id++;
        ap->ctl = ATA_DEVCTL_OBS;
-       ap->host_set = host_set;
+       ap->host = host;
        ap->dev = ent->dev;
        ap->port_no = port_no;
-       ap->hard_port_no =
-               ent->legacy_mode ? ent->hard_port_no : port_no;
-       ap->pio_mask = ent->pio_mask;
-       ap->mwdma_mask = ent->mwdma_mask;
-       ap->udma_mask = ent->udma_mask;
-       ap->flags |= ent->host_flags;
-       ap->ops = ent->port_ops;
+       if (port_no == 1 && ent->pinfo2) {
+               ap->pio_mask = ent->pinfo2->pio_mask;
+               ap->mwdma_mask = ent->pinfo2->mwdma_mask;
+               ap->udma_mask = ent->pinfo2->udma_mask;
+               ap->flags |= ent->pinfo2->flags;
+               ap->ops = ent->pinfo2->port_ops;
+       } else {
+               ap->pio_mask = ent->pio_mask;
+               ap->mwdma_mask = ent->mwdma_mask;
+               ap->udma_mask = ent->udma_mask;
+               ap->flags |= ent->port_flags;
+               ap->ops = ent->port_ops;
+       }
        ap->hw_sata_spd_limit = UINT_MAX;
        ap->active_tag = ATA_TAG_POISON;
        ap->last_ctl = 0xFF;
@@ -5303,9 +5342,30 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
 }
 
 /**
- *     ata_host_add - Attach low-level ATA driver to system
+ *     ata_port_init_shost - Initialize SCSI host associated with ATA port
+ *     @ap: ATA port to initialize SCSI host for
+ *     @shost: SCSI host associated with @ap
+ *
+ *     Initialize SCSI host @shost associated with ATA port @ap.
+ *
+ *     LOCKING:
+ *     Inherited from caller.
+ */
+static void ata_port_init_shost(struct ata_port *ap, struct Scsi_Host *shost)
+{
+       ap->scsi_host = shost;
+
+       shost->unique_id = ap->id;
+       shost->max_id = 16;
+       shost->max_lun = 1;
+       shost->max_channel = 1;
+       shost->max_cmd_len = 12;
+}
+
+/**
+ *     ata_port_add - Attach low-level ATA driver to system
  *     @ent: Information provided by low-level driver
- *     @host_set: Collections of ports to which we add
+ *     @host: Collections of ports to which we add
  *     @port_no: Port number associated with this host
  *
  *     Attach low-level ATA driver to system.
@@ -5316,43 +5376,55 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
  *     RETURNS:
  *     New ata_port on success, for NULL on error.
  */
-
-static struct ata_port * ata_host_add(const struct ata_probe_ent *ent,
-                                     struct ata_host_set *host_set,
+static struct ata_port * ata_port_add(const struct ata_probe_ent *ent,
+                                     struct ata_host *host,
                                      unsigned int port_no)
 {
-       struct Scsi_Host *host;
+       struct Scsi_Host *shost;
        struct ata_port *ap;
-       int rc;
 
        DPRINTK("ENTER\n");
 
        if (!ent->port_ops->error_handler &&
-           !(ent->host_flags & (ATA_FLAG_SATA_RESET | ATA_FLAG_SRST))) {
+           !(ent->port_flags & (ATA_FLAG_SATA_RESET | ATA_FLAG_SRST))) {
                printk(KERN_ERR "ata%u: no reset mechanism available\n",
                       port_no);
                return NULL;
        }
 
-       host = scsi_host_alloc(ent->sht, sizeof(struct ata_port));
-       if (!host)
+       shost = scsi_host_alloc(ent->sht, sizeof(struct ata_port));
+       if (!shost)
                return NULL;
 
-       host->transportt = &ata_scsi_transport_template;
+       shost->transportt = &ata_scsi_transport_template;
 
-       ap = ata_shost_to_port(host);
+       ap = ata_shost_to_port(shost);
 
-       ata_host_init(ap, host, host_set, ent, port_no);
-
-       rc = ap->ops->port_start(ap);
-       if (rc)
-               goto err_out;
+       ata_port_init(ap, host, ent, port_no);
+       ata_port_init_shost(ap, shost);
 
        return ap;
+}
 
-err_out:
-       scsi_host_put(host);
-       return NULL;
+/**
+ *     ata_sas_host_init - Initialize a host struct
+ *     @host:  host to initialize
+ *     @dev:   device host is attached to
+ *     @flags: host flags
+ *     @ops:   port_ops
+ *
+ *     LOCKING:
+ *     PCI/etc. bus probe sem.
+ *
+ */
+
+void ata_host_init(struct ata_host *host, struct device *dev,
+                  unsigned long flags, const struct ata_port_operations *ops)
+{
+       spin_lock_init(&host->lock);
+       host->dev = dev;
+       host->flags = flags;
+       host->ops = ops;
 }
 
 /**
@@ -5375,78 +5447,106 @@ err_out:
  */
 int ata_device_add(const struct ata_probe_ent *ent)
 {
-       unsigned int count = 0, i;
+       unsigned int i;
        struct device *dev = ent->dev;
-       struct ata_host_set *host_set;
+       struct ata_host *host;
        int rc;
 
        DPRINTK("ENTER\n");
        /* alloc a container for our list of ATA ports (buses) */
-       host_set = kzalloc(sizeof(struct ata_host_set) +
-                          (ent->n_ports * sizeof(void *)), GFP_KERNEL);
-       if (!host_set)
+       host = kzalloc(sizeof(struct ata_host) +
+                      (ent->n_ports * sizeof(void *)), GFP_KERNEL);
+       if (!host)
                return 0;
-       spin_lock_init(&host_set->lock);
 
-       host_set->dev = dev;
-       host_set->n_ports = ent->n_ports;
-       host_set->irq = ent->irq;
-       host_set->mmio_base = ent->mmio_base;
-       host_set->private_data = ent->private_data;
-       host_set->ops = ent->port_ops;
-       host_set->flags = ent->host_set_flags;
+       ata_host_init(host, dev, ent->_host_flags, ent->port_ops);
+       host->n_ports = ent->n_ports;
+       host->irq = ent->irq;
+       host->irq2 = ent->irq2;
+       host->mmio_base = ent->mmio_base;
+       host->private_data = ent->private_data;
 
        /* register each port bound to this device */
-       for (i = 0; i < ent->n_ports; i++) {
+       for (i = 0; i < host->n_ports; i++) {
                struct ata_port *ap;
                unsigned long xfer_mode_mask;
+               int irq_line = ent->irq;
 
-               ap = ata_host_add(ent, host_set, i);
+               ap = ata_port_add(ent, host, i);
                if (!ap)
                        goto err_out;
 
-               host_set->ports[i] = ap;
+               host->ports[i] = ap;
+
+               /* dummy? */
+               if (ent->dummy_port_mask & (1 << i)) {
+                       ata_port_printk(ap, KERN_INFO, "DUMMY\n");
+                       ap->ops = &ata_dummy_port_ops;
+                       continue;
+               }
+
+               /* start port */
+               rc = ap->ops->port_start(ap);
+               if (rc) {
+                       host->ports[i] = NULL;
+                       scsi_host_put(ap->scsi_host);
+                       goto err_out;
+               }
+
+               /* Report the secondary IRQ for second channel legacy */
+               if (i == 1 && ent->irq2)
+                       irq_line = ent->irq2;
+
                xfer_mode_mask =(ap->udma_mask << ATA_SHIFT_UDMA) |
                                (ap->mwdma_mask << ATA_SHIFT_MWDMA) |
                                (ap->pio_mask << ATA_SHIFT_PIO);
 
                /* print per-port info to dmesg */
                ata_port_printk(ap, KERN_INFO, "%cATA max %s cmd 0x%lX "
-                               "ctl 0x%lX bmdma 0x%lX irq %lu\n",
+                               "ctl 0x%lX bmdma 0x%lX irq %d\n",
                                ap->flags & ATA_FLAG_SATA ? 'S' : 'P',
                                ata_mode_string(xfer_mode_mask),
                                ap->ioaddr.cmd_addr,
                                ap->ioaddr.ctl_addr,
                                ap->ioaddr.bmdma_addr,
-                               ent->irq);
+                               irq_line);
 
                ata_chk_status(ap);
-               host_set->ops->irq_clear(ap);
+               host->ops->irq_clear(ap);
                ata_eh_freeze_port(ap); /* freeze port before requesting IRQ */
-               count++;
        }
 
-       if (!count)
-               goto err_free_ret;
-
-       /* obtain irq, that is shared between channels */
+       /* obtain irq, that may be shared between channels */
        rc = request_irq(ent->irq, ent->port_ops->irq_handler, ent->irq_flags,
-                        DRV_NAME, host_set);
+                        DRV_NAME, host);
        if (rc) {
                dev_printk(KERN_ERR, dev, "irq %lu request failed: %d\n",
                           ent->irq, rc);
                goto err_out;
        }
 
+       /* do we have a second IRQ for the other channel, eg legacy mode */
+       if (ent->irq2) {
+               /* We will get weird core code crashes later if this is true
+                  so trap it now */
+               BUG_ON(ent->irq == ent->irq2);
+
+               rc = request_irq(ent->irq2, ent->port_ops->irq_handler, ent->irq_flags,
+                        DRV_NAME, host);
+               if (rc) {
+                       dev_printk(KERN_ERR, dev, "irq %lu request failed: %d\n",
+                                  ent->irq2, rc);
+                       goto err_out_free_irq;
+               }
+       }
+
        /* perform each probe synchronously */
        DPRINTK("probe begin\n");
-       for (i = 0; i < count; i++) {
-               struct ata_port *ap;
+       for (i = 0; i < host->n_ports; i++) {
+               struct ata_port *ap = host->ports[i];
                u32 scontrol;
                int rc;
 
-               ap = host_set->ports[i];
-
                /* init sata_spd_limit to the current value */
                if (sata_scr_read(ap, SCR_CONTROL, &scontrol) == 0) {
                        int spd = (scontrol >> 4) & 0xf;
@@ -5454,7 +5554,7 @@ int ata_device_add(const struct ata_probe_ent *ent)
                }
                ap->sata_spd_limit = ap->hw_sata_spd_limit;
 
-               rc = scsi_add_host(ap->host, dev);
+               rc = scsi_add_host(ap->scsi_host, dev);
                if (rc) {
                        ata_port_printk(ap, KERN_ERR, "scsi_add_host failed\n");
                        /* FIXME: do something useful here */
@@ -5502,27 +5602,29 @@ int ata_device_add(const struct ata_probe_ent *ent)
 
        /* probes are done, now scan each port's disk(s) */
        DPRINTK("host probe begin\n");
-       for (i = 0; i < count; i++) {
-               struct ata_port *ap = host_set->ports[i];
+       for (i = 0; i < host->n_ports; i++) {
+               struct ata_port *ap = host->ports[i];
 
                ata_scsi_scan_host(ap);
        }
 
-       dev_set_drvdata(dev, host_set);
+       dev_set_drvdata(dev, host);
 
        VPRINTK("EXIT, returning %u\n", ent->n_ports);
        return ent->n_ports; /* success */
 
+err_out_free_irq:
+       free_irq(ent->irq, host);
 err_out:
-       for (i = 0; i < count; i++) {
-               struct ata_port *ap = host_set->ports[i];
+       for (i = 0; i < host->n_ports; i++) {
+               struct ata_port *ap = host->ports[i];
                if (ap) {
                        ap->ops->port_stop(ap);
-                       scsi_host_put(ap->host);
+                       scsi_host_put(ap->scsi_host);
                }
        }
-err_free_ret:
-       kfree(host_set);
+
+       kfree(host);
        VPRINTK("EXIT, returning 0\n");
        return 0;
 }
@@ -5582,12 +5684,12 @@ void ata_port_detach(struct ata_port *ap)
 
  skip_eh:
        /* remove the associated SCSI host */
-       scsi_remove_host(ap->host);
+       scsi_remove_host(ap->scsi_host);
 }
 
 /**
- *     ata_host_set_remove - PCI layer callback for device removal
- *     @host_set: ATA host set that was removed
+ *     ata_host_remove - PCI layer callback for device removal
+ *     @host: ATA host set that was removed
  *
  *     Unregister all objects associated with this host set. Free those
  *     objects.
@@ -5596,36 +5698,39 @@ void ata_port_detach(struct ata_port *ap)
  *     Inherited from calling layer (may sleep).
  */
 
-void ata_host_set_remove(struct ata_host_set *host_set)
+void ata_host_remove(struct ata_host *host)
 {
        unsigned int i;
 
-       for (i = 0; i < host_set->n_ports; i++)
-               ata_port_detach(host_set->ports[i]);
+       for (i = 0; i < host->n_ports; i++)
+               ata_port_detach(host->ports[i]);
 
-       free_irq(host_set->irq, host_set);
+       free_irq(host->irq, host);
+       if (host->irq2)
+               free_irq(host->irq2, host);
 
-       for (i = 0; i < host_set->n_ports; i++) {
-               struct ata_port *ap = host_set->ports[i];
+       for (i = 0; i < host->n_ports; i++) {
+               struct ata_port *ap = host->ports[i];
 
-               ata_scsi_release(ap->host);
+               ata_scsi_release(ap->scsi_host);
 
                if ((ap->flags & ATA_FLAG_NO_LEGACY) == 0) {
                        struct ata_ioports *ioaddr = &ap->ioaddr;
 
-                       if (ioaddr->cmd_addr == 0x1f0)
-                               release_region(0x1f0, 8);
-                       else if (ioaddr->cmd_addr == 0x170)
-                               release_region(0x170, 8);
+                       /* FIXME: Add -ac IDE pci mods to remove these special cases */
+                       if (ioaddr->cmd_addr == ATA_PRIMARY_CMD)
+                               release_region(ATA_PRIMARY_CMD, 8);
+                       else if (ioaddr->cmd_addr == ATA_SECONDARY_CMD)
+                               release_region(ATA_SECONDARY_CMD, 8);
                }
 
-               scsi_host_put(ap->host);
+               scsi_host_put(ap->scsi_host);
        }
 
-       if (host_set->ops->host_stop)
-               host_set->ops->host_stop(host_set);
+       if (host->ops->host_stop)
+               host->ops->host_stop(host);
 
-       kfree(host_set);
+       kfree(host);
 }
 
 /**
@@ -5642,9 +5747,9 @@ void ata_host_set_remove(struct ata_host_set *host_set)
  *     One.
  */
 
-int ata_scsi_release(struct Scsi_Host *host)
+int ata_scsi_release(struct Scsi_Host *shost)
 {
-       struct ata_port *ap = ata_shost_to_port(host);
+       struct ata_port *ap = ata_shost_to_port(shost);
 
        DPRINTK("ENTER\n");
 
@@ -5655,6 +5760,31 @@ int ata_scsi_release(struct Scsi_Host *host)
        return 1;
 }
 
+struct ata_probe_ent *
+ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port)
+{
+       struct ata_probe_ent *probe_ent;
+
+       probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
+       if (!probe_ent) {
+               printk(KERN_ERR DRV_NAME "(%s): out of memory\n",
+                      kobject_name(&(dev->kobj)));
+               return NULL;
+       }
+
+       INIT_LIST_HEAD(&probe_ent->node);
+       probe_ent->dev = dev;
+
+       probe_ent->sht = port->sht;
+       probe_ent->port_flags = port->flags;
+       probe_ent->pio_mask = port->pio_mask;
+       probe_ent->mwdma_mask = port->mwdma_mask;
+       probe_ent->udma_mask = port->udma_mask;
+       probe_ent->port_ops = port->port_ops;
+
+       return probe_ent;
+}
+
 /**
  *     ata_std_ports - initialize ioaddr with standard port offsets.
  *     @ioaddr: IO address structure to be initialized
@@ -5684,11 +5814,11 @@ void ata_std_ports(struct ata_ioports *ioaddr)
 
 #ifdef CONFIG_PCI
 
-void ata_pci_host_stop (struct ata_host_set *host_set)
+void ata_pci_host_stop (struct ata_host *host)
 {
-       struct pci_dev *pdev = to_pci_dev(host_set->dev);
+       struct pci_dev *pdev = to_pci_dev(host->dev);
 
-       pci_iounmap(pdev, host_set->mmio_base);
+       pci_iounmap(pdev, host->mmio_base);
 }
 
 /**
@@ -5708,12 +5838,9 @@ void ata_pci_host_stop (struct ata_host_set *host_set)
 void ata_pci_remove_one (struct pci_dev *pdev)
 {
        struct device *dev = pci_dev_to_dev(pdev);
-       struct ata_host_set *host_set = dev_get_drvdata(dev);
-       struct ata_host_set *host_set2 = host_set->next;
+       struct ata_host *host = dev_get_drvdata(dev);
 
-       ata_host_set_remove(host_set);
-       if (host_set2)
-               ata_host_set_remove(host_set2);
+       ata_host_remove(host);
 
        pci_release_regions(pdev);
        pci_disable_device(pdev);
@@ -5754,11 +5881,11 @@ int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits)
        return (tmp == bits->val) ? 1 : 0;
 }
 
-void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t state)
+void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg)
 {
        pci_save_state(pdev);
 
-       if (state.event == PM_EVENT_SUSPEND) {
+       if (mesg.event == PM_EVENT_SUSPEND) {
                pci_disable_device(pdev);
                pci_set_power_state(pdev, PCI_D3hot);
        }
@@ -5772,37 +5899,26 @@ void ata_pci_device_do_resume(struct pci_dev *pdev)
        pci_set_master(pdev);
 }
 
-int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state)
+int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
 {
-       struct ata_host_set *host_set = dev_get_drvdata(&pdev->dev);
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
        int rc = 0;
 
-       rc = ata_host_set_suspend(host_set, state);
+       rc = ata_host_suspend(host, mesg);
        if (rc)
                return rc;
 
-       if (host_set->next) {
-               rc = ata_host_set_suspend(host_set->next, state);
-               if (rc) {
-                       ata_host_set_resume(host_set);
-                       return rc;
-               }
-       }
-
-       ata_pci_device_do_suspend(pdev, state);
+       ata_pci_device_do_suspend(pdev, mesg);
 
        return 0;
 }
 
 int ata_pci_device_resume(struct pci_dev *pdev)
 {
-       struct ata_host_set *host_set = dev_get_drvdata(&pdev->dev);
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
 
        ata_pci_device_do_resume(pdev);
-       ata_host_set_resume(host_set);
-       if (host_set->next)
-               ata_host_set_resume(host_set->next);
-
+       ata_host_resume(host);
        return 0;
 }
 #endif /* CONFIG_PCI */
@@ -5901,6 +6017,39 @@ u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
        return tmp;
 }
 
+/*
+ * Dummy port_ops
+ */
+static void ata_dummy_noret(struct ata_port *ap)       { }
+static int ata_dummy_ret0(struct ata_port *ap)         { return 0; }
+static void ata_dummy_qc_noret(struct ata_queued_cmd *qc) { }
+
+static u8 ata_dummy_check_status(struct ata_port *ap)
+{
+       return ATA_DRDY;
+}
+
+static unsigned int ata_dummy_qc_issue(struct ata_queued_cmd *qc)
+{
+       return AC_ERR_SYSTEM;
+}
+
+const struct ata_port_operations ata_dummy_port_ops = {
+       .port_disable           = ata_port_disable,
+       .check_status           = ata_dummy_check_status,
+       .check_altstatus        = ata_dummy_check_status,
+       .dev_select             = ata_noop_dev_select,
+       .qc_prep                = ata_noop_qc_prep,
+       .qc_issue               = ata_dummy_qc_issue,
+       .freeze                 = ata_dummy_noret,
+       .thaw                   = ata_dummy_noret,
+       .error_handler          = ata_dummy_noret,
+       .post_internal_cmd      = ata_dummy_qc_noret,
+       .irq_clear              = ata_dummy_noret,
+       .port_start             = ata_dummy_ret0,
+       .port_stop              = ata_dummy_noret,
+};
+
 /*
  * libata is essentially a library of internal helper functions for
  * low-level ATA host controller drivers.  As such, the API/ABI is
@@ -5911,11 +6060,13 @@ u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
 EXPORT_SYMBOL_GPL(sata_deb_timing_normal);
 EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug);
 EXPORT_SYMBOL_GPL(sata_deb_timing_long);
+EXPORT_SYMBOL_GPL(ata_dummy_port_ops);
 EXPORT_SYMBOL_GPL(ata_std_bios_param);
 EXPORT_SYMBOL_GPL(ata_std_ports);
+EXPORT_SYMBOL_GPL(ata_host_init);
 EXPORT_SYMBOL_GPL(ata_device_add);
 EXPORT_SYMBOL_GPL(ata_port_detach);
-EXPORT_SYMBOL_GPL(ata_host_set_remove);
+EXPORT_SYMBOL_GPL(ata_host_remove);
 EXPORT_SYMBOL_GPL(ata_sg_init);
 EXPORT_SYMBOL_GPL(ata_sg_init_one);
 EXPORT_SYMBOL_GPL(ata_hsm_move);
@@ -5982,8 +6133,8 @@ EXPORT_SYMBOL_GPL(sata_scr_write);
 EXPORT_SYMBOL_GPL(sata_scr_write_flush);
 EXPORT_SYMBOL_GPL(ata_port_online);
 EXPORT_SYMBOL_GPL(ata_port_offline);
-EXPORT_SYMBOL_GPL(ata_host_set_suspend);
-EXPORT_SYMBOL_GPL(ata_host_set_resume);
+EXPORT_SYMBOL_GPL(ata_host_suspend);
+EXPORT_SYMBOL_GPL(ata_host_resume);
 EXPORT_SYMBOL_GPL(ata_id_string);
 EXPORT_SYMBOL_GPL(ata_id_c_string);
 EXPORT_SYMBOL_GPL(ata_scsi_simulate);
similarity index 99%
rename from drivers/scsi/libata-eh.c
rename to drivers/ata/libata-eh.c
index 2c34af99627d3a78caefe8fcea233f1539c3afb1..3fa80f09f2ae8edf283b36e4553a7c9b119ea1e8 100644 (file)
@@ -38,7 +38,7 @@
 #include <scsi/scsi_eh.h>
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_cmnd.h>
-#include "scsi_transport_api.h"
+#include "../scsi/scsi_transport_api.h"
 
 #include <linux/libata.h>
 
@@ -199,7 +199,7 @@ void ata_scsi_error(struct Scsi_Host *host)
        /* synchronize with port task */
        ata_port_flush_task(ap);
 
-       /* synchronize with host_set lock and sort out timeouts */
+       /* synchronize with host lock and sort out timeouts */
 
        /* For new EH, all qcs are finished in one of three ways -
         * normal completion, error completion, and SCSI timeout.
@@ -376,7 +376,7 @@ void ata_port_wait_eh(struct ata_port *ap)
        spin_unlock_irqrestore(ap->lock, flags);
 
        /* make sure SCSI EH is complete */
-       if (scsi_host_in_recovery(ap->host)) {
+       if (scsi_host_in_recovery(ap->scsi_host)) {
                msleep(10);
                goto retry;
        }
@@ -485,7 +485,7 @@ void ata_eng_timeout(struct ata_port *ap)
  *     other commands are drained.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 void ata_qc_schedule_eh(struct ata_queued_cmd *qc)
 {
@@ -512,14 +512,14 @@ void ata_qc_schedule_eh(struct ata_queued_cmd *qc)
  *     all commands are drained.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 void ata_port_schedule_eh(struct ata_port *ap)
 {
        WARN_ON(!ap->ops->error_handler);
 
        ap->pflags |= ATA_PFLAG_EH_PENDING;
-       scsi_schedule_eh(ap->host);
+       scsi_schedule_eh(ap->scsi_host);
 
        DPRINTK("port EH scheduled\n");
 }
@@ -531,7 +531,7 @@ void ata_port_schedule_eh(struct ata_port *ap)
  *     Abort all active qc's of @ap and schedule EH.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     Number of aborted qc's.
@@ -574,7 +574,7 @@ int ata_port_abort(struct ata_port *ap)
  *     is frozen.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 static void __ata_port_freeze(struct ata_port *ap)
 {
@@ -595,7 +595,7 @@ static void __ata_port_freeze(struct ata_port *ap)
  *     Abort and freeze @ap.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     Number of aborted commands.
similarity index 94%
rename from drivers/scsi/libata-scsi.c
rename to drivers/ata/libata-scsi.c
index e92c31d698ff6c983b7a817afe190d10a7f1de6c..3986ec8741b4157ba46e1415f0487cb05b4fb8d0 100644 (file)
@@ -321,7 +321,7 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
  *     current command.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     Command allocated, or %NULL if none available.
@@ -400,7 +400,7 @@ void ata_dump_status(unsigned id, struct ata_taskfile *tf)
 /**
  *     ata_scsi_device_suspend - suspend ATA device associated with sdev
  *     @sdev: the SCSI device to suspend
- *     @state: target power management state
+ *     @mesg: target power management message
  *
  *     Request suspend EH action on the ATA device associated with
  *     @sdev and wait for the operation to complete.
@@ -411,7 +411,7 @@ void ata_dump_status(unsigned id, struct ata_taskfile *tf)
  *     RETURNS:
  *     0 on success, -errno otherwise.
  */
-int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t state)
+int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t mesg)
 {
        struct ata_port *ap = ata_shost_to_port(sdev->host);
        struct ata_device *dev = ata_scsi_find_dev(ap, sdev);
@@ -438,7 +438,7 @@ int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t state)
 
        /* request suspend */
        action = ATA_EH_SUSPEND;
-       if (state.event != PM_EVENT_SUSPEND)
+       if (mesg.event != PM_EVENT_SUSPEND)
                action |= ATA_EH_PM_FREEZE;
        ap->eh_info.dev_action[dev->devno] |= action;
        ap->eh_info.flags |= ATA_EHI_QUIET;
@@ -463,7 +463,7 @@ int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t state)
        spin_unlock_irqrestore(ap->lock, flags);
  out:
        if (rc == 0)
-               sdev->sdev_gendev.power.power_state = state;
+               sdev->sdev_gendev.power.power_state = mesg;
        return rc;
 }
 
@@ -537,7 +537,7 @@ int ata_scsi_device_resume(struct scsi_device *sdev)
  *     format sense blocks.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
                        u8 *ascq, int verbose)
@@ -649,7 +649,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
  *     block. Clear sense key, ASC & ASCQ if there is no error.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc)
 {
@@ -918,7 +918,7 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth)
  *     [See SAT revision 5 at www.t10.org]
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     Zero on success, non-zero on error.
@@ -986,7 +986,7 @@ invalid_fld:
  *     FLUSH CACHE EXT.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     Zero on success, non-zero on error.
@@ -1109,7 +1109,7 @@ static void scsi_16_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
  *     Converts SCSI VERIFY command to an ATA READ VERIFY command.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     Zero on success, non-zero on error.
@@ -1233,7 +1233,7 @@ nothing_to_do:
  *     %WRITE_16 are currently supported.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     Zero on success, non-zero on error.
@@ -1467,7 +1467,7 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
  *     issued to @dev.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     1 if deferring is needed, 0 otherwise.
@@ -1510,7 +1510,7 @@ static int ata_scmd_need_defer(struct ata_device *dev, int is_io)
  *     termination.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     0 on success, SCSI_ML_QUEUE_DEVICE_BUSY if the command
@@ -1589,7 +1589,7 @@ defer:
  *     Maps buffer contained within SCSI command @cmd.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     Length of response buffer.
@@ -1623,7 +1623,7 @@ static unsigned int ata_scsi_rbuf_get(struct scsi_cmnd *cmd, u8 **buf_out)
  *     Unmaps response buffer contained within @cmd.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, u8 *buf)
@@ -1649,7 +1649,7 @@ static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, u8 *buf)
  *     and sense buffer are assumed to be set).
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
@@ -1680,7 +1680,7 @@ void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
  *     with non-VPD INQUIRY command output.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
@@ -1736,7 +1736,7 @@ unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
  *     Returns list of inquiry VPD pages available.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf,
@@ -1764,7 +1764,7 @@ unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf,
  *     Returns ATA device serial number.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
@@ -1797,7 +1797,7 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
  *        name ("ATA     "), model and serial numbers.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
@@ -1849,7 +1849,7 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
  *     that the caller should successfully complete this SCSI command.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 unsigned int ata_scsiop_noop(struct ata_scsi_args *args, u8 *rbuf,
@@ -1990,7 +1990,7 @@ static int ata_dev_supports_fua(u16 *id)
  *     descriptor for other device types.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf,
@@ -2129,7 +2129,7 @@ saving_not_supp:
  *     Simulate READ CAPACITY commands.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf,
@@ -2204,7 +2204,7 @@ unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf,
  *     Simulate REPORT LUNS command.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 unsigned int ata_scsiop_report_luns(struct ata_scsi_args *args, u8 *rbuf,
@@ -2256,7 +2256,7 @@ void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq)
  *     and the specified additional sense codes.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8 asc, u8 ascq)
@@ -2421,7 +2421,7 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
  *     @scsicmd: SCSI CDB associated with this PACKET command
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     Zero on success, non-zero on failure.
@@ -2500,7 +2500,7 @@ static struct ata_device * __ata_scsi_find_dev(struct ata_port *ap,
  *     Determine if commands should be sent to the specified device.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     0 if commands are not allowed / 1 if commands are allowed
@@ -2534,7 +2534,7 @@ static int ata_scsi_dev_enabled(struct ata_device *dev)
  *     SCSI command to be sent.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     Associated ATA device, or %NULL if not found.
@@ -2808,7 +2808,7 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *cmd,
  *     ATA and ATAPI devices appearing as SCSI devices.
  *
  *     LOCKING:
- *     Releases scsi-layer-held lock, and obtains host_set lock.
+ *     Releases scsi-layer-held lock, and obtains host lock.
  *
  *     RETURNS:
  *     Return value from __ata_scsi_queuecmd() if @cmd can be queued,
@@ -2852,7 +2852,7 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
  *     that can be handled internally.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
@@ -2944,7 +2944,7 @@ void ata_scsi_scan_host(struct ata_port *ap)
                if (!ata_dev_enabled(dev) || dev->sdev)
                        continue;
 
-               sdev = __scsi_add_device(ap->host, 0, i, 0, NULL);
+               sdev = __scsi_add_device(ap->scsi_host, 0, i, 0, NULL);
                if (!IS_ERR(sdev)) {
                        dev->sdev = sdev;
                        scsi_device_put(sdev);
@@ -2958,11 +2958,11 @@ void ata_scsi_scan_host(struct ata_port *ap)
  *
  *     This function is called from ata_eh_hotplug() and responsible
  *     for taking the SCSI device attached to @dev offline.  This
- *     function is called with host_set lock which protects dev->sdev
+ *     function is called with host lock which protects dev->sdev
  *     against clearing.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  *
  *     RETURNS:
  *     1 if attached SCSI device exists, 0 otherwise.
@@ -2998,16 +2998,16 @@ static void ata_scsi_remove_dev(struct ata_device *dev)
         * be removed if there is __scsi_device_get() interface which
         * increments reference counts regardless of device state.
         */
-       mutex_lock(&ap->host->scan_mutex);
+       mutex_lock(&ap->scsi_host->scan_mutex);
        spin_lock_irqsave(ap->lock, flags);
 
-       /* clearing dev->sdev is protected by host_set lock */
+       /* clearing dev->sdev is protected by host lock */
        sdev = dev->sdev;
        dev->sdev = NULL;
 
        if (sdev) {
                /* If user initiated unplug races with us, sdev can go
-                * away underneath us after the host_set lock and
+                * away underneath us after the host lock and
                 * scan_mutex are released.  Hold onto it.
                 */
                if (scsi_device_get(sdev) == 0) {
@@ -3024,7 +3024,7 @@ static void ata_scsi_remove_dev(struct ata_device *dev)
        }
 
        spin_unlock_irqrestore(ap->lock, flags);
-       mutex_unlock(&ap->host->scan_mutex);
+       mutex_unlock(&ap->scsi_host->scan_mutex);
 
        if (sdev) {
                ata_dev_printk(dev, KERN_INFO, "detaching (SCSI %s)\n",
@@ -3171,3 +3171,152 @@ void ata_scsi_dev_rescan(void *data)
                        scsi_rescan_device(&(dev->sdev->sdev_gendev));
        }
 }
+
+/**
+ *     ata_sas_port_alloc - Allocate port for a SAS attached SATA device
+ *     @pdev: PCI device that the scsi device is attached to
+ *     @port_info: Information from low-level host driver
+ *     @shost: SCSI host that the scsi device is attached to
+ *
+ *     LOCKING:
+ *     PCI/etc. bus probe sem.
+ *
+ *     RETURNS:
+ *     ata_port pointer on success / NULL on failure.
+ */
+
+struct ata_port *ata_sas_port_alloc(struct ata_host *host,
+                                   struct ata_port_info *port_info,
+                                   struct Scsi_Host *shost)
+{
+       struct ata_port *ap = kzalloc(sizeof(*ap), GFP_KERNEL);
+       struct ata_probe_ent *ent;
+
+       if (!ap)
+               return NULL;
+
+       ent = ata_probe_ent_alloc(host->dev, port_info);
+       if (!ent) {
+               kfree(ap);
+               return NULL;
+       }
+
+       ata_port_init(ap, host, ent, 0);
+       ap->lock = shost->host_lock;
+       kfree(ent);
+       return ap;
+}
+EXPORT_SYMBOL_GPL(ata_sas_port_alloc);
+
+/**
+ *     ata_sas_port_start - Set port up for dma.
+ *     @ap: Port to initialize
+ *
+ *     Called just after data structures for each port are
+ *     initialized.  Allocates DMA pad.
+ *
+ *     May be used as the port_start() entry in ata_port_operations.
+ *
+ *     LOCKING:
+ *     Inherited from caller.
+ */
+int ata_sas_port_start(struct ata_port *ap)
+{
+       return ata_pad_alloc(ap, ap->dev);
+}
+EXPORT_SYMBOL_GPL(ata_sas_port_start);
+
+/**
+ *     ata_port_stop - Undo ata_sas_port_start()
+ *     @ap: Port to shut down
+ *
+ *     Frees the DMA pad.
+ *
+ *     May be used as the port_stop() entry in ata_port_operations.
+ *
+ *     LOCKING:
+ *     Inherited from caller.
+ */
+
+void ata_sas_port_stop(struct ata_port *ap)
+{
+       ata_pad_free(ap, ap->dev);
+}
+EXPORT_SYMBOL_GPL(ata_sas_port_stop);
+
+/**
+ *     ata_sas_port_init - Initialize a SATA device
+ *     @ap: SATA port to initialize
+ *
+ *     LOCKING:
+ *     PCI/etc. bus probe sem.
+ *
+ *     RETURNS:
+ *     Zero on success, non-zero on error.
+ */
+
+int ata_sas_port_init(struct ata_port *ap)
+{
+       int rc = ap->ops->port_start(ap);
+
+       if (!rc)
+               rc = ata_bus_probe(ap);
+
+       return rc;
+}
+EXPORT_SYMBOL_GPL(ata_sas_port_init);
+
+/**
+ *     ata_sas_port_destroy - Destroy a SATA port allocated by ata_sas_port_alloc
+ *     @ap: SATA port to destroy
+ *
+ */
+
+void ata_sas_port_destroy(struct ata_port *ap)
+{
+       ap->ops->port_stop(ap);
+       kfree(ap);
+}
+EXPORT_SYMBOL_GPL(ata_sas_port_destroy);
+
+/**
+ *     ata_sas_slave_configure - Default slave_config routine for libata devices
+ *     @sdev: SCSI device to configure
+ *     @ap: ATA port to which SCSI device is attached
+ *
+ *     RETURNS:
+ *     Zero.
+ */
+
+int ata_sas_slave_configure(struct scsi_device *sdev, struct ata_port *ap)
+{
+       ata_scsi_sdev_config(sdev);
+       ata_scsi_dev_config(sdev, ap->device);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(ata_sas_slave_configure);
+
+/**
+ *     ata_sas_queuecmd - Issue SCSI cdb to libata-managed device
+ *     @cmd: SCSI command to be sent
+ *     @done: Completion function, called when command is complete
+ *     @ap:    ATA port to which the command is being sent
+ *
+ *     RETURNS:
+ *     Zero.
+ */
+
+int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
+                    struct ata_port *ap)
+{
+       ata_scsi_dump_cdb(ap, cmd);
+
+       if (likely(ata_scsi_dev_enabled(ap->device)))
+               __ata_scsi_queuecmd(cmd, done, ap->device);
+       else {
+               cmd->result = (DID_BAD_TARGET << 16);
+               done(cmd);
+       }
+       return 0;
+}
+EXPORT_SYMBOL_GPL(ata_sas_queuecmd);
similarity index 89%
rename from drivers/scsi/libata-bmdma.c
rename to drivers/ata/libata-sff.c
index 9ce221f25954426af69ce124bb11a4beaf0feff2..688bb55e197a786b82d40f63b2695e68afd75fb8 100644 (file)
@@ -193,7 +193,7 @@ void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
  *     synchronization with interrupt handler / other threads.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile *tf)
@@ -216,7 +216,7 @@ static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile
  *     FIXME: missing write posting for 400nS delay enforcement
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 static void ata_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
@@ -237,7 +237,7 @@ static void ata_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile
  *     synchronization with interrupt handler / other threads.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
 {
@@ -422,7 +422,7 @@ u8 ata_altstatus(struct ata_port *ap)
  *     @qc: Info associated with this ATA transaction.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 static void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc)
@@ -452,7 +452,7 @@ static void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc)
  *     @qc: Info associated with this ATA transaction.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 static void ata_bmdma_start_mmio (struct ata_queued_cmd *qc)
@@ -483,7 +483,7 @@ static void ata_bmdma_start_mmio (struct ata_queued_cmd *qc)
  *     @qc: Info associated with this ATA transaction.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 static void ata_bmdma_setup_pio (struct ata_queued_cmd *qc)
@@ -511,7 +511,7 @@ static void ata_bmdma_setup_pio (struct ata_queued_cmd *qc)
  *     @qc: Info associated with this ATA transaction.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 static void ata_bmdma_start_pio (struct ata_queued_cmd *qc)
@@ -535,7 +535,7 @@ static void ata_bmdma_start_pio (struct ata_queued_cmd *qc)
  *     May be used as the bmdma_start() entry in ata_port_operations.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 void ata_bmdma_start(struct ata_queued_cmd *qc)
 {
@@ -557,7 +557,7 @@ void ata_bmdma_start(struct ata_queued_cmd *qc)
  *     May be used as the bmdma_setup() entry in ata_port_operations.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 void ata_bmdma_setup(struct ata_queued_cmd *qc)
 {
@@ -577,7 +577,7 @@ void ata_bmdma_setup(struct ata_queued_cmd *qc)
  *     May be used as the irq_clear() entry in ata_port_operations.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 void ata_bmdma_irq_clear(struct ata_port *ap)
@@ -605,7 +605,7 @@ void ata_bmdma_irq_clear(struct ata_port *ap)
  *     May be used as the bmdma_status() entry in ata_port_operations.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 u8 ata_bmdma_status(struct ata_port *ap)
@@ -629,7 +629,7 @@ u8 ata_bmdma_status(struct ata_port *ap)
  *     May be used as the bmdma_stop() entry in ata_port_operations.
  *
  *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
+ *     spin_lock_irqsave(host lock)
  */
 
 void ata_bmdma_stop(struct ata_queued_cmd *qc)
@@ -797,32 +797,6 @@ void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc)
 }
 
 #ifdef CONFIG_PCI
-static struct ata_probe_ent *
-ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port)
-{
-       struct ata_probe_ent *probe_ent;
-
-       probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
-       if (!probe_ent) {
-               printk(KERN_ERR DRV_NAME "(%s): out of memory\n",
-                      kobject_name(&(dev->kobj)));
-               return NULL;
-       }
-
-       INIT_LIST_HEAD(&probe_ent->node);
-       probe_ent->dev = dev;
-
-       probe_ent->sht = port->sht;
-       probe_ent->host_flags = port->host_flags;
-       probe_ent->pio_mask = port->pio_mask;
-       probe_ent->mwdma_mask = port->mwdma_mask;
-       probe_ent->udma_mask = port->udma_mask;
-       probe_ent->port_ops = port->port_ops;
-
-       return probe_ent;
-}
-
-
 /**
  *     ata_pci_init_native_mode - Initialize native-mode driver
  *     @pdev:  pci device to be initialized
@@ -864,7 +838,7 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
                bmdma = pci_resource_start(pdev, 4);
                if (bmdma) {
                        if (inb(bmdma + 2) & 0x80)
-                               probe_ent->host_set_flags |= ATA_HOST_SIMPLEX;
+                               probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
                        probe_ent->port[p].bmdma_addr = bmdma;
                }
                ata_std_ports(&probe_ent->port[p]);
@@ -880,10 +854,11 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
                if (bmdma) {
                        bmdma += 8;
                        if(inb(bmdma + 2) & 0x80)
-                       probe_ent->host_set_flags |= ATA_HOST_SIMPLEX;
+                               probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
                        probe_ent->port[p].bmdma_addr = bmdma;
                }
                ata_std_ports(&probe_ent->port[p]);
+               probe_ent->pinfo2 = port[1];
                p++;
        }
 
@@ -893,44 +868,49 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
 
 
 static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
-                               struct ata_port_info *port, int port_num)
+                               struct ata_port_info **port, int port_mask)
 {
        struct ata_probe_ent *probe_ent;
-       unsigned long bmdma;
+       unsigned long bmdma = pci_resource_start(pdev, 4);
 
-       probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port);
+       probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]);
        if (!probe_ent)
                return NULL;
 
-       probe_ent->legacy_mode = 1;
-       probe_ent->n_ports = 1;
-       probe_ent->hard_port_no = port_num;
-       probe_ent->private_data = port->private_data;
-
-       switch(port_num)
-       {
-               case 0:
-                       probe_ent->irq = 14;
-                       probe_ent->port[0].cmd_addr = 0x1f0;
-                       probe_ent->port[0].altstatus_addr =
-                       probe_ent->port[0].ctl_addr = 0x3f6;
-                       break;
-               case 1:
-                       probe_ent->irq = 15;
-                       probe_ent->port[0].cmd_addr = 0x170;
-                       probe_ent->port[0].altstatus_addr =
-                       probe_ent->port[0].ctl_addr = 0x376;
-                       break;
-       }
+       probe_ent->n_ports = 2;
+       probe_ent->private_data = port[0]->private_data;
 
-       bmdma = pci_resource_start(pdev, 4);
-       if (bmdma != 0) {
-               bmdma += 8 * port_num;
-               probe_ent->port[0].bmdma_addr = bmdma;
-               if (inb(bmdma + 2) & 0x80)
-                       probe_ent->host_set_flags |= ATA_HOST_SIMPLEX;
-       }
-       ata_std_ports(&probe_ent->port[0]);
+       if (port_mask & ATA_PORT_PRIMARY) {
+               probe_ent->irq = 14;
+               probe_ent->port[0].cmd_addr = ATA_PRIMARY_CMD;
+               probe_ent->port[0].altstatus_addr =
+               probe_ent->port[0].ctl_addr = ATA_PRIMARY_CTL;
+               if (bmdma) {
+                       probe_ent->port[0].bmdma_addr = bmdma;
+                       if (inb(bmdma + 2) & 0x80)
+                               probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
+               }
+               ata_std_ports(&probe_ent->port[0]);
+       } else
+               probe_ent->dummy_port_mask |= ATA_PORT_PRIMARY;
+
+       if (port_mask & ATA_PORT_SECONDARY) {
+               if (probe_ent->irq)
+                       probe_ent->irq2 = 15;
+               else
+                       probe_ent->irq = 15;
+               probe_ent->port[1].cmd_addr = ATA_SECONDARY_CMD;
+               probe_ent->port[1].altstatus_addr =
+               probe_ent->port[1].ctl_addr = ATA_SECONDARY_CTL;
+               if (bmdma) {
+                       probe_ent->port[1].bmdma_addr = bmdma + 8;
+                       if (inb(bmdma + 10) & 0x80)
+                               probe_ent->_host_flags |= ATA_HOST_SIMPLEX;
+               }
+               ata_std_ports(&probe_ent->port[1]);
+               probe_ent->pinfo2 = port[1];