Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (100 commits)
ide: move hwif_register() call out of ide_probe_port()
ide: factor out code for tuning devices from ide_probe_port()
ide: move handling of I/O resources out of ide_probe_port()
ide: make probe_hwif() return an error value
ide: use ide_remove_port_from_hwgroup in init_irq()
ide: prepare init_irq() for using ide_remove_port_from_hwgroup()
ide: factor out code removing port from hwgroup from ide_unregister()
ide: I/O resources are released too early in ide_unregister()
ide: cleanup ide_system_bus_speed()
ide: remove needless zeroing of hwgroup fields from init_irq()
ide: remove unused ide_hwgroup_t fields
ide_platform: remove struct hwif_prop
ide: remove hwif->present manipulations from hwif_init()
ide: move wait_hwif_ready() documentation in the right place
ide: fix handling of busy I/O resources in probe_hwif()
<linux/hdsmart.h> is not used by kernel code
ide: don't include <linux/hdsmart.h>
ide-floppy: cleanup header
ide: update/add my Copyrights
ide: delete filenames/versions from comments
...

+2602 -3641
+268
Documentation/ide/ChangeLog.ide-cd.1994-2004
···
··· 1 + /* 2 + * 1.00 Oct 31, 1994 -- Initial version. 3 + * 1.01 Nov 2, 1994 -- Fixed problem with starting request in 4 + * cdrom_check_status. 5 + * 1.03 Nov 25, 1994 -- leaving unmask_intr[] as a user-setting (as for disks) 6 + * (from mlord) -- minor changes to cdrom_setup() 7 + * -- renamed ide_dev_s to ide_drive_t, enable irq on command 8 + * 2.00 Nov 27, 1994 -- Generalize packet command interface; 9 + * add audio ioctls. 10 + * 2.01 Dec 3, 1994 -- Rework packet command interface to handle devices 11 + * which send an interrupt when ready for a command. 12 + * 2.02 Dec 11, 1994 -- Cache the TOC in the driver. 13 + * Don't use SCMD_PLAYAUDIO_TI; it's not included 14 + * in the current version of ATAPI. 15 + * Try to use LBA instead of track or MSF addressing 16 + * when possible. 17 + * Don't wait for READY_STAT. 18 + * 2.03 Jan 10, 1995 -- Rewrite block read routines to handle block sizes 19 + * other than 2k and to move multiple sectors in a 20 + * single transaction. 21 + * 2.04 Apr 21, 1995 -- Add work-around for Creative Labs CD220E drives. 22 + * Thanks to Nick Saw <cwsaw@pts7.pts.mot.com> for 23 + * help in figuring this out. Ditto for Acer and 24 + * Aztech drives, which seem to have the same problem. 25 + * 2.04b May 30, 1995 -- Fix to match changes in ide.c version 3.16 -ml 26 + * 2.05 Jun 8, 1995 -- Don't attempt to retry after an illegal request 27 + * or data protect error. 28 + * Use HWIF and DEV_HWIF macros as in ide.c. 29 + * Always try to do a request_sense after 30 + * a failed command. 31 + * Include an option to give textual descriptions 32 + * of ATAPI errors. 33 + * Fix a bug in handling the sector cache which 34 + * showed up if the drive returned data in 512 byte 35 + * blocks (like Pioneer drives). Thanks to 36 + * Richard Hirst <srh@gpt.co.uk> for diagnosing this. 37 + * Properly supply the page number field in the 38 + * MODE_SELECT command. 39 + * PLAYAUDIO12 is broken on the Aztech; work around it. 40 + * 2.05x Aug 11, 1995 -- lots of data structure renaming/restructuring in ide.c 41 + * (my apologies to Scott, but now ide-cd.c is independent) 42 + * 3.00 Aug 22, 1995 -- Implement CDROMMULTISESSION ioctl. 43 + * Implement CDROMREADAUDIO ioctl (UNTESTED). 44 + * Use input_ide_data() and output_ide_data(). 45 + * Add door locking. 46 + * Fix usage count leak in cdrom_open, which happened 47 + * when a read-write mount was attempted. 48 + * Try to load the disk on open. 49 + * Implement CDROMEJECT_SW ioctl (off by default). 50 + * Read total cdrom capacity during open. 51 + * Rearrange logic in cdrom_decode_status. Issue 52 + * request sense commands for failed packet commands 53 + * from here instead of from cdrom_queue_packet_command. 54 + * Fix a race condition in retrieving error information. 55 + * Suppress printing normal unit attention errors and 56 + * some drive not ready errors. 57 + * Implement CDROMVOLREAD ioctl. 58 + * Implement CDROMREADMODE1/2 ioctls. 59 + * Fix race condition in setting up interrupt handlers 60 + * when the `serialize' option is used. 61 + * 3.01 Sep 2, 1995 -- Fix ordering of reenabling interrupts in 62 + * cdrom_queue_request. 63 + * Another try at using ide_[input,output]_data. 64 + * 3.02 Sep 16, 1995 -- Stick total disk capacity in partition table as well. 65 + * Make VERBOSE_IDE_CD_ERRORS dump failed command again. 66 + * Dump out more information for ILLEGAL REQUEST errs. 67 + * Fix handling of errors occurring before the 68 + * packet command is transferred. 69 + * Fix transfers with odd bytelengths. 70 + * 3.03 Oct 27, 1995 -- Some Creative drives have an id of just `CD'. 71 + * `DCI-2S10' drives are broken too. 72 + * 3.04 Nov 20, 1995 -- So are Vertos drives. 73 + * 3.05 Dec 1, 1995 -- Changes to go with overhaul of ide.c and ide-tape.c 74 + * 3.06 Dec 16, 1995 -- Add support needed for partitions. 75 + * More workarounds for Vertos bugs (based on patches 76 + * from Holger Dietze <dietze@aix520.informatik.uni-leipzig.de>). 77 + * Try to eliminate byteorder assumptions. 78 + * Use atapi_cdrom_subchnl struct definition. 79 + * Add STANDARD_ATAPI compilation option. 80 + * 3.07 Jan 29, 1996 -- More twiddling for broken drives: Sony 55D, 81 + * Vertos 300. 82 + * Add NO_DOOR_LOCKING configuration option. 83 + * Handle drive_cmd requests w/NULL args (for hdparm -t). 84 + * Work around sporadic Sony55e audio play problem. 85 + * 3.07a Feb 11, 1996 -- check drive->id for NULL before dereferencing, to fix 86 + * problem with "hde=cdrom" with no drive present. -ml 87 + * 3.08 Mar 6, 1996 -- More Vertos workarounds. 88 + * 3.09 Apr 5, 1996 -- Add CDROMCLOSETRAY ioctl. 89 + * Switch to using MSF addressing for audio commands. 90 + * Reformat to match kernel tabbing style. 91 + * Add CDROM_GET_UPC ioctl. 92 + * 3.10 Apr 10, 1996 -- Fix compilation error with STANDARD_ATAPI. 93 + * 3.11 Apr 29, 1996 -- Patch from Heiko Eißfeldt <heiko@colossus.escape.de> 94 + * to remove redundant verify_area calls. 95 + * 3.12 May 7, 1996 -- Rudimentary changer support. Based on patches 96 + * from Gerhard Zuber <zuber@berlin.snafu.de>. 97 + * Let open succeed even if there's no loaded disc. 98 + * 3.13 May 19, 1996 -- Fixes for changer code. 99 + * 3.14 May 29, 1996 -- Add work-around for Vertos 600. 100 + * (From Hennus Bergman <hennus@sky.ow.nl>.) 101 + * 3.15 July 2, 1996 -- Added support for Sanyo 3 CD changers 102 + * from Ben Galliart <bgallia@luc.edu> with 103 + * special help from Jeff Lightfoot 104 + * <jeffml@pobox.com> 105 + * 3.15a July 9, 1996 -- Improved Sanyo 3 CD changer identification 106 + * 3.16 Jul 28, 1996 -- Fix from Gadi to reduce kernel stack usage for ioctl. 107 + * 3.17 Sep 17, 1996 -- Tweak audio reads for some drives. 108 + * Start changing CDROMLOADFROMSLOT to CDROM_SELECT_DISC. 109 + * 3.18 Oct 31, 1996 -- Added module and DMA support. 110 + * 111 + * 4.00 Nov 5, 1996 -- New ide-cd maintainer, 112 + * Erik B. Andersen <andersee@debian.org> 113 + * -- Newer Creative drives don't always set the error 114 + * register correctly. Make sure we see media changes 115 + * regardless. 116 + * -- Integrate with generic cdrom driver. 117 + * -- CDROMGETSPINDOWN and CDROMSETSPINDOWN ioctls, based on 118 + * a patch from Ciro Cattuto <>. 119 + * -- Call set_device_ro. 120 + * -- Implement CDROMMECHANISMSTATUS and CDROMSLOTTABLE 121 + * ioctls, based on patch by Erik Andersen 122 + * -- Add some probes of drive capability during setup. 123 + * 124 + * 4.01 Nov 11, 1996 -- Split into ide-cd.c and ide-cd.h 125 + * -- Removed CDROMMECHANISMSTATUS and CDROMSLOTTABLE 126 + * ioctls in favor of a generalized approach 127 + * using the generic cdrom driver. 128 + * -- Fully integrated with the 2.1.X kernel. 129 + * -- Other stuff that I forgot (lots of changes) 130 + * 131 + * 4.02 Dec 01, 1996 -- Applied patch from Gadi Oxman <gadio@netvision.net.il> 132 + * to fix the drive door locking problems. 133 + * 134 + * 4.03 Dec 04, 1996 -- Added DSC overlap support. 135 + * 4.04 Dec 29, 1996 -- Added CDROMREADRAW ioclt based on patch 136 + * by Ales Makarov (xmakarov@sun.felk.cvut.cz) 137 + * 138 + * 4.05 Nov 20, 1997 -- Modified to print more drive info on init 139 + * Minor other changes 140 + * Fix errors on CDROMSTOP (If you have a "Dolphin", 141 + * you must define IHAVEADOLPHIN) 142 + * Added identifier so new Sanyo CD-changer works 143 + * Better detection if door locking isn't supported 144 + * 145 + * 4.06 Dec 17, 1997 -- fixed endless "tray open" messages -ml 146 + * 4.07 Dec 17, 1997 -- fallback to set pc->stat on "tray open" 147 + * 4.08 Dec 18, 1997 -- spew less noise when tray is empty 148 + * -- fix speed display for ACER 24X, 18X 149 + * 4.09 Jan 04, 1998 -- fix handling of the last block so we return 150 + * an end of file instead of an I/O error (Gadi) 151 + * 4.10 Jan 24, 1998 -- fixed a bug so now changers can change to a new 152 + * slot when there is no disc in the current slot. 153 + * -- Fixed a memory leak where info->changer_info was 154 + * malloc'ed but never free'd when closing the device. 155 + * -- Cleaned up the global namespace a bit by making more 156 + * functions static that should already have been. 157 + * 4.11 Mar 12, 1998 -- Added support for the CDROM_SELECT_SPEED ioctl 158 + * based on a patch for 2.0.33 by Jelle Foks 159 + * <jelle@scintilla.utwente.nl>, a patch for 2.0.33 160 + * by Toni Giorgino <toni@pcape2.pi.infn.it>, the SCSI 161 + * version, and my own efforts. -erik 162 + * -- Fixed a stupid bug which egcs was kind enough to 163 + * inform me of where "Illegal mode for this track" 164 + * was never returned due to a comparison on data 165 + * types of limited range. 166 + * 4.12 Mar 29, 1998 -- Fixed bug in CDROM_SELECT_SPEED so write speed is 167 + * now set ionly for CD-R and CD-RW drives. I had 168 + * removed this support because it produced errors. 169 + * It produced errors _only_ for non-writers. duh. 170 + * 4.13 May 05, 1998 -- Suppress useless "in progress of becoming ready" 171 + * messages, since this is not an error. 172 + * -- Change error messages to be const 173 + * -- Remove a "\t" which looks ugly in the syslogs 174 + * 4.14 July 17, 1998 -- Change to pointing to .ps version of ATAPI spec 175 + * since the .pdf version doesn't seem to work... 176 + * -- Updated the TODO list to something more current. 177 + * 178 + * 4.15 Aug 25, 1998 -- Updated ide-cd.h to respect mechine endianess, 179 + * patch thanks to "Eddie C. Dost" <ecd@skynet.be> 180 + * 181 + * 4.50 Oct 19, 1998 -- New maintainers! 182 + * Jens Axboe <axboe@image.dk> 183 + * Chris Zwilling <chris@cloudnet.com> 184 + * 185 + * 4.51 Dec 23, 1998 -- Jens Axboe <axboe@image.dk> 186 + * - ide_cdrom_reset enabled since the ide subsystem 187 + * handles resets fine now. <axboe@image.dk> 188 + * - Transfer size fix for Samsung CD-ROMs, thanks to 189 + * "Ville Hallik" <ville.hallik@mail.ee>. 190 + * - other minor stuff. 191 + * 192 + * 4.52 Jan 19, 1999 -- Jens Axboe <axboe@image.dk> 193 + * - Detect DVD-ROM/RAM drives 194 + * 195 + * 4.53 Feb 22, 1999 - Include other model Samsung and one Goldstar 196 + * drive in transfer size limit. 197 + * - Fix the I/O error when doing eject without a medium 198 + * loaded on some drives. 199 + * - CDROMREADMODE2 is now implemented through 200 + * CDROMREADRAW, since many drives don't support 201 + * MODE2 (even though ATAPI 2.6 says they must). 202 + * - Added ignore parameter to ide-cd (as a module), eg 203 + * insmod ide-cd ignore='hda hdb' 204 + * Useful when using ide-cd in conjunction with 205 + * ide-scsi. TODO: non-modular way of doing the 206 + * same. 207 + * 208 + * 4.54 Aug 5, 1999 - Support for MMC2 class commands through the generic 209 + * packet interface to cdrom.c. 210 + * - Unified audio ioctl support, most of it. 211 + * - cleaned up various deprecated verify_area(). 212 + * - Added ide_cdrom_packet() as the interface for 213 + * the Uniform generic_packet(). 214 + * - bunch of other stuff, will fill in logs later. 215 + * - report 1 slot for non-changers, like the other 216 + * cd-rom drivers. don't report select disc for 217 + * non-changers as well. 218 + * - mask out audio playing, if the device can't do it. 219 + * 220 + * 4.55 Sep 1, 1999 - Eliminated the rest of the audio ioctls, except 221 + * for CDROMREADTOC[ENTRY|HEADER]. Some of the drivers 222 + * use this independently of the actual audio handling. 223 + * They will disappear later when I get the time to 224 + * do it cleanly. 225 + * - Minimize the TOC reading - only do it when we 226 + * know a media change has occurred. 227 + * - Moved all the CDROMREADx ioctls to the Uniform layer. 228 + * - Heiko Eißfeldt <heiko@colossus.escape.de> supplied 229 + * some fixes for CDI. 230 + * - CD-ROM leaving door locked fix from Andries 231 + * Brouwer <Andries.Brouwer@cwi.nl> 232 + * - Erik Andersen <andersen@xmission.com> unified 233 + * commands across the various drivers and how 234 + * sense errors are handled. 235 + * 236 + * 4.56 Sep 12, 1999 - Removed changer support - it is now in the 237 + * Uniform layer. 238 + * - Added partition based multisession handling. 239 + * - Mode sense and mode select moved to the 240 + * Uniform layer. 241 + * - Fixed a problem with WPI CDS-32X drive - it 242 + * failed the capabilities 243 + * 244 + * 4.57 Apr 7, 2000 - Fixed sense reporting. 245 + * - Fixed possible oops in ide_cdrom_get_last_session() 246 + * - Fix locking mania and make ide_cdrom_reset relock 247 + * - Stop spewing errors to log when magicdev polls with 248 + * TEST_UNIT_READY on some drives. 249 + * - Various fixes from Tobias Ringstrom: 250 + * tray if it was locked prior to the reset. 251 + * - cdrom_read_capacity returns one frame too little. 252 + * - Fix real capacity reporting. 253 + * 254 + * 4.58 May 1, 2000 - Clean up ACER50 stuff. 255 + * - Fix small problem with ide_cdrom_capacity 256 + * 257 + * 4.59 Aug 11, 2000 - Fix changer problem in cdrom_read_toc, we weren't 258 + * correctly sensing a disc change. 259 + * - Rearranged some code 260 + * - Use extended sense on drives that support it for 261 + * correctly reporting tray status -- from 262 + * Michael D Johnson <johnsom@orst.edu> 263 + * 4.60 Dec 17, 2003 - Add mt rainier support 264 + * - Bump timeout for packet commands, matches sr 265 + * - Odd stuff 266 + * 4.61 Jan 22, 2004 - support hardware sector sizes other than 2kB, 267 + * Pascal Schmidt <der.eremit@email.de> 268 + */
+63
Documentation/ide/ChangeLog.ide-floppy.1996-2002
···
··· 1 + /* 2 + * Many thanks to Lode Leroy <Lode.Leroy@www.ibase.be>, who tested so many 3 + * ALPHA patches to this driver on an EASYSTOR LS-120 ATAPI floppy drive. 4 + * 5 + * Ver 0.1 Oct 17 96 Initial test version, mostly based on ide-tape.c. 6 + * Ver 0.2 Oct 31 96 Minor changes. 7 + * Ver 0.3 Dec 2 96 Fixed error recovery bug. 8 + * Ver 0.4 Jan 26 97 Add support for the HDIO_GETGEO ioctl. 9 + * Ver 0.5 Feb 21 97 Add partitions support. 10 + * Use the minimum of the LBA and CHS capacities. 11 + * Avoid hwgroup->rq == NULL on the last irq. 12 + * Fix potential null dereferencing with DEBUG_LOG. 13 + * Ver 0.8 Dec 7 97 Increase irq timeout from 10 to 50 seconds. 14 + * Add media write-protect detection. 15 + * Issue START command only if TEST UNIT READY fails. 16 + * Add work-around for IOMEGA ZIP revision 21.D. 17 + * Remove idefloppy_get_capabilities(). 18 + * Ver 0.9 Jul 4 99 Fix a bug which might have caused the number of 19 + * bytes requested on each interrupt to be zero. 20 + * Thanks to <shanos@es.co.nz> for pointing this out. 21 + * Ver 0.9.sv Jan 6 01 Sam Varshavchik <mrsam@courier-mta.com> 22 + * Implement low level formatting. Reimplemented 23 + * IDEFLOPPY_CAPABILITIES_PAGE, since we need the srfp 24 + * bit. My LS-120 drive barfs on 25 + * IDEFLOPPY_CAPABILITIES_PAGE, but maybe it's just me. 26 + * Compromise by not reporting a failure to get this 27 + * mode page. Implemented four IOCTLs in order to 28 + * implement formatting. IOCTls begin with 0x4600, 29 + * 0x46 is 'F' as in Format. 30 + * Jan 9 01 Userland option to select format verify. 31 + * Added PC_SUPPRESS_ERROR flag - some idefloppy drives 32 + * do not implement IDEFLOPPY_CAPABILITIES_PAGE, and 33 + * return a sense error. Suppress error reporting in 34 + * this particular case in order to avoid spurious 35 + * errors in syslog. The culprit is 36 + * idefloppy_get_capability_page(), so move it to 37 + * idefloppy_begin_format() so that it's not used 38 + * unless absolutely necessary. 39 + * If drive does not support format progress indication 40 + * monitor the dsc bit in the status register. 41 + * Also, O_NDELAY on open will allow the device to be 42 + * opened without a disk available. This can be used to 43 + * open an unformatted disk, or get the device capacity. 44 + * Ver 0.91 Dec 11 99 Added IOMEGA Clik! drive support by 45 + * <paul@paulbristow.net> 46 + * Ver 0.92 Oct 22 00 Paul Bristow became official maintainer for this 47 + * driver. Included Powerbook internal zip kludge. 48 + * Ver 0.93 Oct 24 00 Fixed bugs for Clik! drive 49 + * no disk on insert and disk change now works 50 + * Ver 0.94 Oct 27 00 Tidied up to remove strstr(Clik) everywhere 51 + * Ver 0.95 Nov 7 00 Brought across to kernel 2.4 52 + * Ver 0.96 Jan 7 01 Actually in line with release version of 2.4.0 53 + * including set_bit patch from Rusty Russell 54 + * Ver 0.97 Jul 22 01 Merge 0.91-0.96 onto 0.9.sv for ac series 55 + * Ver 0.97.sv Aug 3 01 Backported from 2.4.7-ac3 56 + * Ver 0.98 Oct 26 01 Split idefloppy_transfer_pc into two pieces to 57 + * fix a lost interrupt problem. It appears the busy 58 + * bit was being deasserted by my IOMEGA ATAPI ZIP 100 59 + * drive before the drive was actually ready. 60 + * Ver 0.98a Oct 29 01 Expose delay value so we can play. 61 + * Ver 0.99 Feb 24 02 Remove duplicate code, modify clik! detection code 62 + * to support new PocketZip drives 63 + */
-6
drivers/cdrom/cdrom.c
··· 2787 return -ENOSYS; 2788 } 2789 2790 - static inline 2791 - int msf_to_lba(char m, char s, char f) 2792 - { 2793 - return (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET; 2794 - } 2795 - 2796 /* 2797 * Required when we need to use READ_10 to issue other than 2048 block 2798 * reads
··· 2787 return -ENOSYS; 2788 } 2789 2790 /* 2791 * Required when we need to use READ_10 to issue other than 2048 block 2792 * reads
+32 -23
drivers/ide/Kconfig
··· 206 To compile this driver as a module, choose M here: the 207 module will be called ide-cd. 208 209 config BLK_DEV_IDETAPE 210 tristate "Include IDE/ATAPI TAPE support (EXPERIMENTAL)" 211 depends on EXPERIMENTAL ··· 626 tristate "National SCx200 chipset support" 627 select BLK_DEV_IDEDMA_PCI 628 help 629 - This driver adds support for the built in IDE on the National 630 - SCx200 series of embedded x86 "Geode" systems 631 632 config BLK_DEV_PIIX 633 tristate "Intel PIIXn chipsets support" ··· 802 depends on PPC_CELLEB 803 select BLK_DEV_IDEDMA_PCI 804 help 805 - This driver provides support for the built-in IDE controller on 806 Toshiba Cell Reference Board. 807 If unsure, say Y. 808 809 endif 810 811 config BLK_DEV_IDE_PMAC 812 - tristate "Builtin PowerMac IDE support" 813 depends on PPC_PMAC && IDE=y && BLK_DEV_IDE=y 814 help 815 - This driver provides support for the built-in IDE controller on 816 most of the recent Apple Power Macintoshes and PowerBooks. 817 If unsure, say Y. 818 819 config BLK_DEV_IDE_PMAC_ATA100FIRST 820 - bool "Probe internal ATA/100 (Kauai) first" 821 depends on BLK_DEV_IDE_PMAC 822 help 823 This option will cause the ATA/100 controller found in UniNorth2 ··· 832 depends on BLK_DEV_IDE_PMAC 833 select BLK_DEV_IDEDMA_PCI 834 help 835 - This option allows the driver for the built-in IDE controller on 836 Power Macintoshes and PowerBooks to use DMA (direct memory access) 837 to transfer data to and from memory. Saying Y is safe and improves 838 performance. ··· 943 help 944 This is the IDE driver for the Amiga Gayle IDE interface. It supports 945 both the `A1200 style' and `A4000 style' of the Gayle IDE interface, 946 - This includes builtin IDE interfaces on some Amiga models (A600, 947 A1200, A4000, and A4000T), and IDE interfaces on the Zorro expansion 948 bus (M-Tech E-Matrix 530 expansion card). 949 Say Y if you have an Amiga with a Gayle IDE interface and want to use ··· 957 depends on BLK_DEV_GAYLE && EXPERIMENTAL 958 ---help--- 959 This driver provides support for the so-called `IDE doublers' (made 960 - by various manufacturers, e.g. Eyetech) that can be connected to the 961 - builtin IDE interface of some Amiga models. Using such an IDE 962 - doubler, you can connect up to four instead of two IDE devices on 963 - the Amiga's builtin IDE interface. 964 965 Note that the normal Amiga Gayle IDE driver may not work correctly 966 if you have an IDE doubler and don't enable this driver! ··· 972 tristate "Buddha/Catweasel/X-Surf IDE interface support (EXPERIMENTAL)" 973 depends on ZORRO && EXPERIMENTAL 974 help 975 - This is the IDE driver for the IDE interfaces on the Buddha, 976 - Catweasel and X-Surf expansion boards. It supports up to two interfaces 977 - on the Buddha, three on the Catweasel and two on the X-Surf. 978 979 Say Y if you have a Buddha or Catweasel expansion board and want to 980 use IDE devices (hard disks, CD-ROM drives, etc.) that are connected ··· 984 tristate "Falcon IDE interface support" 985 depends on ATARI 986 help 987 - This is the IDE driver for the builtin IDE interface on the Atari 988 Falcon. Say Y if you have a Falcon and want to use IDE devices (hard 989 - disks, CD-ROM drives, etc.) that are connected to the builtin IDE 990 interface. 991 992 config BLK_DEV_MAC_IDE 993 tristate "Macintosh Quadra/Powerbook IDE interface support" 994 depends on MAC 995 help 996 - This is the IDE driver for the builtin IDE interface on some m68k 997 Macintosh models. It supports both the `Quadra style' (used in 998 Quadra/ Centris 630 and Performa 588 models) and `Powerbook style' 999 (used in the Powerbook 150 and 190 models) IDE interface. 1000 1001 Say Y if you have such an Macintosh model and want to use IDE 1002 devices (hard disks, CD-ROM drives, etc.) that are connected to the 1003 - builtin IDE interface. 1004 1005 config BLK_DEV_Q40IDE 1006 tristate "Q40/Q60 IDE interface support" ··· 1071 boot parameter. It enables support for the secondary IDE interface 1072 of the ALI M1439/1443/1445/1487/1489 chipsets, and permits faster 1073 I/O speeds to be set as well. See the files 1074 - <file:Documentation/ide.txt> and <file:drivers/ide/legacy/ali14xx.c> for 1075 - more info. 1076 1077 config BLK_DEV_DTC2278 1078 tristate "DTC-2278 support" ··· 1097 help 1098 This driver is enabled at runtime using the "qd65xx.probe" kernel 1099 boot parameter. It permits faster I/O speeds to be set. See the 1100 - <file:Documentation/ide.txt> and <file:drivers/ide/legacy/qd65xx.c> for 1101 - more info. 1102 1103 config BLK_DEV_UMC8672 1104 tristate "UMC-8672 support"
··· 206 To compile this driver as a module, choose M here: the 207 module will be called ide-cd. 208 209 + config BLK_DEV_IDECD_VERBOSE_ERRORS 210 + bool "Verbose error logging for IDE/ATAPI CDROM driver" if EMBEDDED 211 + depends on BLK_DEV_IDECD 212 + default y 213 + help 214 + Turn this on to have the driver print out the meanings of the 215 + ATAPI error codes. This will use up additional 8kB of kernel-space 216 + memory, though. 217 + 218 config BLK_DEV_IDETAPE 219 tristate "Include IDE/ATAPI TAPE support (EXPERIMENTAL)" 220 depends on EXPERIMENTAL ··· 617 tristate "National SCx200 chipset support" 618 select BLK_DEV_IDEDMA_PCI 619 help 620 + This driver adds support for the on-board IDE controller on the 621 + National SCx200 series of embedded x86 "Geode" systems. 622 623 config BLK_DEV_PIIX 624 tristate "Intel PIIXn chipsets support" ··· 793 depends on PPC_CELLEB 794 select BLK_DEV_IDEDMA_PCI 795 help 796 + This driver provides support for the on-board IDE controller on 797 Toshiba Cell Reference Board. 798 If unsure, say Y. 799 800 endif 801 802 config BLK_DEV_IDE_PMAC 803 + tristate "PowerMac on-board IDE support" 804 depends on PPC_PMAC && IDE=y && BLK_DEV_IDE=y 805 help 806 + This driver provides support for the on-board IDE controller on 807 most of the recent Apple Power Macintoshes and PowerBooks. 808 If unsure, say Y. 809 810 config BLK_DEV_IDE_PMAC_ATA100FIRST 811 + bool "Probe on-board ATA/100 (Kauai) first" 812 depends on BLK_DEV_IDE_PMAC 813 help 814 This option will cause the ATA/100 controller found in UniNorth2 ··· 823 depends on BLK_DEV_IDE_PMAC 824 select BLK_DEV_IDEDMA_PCI 825 help 826 + This option allows the driver for the on-board IDE controller on 827 Power Macintoshes and PowerBooks to use DMA (direct memory access) 828 to transfer data to and from memory. Saying Y is safe and improves 829 performance. ··· 934 help 935 This is the IDE driver for the Amiga Gayle IDE interface. It supports 936 both the `A1200 style' and `A4000 style' of the Gayle IDE interface, 937 + This includes on-board IDE interfaces on some Amiga models (A600, 938 A1200, A4000, and A4000T), and IDE interfaces on the Zorro expansion 939 bus (M-Tech E-Matrix 530 expansion card). 940 Say Y if you have an Amiga with a Gayle IDE interface and want to use ··· 948 depends on BLK_DEV_GAYLE && EXPERIMENTAL 949 ---help--- 950 This driver provides support for the so-called `IDE doublers' (made 951 + by various manufacturers, e.g. Eyetech) that can be connected to 952 + the on-board IDE interface of some Amiga models. Using such an IDE 953 + doubler, you can connect up to four instead of two IDE devices to 954 + the Amiga's on-board IDE interface. 955 956 Note that the normal Amiga Gayle IDE driver may not work correctly 957 if you have an IDE doubler and don't enable this driver! ··· 963 tristate "Buddha/Catweasel/X-Surf IDE interface support (EXPERIMENTAL)" 964 depends on ZORRO && EXPERIMENTAL 965 help 966 + This is the IDE driver for the IDE interfaces on the Buddha, Catweasel 967 + and X-Surf expansion boards. It supports up to two interfaces on the 968 + Buddha, three on the Catweasel and two on the X-Surf. 969 970 Say Y if you have a Buddha or Catweasel expansion board and want to 971 use IDE devices (hard disks, CD-ROM drives, etc.) that are connected ··· 975 tristate "Falcon IDE interface support" 976 depends on ATARI 977 help 978 + This is the IDE driver for the on-board IDE interface on the Atari 979 Falcon. Say Y if you have a Falcon and want to use IDE devices (hard 980 + disks, CD-ROM drives, etc.) that are connected to the on-board IDE 981 interface. 982 983 config BLK_DEV_MAC_IDE 984 tristate "Macintosh Quadra/Powerbook IDE interface support" 985 depends on MAC 986 help 987 + This is the IDE driver for the on-board IDE interface on some m68k 988 Macintosh models. It supports both the `Quadra style' (used in 989 Quadra/ Centris 630 and Performa 588 models) and `Powerbook style' 990 (used in the Powerbook 150 and 190 models) IDE interface. 991 992 Say Y if you have such an Macintosh model and want to use IDE 993 devices (hard disks, CD-ROM drives, etc.) that are connected to the 994 + on-board IDE interface. 995 996 config BLK_DEV_Q40IDE 997 tristate "Q40/Q60 IDE interface support" ··· 1062 boot parameter. It enables support for the secondary IDE interface 1063 of the ALI M1439/1443/1445/1487/1489 chipsets, and permits faster 1064 I/O speeds to be set as well. See the files 1065 + <file:Documentation/ide.txt> and <file:drivers/ide/legacy/ali14xx.c> 1066 + for more info. 1067 1068 config BLK_DEV_DTC2278 1069 tristate "DTC-2278 support" ··· 1088 help 1089 This driver is enabled at runtime using the "qd65xx.probe" kernel 1090 boot parameter. It permits faster I/O speeds to be set. See the 1091 + <file:Documentation/ide.txt> and <file:drivers/ide/legacy/qd65xx.c> 1092 + for more info. 1093 1094 config BLK_DEV_UMC8672 1095 tristate "UMC-8672 support"
+3 -1
drivers/ide/Makefile
··· 40 obj-$(CONFIG_IDE_H8300) += h8300/ 41 obj-$(CONFIG_IDE_GENERIC) += ide-generic.o 42 43 obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o 44 - obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd.o 45 obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o 46 obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o 47
··· 40 obj-$(CONFIG_IDE_H8300) += h8300/ 41 obj-$(CONFIG_IDE_GENERIC) += ide-generic.o 42 43 + ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o 44 + 45 obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o 46 + obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o 47 obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o 48 obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o 49
+1 -2
drivers/ide/arm/bast-ide.c
··· 1 - /* linux/drivers/ide/arm/bast-ide.c 2 - * 3 * Copyright (c) 2003-2004 Simtec Electronics 4 * Ben Dooks <ben@simtec.co.uk> 5 *
··· 1 + /* 2 * Copyright (c) 2003-2004 Simtec Electronics 3 * Ben Dooks <ben@simtec.co.uk> 4 *
+14 -36
drivers/ide/arm/icside.c
··· 1 /* 2 - * linux/drivers/ide/arm/icside.c 3 - * 4 * Copyright (c) 1996-2004 Russell King. 5 * 6 * Please note that this platform does not support 32-bit IDE IO. ··· 69 void __iomem *irq_port; 70 void __iomem *ioc_base; 71 unsigned int type; 72 - /* parent device... until the IDE core gets one of its own */ 73 - struct device *dev; 74 ide_hwif_t *hwif[2]; 75 }; 76 ··· 202 * interfaces use the same IRQ, which should guarantee this. 203 */ 204 205 - static void icside_build_sglist(ide_drive_t *drive, struct request *rq) 206 - { 207 - ide_hwif_t *hwif = drive->hwif; 208 - struct icside_state *state = hwif->hwif_data; 209 - struct scatterlist *sg = hwif->sg_table; 210 - 211 - ide_map_sg(drive, rq); 212 - 213 - if (rq_data_dir(rq) == READ) 214 - hwif->sg_dma_direction = DMA_FROM_DEVICE; 215 - else 216 - hwif->sg_dma_direction = DMA_TO_DEVICE; 217 - 218 - hwif->sg_nents = dma_map_sg(state->dev, sg, hwif->sg_nents, 219 - hwif->sg_dma_direction); 220 - } 221 - 222 /* 223 * Configure the IOMD to give the appropriate timings for the transfer 224 * mode being requested. We take the advice of the ATA standards, and ··· 273 static int icside_dma_end(ide_drive_t *drive) 274 { 275 ide_hwif_t *hwif = HWIF(drive); 276 - struct icside_state *state = hwif->hwif_data; 277 278 drive->waiting_for_dma = 0; 279 280 - disable_dma(ECARD_DEV(state->dev)->dma); 281 282 /* Teardown mappings after DMA has completed. */ 283 - dma_unmap_sg(state->dev, hwif->sg_table, hwif->sg_nents, 284 - hwif->sg_dma_direction); 285 286 - return get_dma_residue(ECARD_DEV(state->dev)->dma) != 0; 287 } 288 289 static void icside_dma_start(ide_drive_t *drive) 290 { 291 ide_hwif_t *hwif = HWIF(drive); 292 - struct icside_state *state = hwif->hwif_data; 293 294 /* We can not enable DMA on both channels simultaneously. */ 295 - BUG_ON(dma_channel_active(ECARD_DEV(state->dev)->dma)); 296 - enable_dma(ECARD_DEV(state->dev)->dma); 297 } 298 299 static int icside_dma_setup(ide_drive_t *drive) 300 { 301 ide_hwif_t *hwif = HWIF(drive); 302 - struct icside_state *state = hwif->hwif_data; 303 struct request *rq = hwif->hwgroup->rq; 304 unsigned int dma_mode; 305 ··· 310 /* 311 * We can not enable DMA on both channels. 312 */ 313 - BUG_ON(dma_channel_active(ECARD_DEV(state->dev)->dma)); 314 315 - icside_build_sglist(drive, rq); 316 317 /* 318 * Ensure that we have the right interrupt routed. ··· 327 /* 328 * Select the correct timing for this drive. 329 */ 330 - set_dma_speed(ECARD_DEV(state->dev)->dma, drive->drive_data); 331 332 /* 333 * Tell the DMA engine about the SG table and 334 * data direction. 335 */ 336 - set_dma_sg(ECARD_DEV(state->dev)->dma, hwif->sg_table, hwif->sg_nents); 337 - set_dma_mode(ECARD_DEV(state->dev)->dma, dma_mode); 338 339 drive->waiting_for_dma = 1; 340 ··· 422 hwif->noprobe = 0; 423 hwif->chipset = ide_acorn; 424 hwif->gendev.parent = &ec->dev; 425 } 426 427 return hwif; ··· 570 } 571 572 state->type = ICS_TYPE_NOTYPE; 573 - state->dev = &ec->dev; 574 575 idmem = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); 576 if (idmem) {
··· 1 /* 2 * Copyright (c) 1996-2004 Russell King. 3 * 4 * Please note that this platform does not support 32-bit IDE IO. ··· 71 void __iomem *irq_port; 72 void __iomem *ioc_base; 73 unsigned int type; 74 ide_hwif_t *hwif[2]; 75 }; 76 ··· 206 * interfaces use the same IRQ, which should guarantee this. 207 */ 208 209 /* 210 * Configure the IOMD to give the appropriate timings for the transfer 211 * mode being requested. We take the advice of the ATA standards, and ··· 294 static int icside_dma_end(ide_drive_t *drive) 295 { 296 ide_hwif_t *hwif = HWIF(drive); 297 + struct expansion_card *ec = ECARD_DEV(hwif->dev); 298 299 drive->waiting_for_dma = 0; 300 301 + disable_dma(ec->dma); 302 303 /* Teardown mappings after DMA has completed. */ 304 + ide_destroy_dmatable(drive); 305 306 + return get_dma_residue(ec->dma) != 0; 307 } 308 309 static void icside_dma_start(ide_drive_t *drive) 310 { 311 ide_hwif_t *hwif = HWIF(drive); 312 + struct expansion_card *ec = ECARD_DEV(hwif->dev); 313 314 /* We can not enable DMA on both channels simultaneously. */ 315 + BUG_ON(dma_channel_active(ec->dma)); 316 + enable_dma(ec->dma); 317 } 318 319 static int icside_dma_setup(ide_drive_t *drive) 320 { 321 ide_hwif_t *hwif = HWIF(drive); 322 + struct expansion_card *ec = ECARD_DEV(hwif->dev); 323 struct request *rq = hwif->hwgroup->rq; 324 unsigned int dma_mode; 325 ··· 332 /* 333 * We can not enable DMA on both channels. 334 */ 335 + BUG_ON(dma_channel_active(ec->dma)); 336 337 + hwif->sg_nents = ide_build_sglist(drive, rq); 338 339 /* 340 * Ensure that we have the right interrupt routed. ··· 349 /* 350 * Select the correct timing for this drive. 351 */ 352 + set_dma_speed(ec->dma, drive->drive_data); 353 354 /* 355 * Tell the DMA engine about the SG table and 356 * data direction. 357 */ 358 + set_dma_sg(ec->dma, hwif->sg_table, hwif->sg_nents); 359 + set_dma_mode(ec->dma, dma_mode); 360 361 drive->waiting_for_dma = 1; 362 ··· 444 hwif->noprobe = 0; 445 hwif->chipset = ide_acorn; 446 hwif->gendev.parent = &ec->dev; 447 + hwif->dev = &ec->dev; 448 } 449 450 return hwif; ··· 591 } 592 593 state->type = ICS_TYPE_NOTYPE; 594 595 idmem = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); 596 if (idmem) {
+2 -4
drivers/ide/arm/rapide.c
··· 1 /* 2 - * linux/drivers/ide/arm/rapide.c 3 - * 4 * Copyright (c) 1996-2002 Russell King. 5 */ 6 ··· 76 77 ecard_set_drvdata(ec, NULL); 78 79 - /* there must be a better way */ 80 - ide_unregister(hwif - ide_hwifs); 81 ecard_release_resources(ec); 82 } 83
··· 1 /* 2 * Copyright (c) 1996-2002 Russell King. 3 */ 4 ··· 78 79 ecard_set_drvdata(ec, NULL); 80 81 + ide_unregister(hwif->index); 82 + 83 ecard_release_resources(ec); 84 } 85
+1 -2
drivers/ide/cris/ide-cris.c
··· 1 - /* $Id: cris-ide-driver.patch,v 1.1 2005/06/29 21:39:07 akpm Exp $ 2 - * 3 * Etrax specific IDE functions, like init and PIO-mode setting etc. 4 * Almost the entire ide.c is used for the rest of the Etrax ATA driver. 5 * Copyright (c) 2000-2005 Axis Communications AB
··· 1 + /* 2 * Etrax specific IDE functions, like init and PIO-mode setting etc. 3 * Almost the entire ide.c is used for the rest of the Etrax ATA driver. 4 * Copyright (c) 2000-2005 Axis Communications AB
-1
drivers/ide/h8300/ide-h8300.c
··· 1 /* 2 - * drivers/ide/h8300/ide-h8300.c 3 * H8/300 generic IDE interface 4 */ 5
··· 1 /* 2 * H8/300 generic IDE interface 3 */ 4
-1
drivers/ide/ide-acpi.c
··· 1 /* 2 - * ide-acpi.c 3 * Provides ACPI support for IDE drives. 4 * 5 * Copyright (C) 2005 Intel Corp.
··· 1 /* 2 * Provides ACPI support for IDE drives. 3 * 4 * Copyright (C) 2005 Intel Corp.
+590 -1859
drivers/ide/ide-cd.c
··· 1 /* 2 - * linux/drivers/ide/ide-cd.c 3 * 4 - * Copyright (C) 1994, 1995, 1996 scott snyder <snyder@fnald0.fnal.gov> 5 - * Copyright (C) 1996-1998 Erik Andersen <andersee@debian.org> 6 - * Copyright (C) 1998-2000 Jens Axboe <axboe@suse.de> 7 * 8 * May be copied or modified under the terms of the GNU General Public 9 * License. See linux/COPYING for more information. 10 * 11 - * ATAPI CD-ROM driver. To be used with ide.c. 12 * See Documentation/cdrom/ide-cd for usage information. 13 * 14 * Suggestions are welcome. Patches that work are more welcome though. ;-) ··· 19 * ftp://fission.dt.wdc.com/pub/standards/SFF_atapi/spec/SFF8020-r2.6/PS/8020r26.ps 20 * ftp://ftp.avc-pioneer.com/Mtfuji4/Spec/Fuji4r10.pdf 21 * 22 - * Drives that deviate from these standards will be accommodated as much 23 - * as possible via compile time or command-line options. Since I only have 24 - * a few drives, you generally need to send me patches... 25 - * 26 - * ---------------------------------- 27 - * TO DO LIST: 28 - * -Make it so that Pioneer CD DR-A24X and friends don't get screwed up on 29 - * boot 30 - * 31 - * ---------------------------------- 32 - * 1.00 Oct 31, 1994 -- Initial version. 33 - * 1.01 Nov 2, 1994 -- Fixed problem with starting request in 34 - * cdrom_check_status. 35 - * 1.03 Nov 25, 1994 -- leaving unmask_intr[] as a user-setting (as for disks) 36 - * (from mlord) -- minor changes to cdrom_setup() 37 - * -- renamed ide_dev_s to ide_drive_t, enable irq on command 38 - * 2.00 Nov 27, 1994 -- Generalize packet command interface; 39 - * add audio ioctls. 40 - * 2.01 Dec 3, 1994 -- Rework packet command interface to handle devices 41 - * which send an interrupt when ready for a command. 42 - * 2.02 Dec 11, 1994 -- Cache the TOC in the driver. 43 - * Don't use SCMD_PLAYAUDIO_TI; it's not included 44 - * in the current version of ATAPI. 45 - * Try to use LBA instead of track or MSF addressing 46 - * when possible. 47 - * Don't wait for READY_STAT. 48 - * 2.03 Jan 10, 1995 -- Rewrite block read routines to handle block sizes 49 - * other than 2k and to move multiple sectors in a 50 - * single transaction. 51 - * 2.04 Apr 21, 1995 -- Add work-around for Creative Labs CD220E drives. 52 - * Thanks to Nick Saw <cwsaw@pts7.pts.mot.com> for 53 - * help in figuring this out. Ditto for Acer and 54 - * Aztech drives, which seem to have the same problem. 55 - * 2.04b May 30, 1995 -- Fix to match changes in ide.c version 3.16 -ml 56 - * 2.05 Jun 8, 1995 -- Don't attempt to retry after an illegal request 57 - * or data protect error. 58 - * Use HWIF and DEV_HWIF macros as in ide.c. 59 - * Always try to do a request_sense after 60 - * a failed command. 61 - * Include an option to give textual descriptions 62 - * of ATAPI errors. 63 - * Fix a bug in handling the sector cache which 64 - * showed up if the drive returned data in 512 byte 65 - * blocks (like Pioneer drives). Thanks to 66 - * Richard Hirst <srh@gpt.co.uk> for diagnosing this. 67 - * Properly supply the page number field in the 68 - * MODE_SELECT command. 69 - * PLAYAUDIO12 is broken on the Aztech; work around it. 70 - * 2.05x Aug 11, 1995 -- lots of data structure renaming/restructuring in ide.c 71 - * (my apologies to Scott, but now ide-cd.c is independent) 72 - * 3.00 Aug 22, 1995 -- Implement CDROMMULTISESSION ioctl. 73 - * Implement CDROMREADAUDIO ioctl (UNTESTED). 74 - * Use input_ide_data() and output_ide_data(). 75 - * Add door locking. 76 - * Fix usage count leak in cdrom_open, which happened 77 - * when a read-write mount was attempted. 78 - * Try to load the disk on open. 79 - * Implement CDROMEJECT_SW ioctl (off by default). 80 - * Read total cdrom capacity during open. 81 - * Rearrange logic in cdrom_decode_status. Issue 82 - * request sense commands for failed packet commands 83 - * from here instead of from cdrom_queue_packet_command. 84 - * Fix a race condition in retrieving error information. 85 - * Suppress printing normal unit attention errors and 86 - * some drive not ready errors. 87 - * Implement CDROMVOLREAD ioctl. 88 - * Implement CDROMREADMODE1/2 ioctls. 89 - * Fix race condition in setting up interrupt handlers 90 - * when the `serialize' option is used. 91 - * 3.01 Sep 2, 1995 -- Fix ordering of reenabling interrupts in 92 - * cdrom_queue_request. 93 - * Another try at using ide_[input,output]_data. 94 - * 3.02 Sep 16, 1995 -- Stick total disk capacity in partition table as well. 95 - * Make VERBOSE_IDE_CD_ERRORS dump failed command again. 96 - * Dump out more information for ILLEGAL REQUEST errs. 97 - * Fix handling of errors occurring before the 98 - * packet command is transferred. 99 - * Fix transfers with odd bytelengths. 100 - * 3.03 Oct 27, 1995 -- Some Creative drives have an id of just `CD'. 101 - * `DCI-2S10' drives are broken too. 102 - * 3.04 Nov 20, 1995 -- So are Vertos drives. 103 - * 3.05 Dec 1, 1995 -- Changes to go with overhaul of ide.c and ide-tape.c 104 - * 3.06 Dec 16, 1995 -- Add support needed for partitions. 105 - * More workarounds for Vertos bugs (based on patches 106 - * from Holger Dietze <dietze@aix520.informatik.uni-leipzig.de>). 107 - * Try to eliminate byteorder assumptions. 108 - * Use atapi_cdrom_subchnl struct definition. 109 - * Add STANDARD_ATAPI compilation option. 110 - * 3.07 Jan 29, 1996 -- More twiddling for broken drives: Sony 55D, 111 - * Vertos 300. 112 - * Add NO_DOOR_LOCKING configuration option. 113 - * Handle drive_cmd requests w/NULL args (for hdparm -t). 114 - * Work around sporadic Sony55e audio play problem. 115 - * 3.07a Feb 11, 1996 -- check drive->id for NULL before dereferencing, to fix 116 - * problem with "hde=cdrom" with no drive present. -ml 117 - * 3.08 Mar 6, 1996 -- More Vertos workarounds. 118 - * 3.09 Apr 5, 1996 -- Add CDROMCLOSETRAY ioctl. 119 - * Switch to using MSF addressing for audio commands. 120 - * Reformat to match kernel tabbing style. 121 - * Add CDROM_GET_UPC ioctl. 122 - * 3.10 Apr 10, 1996 -- Fix compilation error with STANDARD_ATAPI. 123 - * 3.11 Apr 29, 1996 -- Patch from Heiko Eißfeldt <heiko@colossus.escape.de> 124 - * to remove redundant verify_area calls. 125 - * 3.12 May 7, 1996 -- Rudimentary changer support. Based on patches 126 - * from Gerhard Zuber <zuber@berlin.snafu.de>. 127 - * Let open succeed even if there's no loaded disc. 128 - * 3.13 May 19, 1996 -- Fixes for changer code. 129 - * 3.14 May 29, 1996 -- Add work-around for Vertos 600. 130 - * (From Hennus Bergman <hennus@sky.ow.nl>.) 131 - * 3.15 July 2, 1996 -- Added support for Sanyo 3 CD changers 132 - * from Ben Galliart <bgallia@luc.edu> with 133 - * special help from Jeff Lightfoot 134 - * <jeffml@pobox.com> 135 - * 3.15a July 9, 1996 -- Improved Sanyo 3 CD changer identification 136 - * 3.16 Jul 28, 1996 -- Fix from Gadi to reduce kernel stack usage for ioctl. 137 - * 3.17 Sep 17, 1996 -- Tweak audio reads for some drives. 138 - * Start changing CDROMLOADFROMSLOT to CDROM_SELECT_DISC. 139 - * 3.18 Oct 31, 1996 -- Added module and DMA support. 140 - * 141 - * 142 - * 4.00 Nov 5, 1996 -- New ide-cd maintainer, 143 - * Erik B. Andersen <andersee@debian.org> 144 - * -- Newer Creative drives don't always set the error 145 - * register correctly. Make sure we see media changes 146 - * regardless. 147 - * -- Integrate with generic cdrom driver. 148 - * -- CDROMGETSPINDOWN and CDROMSETSPINDOWN ioctls, based on 149 - * a patch from Ciro Cattuto <>. 150 - * -- Call set_device_ro. 151 - * -- Implement CDROMMECHANISMSTATUS and CDROMSLOTTABLE 152 - * ioctls, based on patch by Erik Andersen 153 - * -- Add some probes of drive capability during setup. 154 - * 155 - * 4.01 Nov 11, 1996 -- Split into ide-cd.c and ide-cd.h 156 - * -- Removed CDROMMECHANISMSTATUS and CDROMSLOTTABLE 157 - * ioctls in favor of a generalized approach 158 - * using the generic cdrom driver. 159 - * -- Fully integrated with the 2.1.X kernel. 160 - * -- Other stuff that I forgot (lots of changes) 161 - * 162 - * 4.02 Dec 01, 1996 -- Applied patch from Gadi Oxman <gadio@netvision.net.il> 163 - * to fix the drive door locking problems. 164 - * 165 - * 4.03 Dec 04, 1996 -- Added DSC overlap support. 166 - * 4.04 Dec 29, 1996 -- Added CDROMREADRAW ioclt based on patch 167 - * by Ales Makarov (xmakarov@sun.felk.cvut.cz) 168 - * 169 - * 4.05 Nov 20, 1997 -- Modified to print more drive info on init 170 - * Minor other changes 171 - * Fix errors on CDROMSTOP (If you have a "Dolphin", 172 - * you must define IHAVEADOLPHIN) 173 - * Added identifier so new Sanyo CD-changer works 174 - * Better detection if door locking isn't supported 175 - * 176 - * 4.06 Dec 17, 1997 -- fixed endless "tray open" messages -ml 177 - * 4.07 Dec 17, 1997 -- fallback to set pc->stat on "tray open" 178 - * 4.08 Dec 18, 1997 -- spew less noise when tray is empty 179 - * -- fix speed display for ACER 24X, 18X 180 - * 4.09 Jan 04, 1998 -- fix handling of the last block so we return 181 - * an end of file instead of an I/O error (Gadi) 182 - * 4.10 Jan 24, 1998 -- fixed a bug so now changers can change to a new 183 - * slot when there is no disc in the current slot. 184 - * -- Fixed a memory leak where info->changer_info was 185 - * malloc'ed but never free'd when closing the device. 186 - * -- Cleaned up the global namespace a bit by making more 187 - * functions static that should already have been. 188 - * 4.11 Mar 12, 1998 -- Added support for the CDROM_SELECT_SPEED ioctl 189 - * based on a patch for 2.0.33 by Jelle Foks 190 - * <jelle@scintilla.utwente.nl>, a patch for 2.0.33 191 - * by Toni Giorgino <toni@pcape2.pi.infn.it>, the SCSI 192 - * version, and my own efforts. -erik 193 - * -- Fixed a stupid bug which egcs was kind enough to 194 - * inform me of where "Illegal mode for this track" 195 - * was never returned due to a comparison on data 196 - * types of limited range. 197 - * 4.12 Mar 29, 1998 -- Fixed bug in CDROM_SELECT_SPEED so write speed is 198 - * now set ionly for CD-R and CD-RW drives. I had 199 - * removed this support because it produced errors. 200 - * It produced errors _only_ for non-writers. duh. 201 - * 4.13 May 05, 1998 -- Suppress useless "in progress of becoming ready" 202 - * messages, since this is not an error. 203 - * -- Change error messages to be const 204 - * -- Remove a "\t" which looks ugly in the syslogs 205 - * 4.14 July 17, 1998 -- Change to pointing to .ps version of ATAPI spec 206 - * since the .pdf version doesn't seem to work... 207 - * -- Updated the TODO list to something more current. 208 - * 209 - * 4.15 Aug 25, 1998 -- Updated ide-cd.h to respect mechine endianess, 210 - * patch thanks to "Eddie C. Dost" <ecd@skynet.be> 211 - * 212 - * 4.50 Oct 19, 1998 -- New maintainers! 213 - * Jens Axboe <axboe@image.dk> 214 - * Chris Zwilling <chris@cloudnet.com> 215 - * 216 - * 4.51 Dec 23, 1998 -- Jens Axboe <axboe@image.dk> 217 - * - ide_cdrom_reset enabled since the ide subsystem 218 - * handles resets fine now. <axboe@image.dk> 219 - * - Transfer size fix for Samsung CD-ROMs, thanks to 220 - * "Ville Hallik" <ville.hallik@mail.ee>. 221 - * - other minor stuff. 222 - * 223 - * 4.52 Jan 19, 1999 -- Jens Axboe <axboe@image.dk> 224 - * - Detect DVD-ROM/RAM drives 225 - * 226 - * 4.53 Feb 22, 1999 - Include other model Samsung and one Goldstar 227 - * drive in transfer size limit. 228 - * - Fix the I/O error when doing eject without a medium 229 - * loaded on some drives. 230 - * - CDROMREADMODE2 is now implemented through 231 - * CDROMREADRAW, since many drives don't support 232 - * MODE2 (even though ATAPI 2.6 says they must). 233 - * - Added ignore parameter to ide-cd (as a module), eg 234 - * insmod ide-cd ignore='hda hdb' 235 - * Useful when using ide-cd in conjunction with 236 - * ide-scsi. TODO: non-modular way of doing the 237 - * same. 238 - * 239 - * 4.54 Aug 5, 1999 - Support for MMC2 class commands through the generic 240 - * packet interface to cdrom.c. 241 - * - Unified audio ioctl support, most of it. 242 - * - cleaned up various deprecated verify_area(). 243 - * - Added ide_cdrom_packet() as the interface for 244 - * the Uniform generic_packet(). 245 - * - bunch of other stuff, will fill in logs later. 246 - * - report 1 slot for non-changers, like the other 247 - * cd-rom drivers. don't report select disc for 248 - * non-changers as well. 249 - * - mask out audio playing, if the device can't do it. 250 - * 251 - * 4.55 Sep 1, 1999 - Eliminated the rest of the audio ioctls, except 252 - * for CDROMREADTOC[ENTRY|HEADER]. Some of the drivers 253 - * use this independently of the actual audio handling. 254 - * They will disappear later when I get the time to 255 - * do it cleanly. 256 - * - Minimize the TOC reading - only do it when we 257 - * know a media change has occurred. 258 - * - Moved all the CDROMREADx ioctls to the Uniform layer. 259 - * - Heiko Eißfeldt <heiko@colossus.escape.de> supplied 260 - * some fixes for CDI. 261 - * - CD-ROM leaving door locked fix from Andries 262 - * Brouwer <Andries.Brouwer@cwi.nl> 263 - * - Erik Andersen <andersen@xmission.com> unified 264 - * commands across the various drivers and how 265 - * sense errors are handled. 266 - * 267 - * 4.56 Sep 12, 1999 - Removed changer support - it is now in the 268 - * Uniform layer. 269 - * - Added partition based multisession handling. 270 - * - Mode sense and mode select moved to the 271 - * Uniform layer. 272 - * - Fixed a problem with WPI CDS-32X drive - it 273 - * failed the capabilities 274 - * 275 - * 4.57 Apr 7, 2000 - Fixed sense reporting. 276 - * - Fixed possible oops in ide_cdrom_get_last_session() 277 - * - Fix locking mania and make ide_cdrom_reset relock 278 - * - Stop spewing errors to log when magicdev polls with 279 - * TEST_UNIT_READY on some drives. 280 - * - Various fixes from Tobias Ringstrom: 281 - * tray if it was locked prior to the reset. 282 - * - cdrom_read_capacity returns one frame too little. 283 - * - Fix real capacity reporting. 284 - * 285 - * 4.58 May 1, 2000 - Clean up ACER50 stuff. 286 - * - Fix small problem with ide_cdrom_capacity 287 - * 288 - * 4.59 Aug 11, 2000 - Fix changer problem in cdrom_read_toc, we weren't 289 - * correctly sensing a disc change. 290 - * - Rearranged some code 291 - * - Use extended sense on drives that support it for 292 - * correctly reporting tray status -- from 293 - * Michael D Johnson <johnsom@orst.edu> 294 - * 4.60 Dec 17, 2003 - Add mt rainier support 295 - * - Bump timeout for packet commands, matches sr 296 - * - Odd stuff 297 - * 4.61 Jan 22, 2004 - support hardware sector sizes other than 2kB, 298 - * Pascal Schmidt <der.eremit@email.de> 299 - * 300 - *************************************************************************/ 301 - 302 - #define IDECD_VERSION "4.61" 303 304 #include <linux/module.h> 305 #include <linux/types.h> ··· 37 #include <linux/ide.h> 38 #include <linux/completion.h> 39 #include <linux/mutex.h> 40 41 #include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */ 42 ··· 85 buffers. */ 86 static void cdrom_saw_media_change (ide_drive_t *drive) 87 { 88 - struct cdrom_info *info = drive->driver_data; 89 - 90 - CDROM_STATE_FLAGS (drive)->media_changed = 1; 91 - CDROM_STATE_FLAGS (drive)->toc_valid = 0; 92 - info->nsectors_buffered = 0; 93 } 94 95 static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, ··· 190 } 191 } 192 } 193 - #if VERBOSE_IDE_CD_ERRORS 194 - { 195 - int i; 196 - const char *s = "bad sense key!"; 197 - char buf[80]; 198 199 - printk ("ATAPI device %s:\n", drive->name); 200 - if (sense->error_code==0x70) 201 - printk(" Error: "); 202 - else if (sense->error_code==0x71) 203 - printk(" Deferred Error: "); 204 - else if (sense->error_code == 0x7f) 205 - printk(" Vendor-specific Error: "); 206 - else 207 - printk(" Unknown Error Type: "); 208 - 209 - if (sense->sense_key < ARRAY_SIZE(sense_key_texts)) 210 - s = sense_key_texts[sense->sense_key]; 211 - 212 - printk("%s -- (Sense key=0x%02x)\n", s, sense->sense_key); 213 - 214 - if (sense->asc == 0x40) { 215 - sprintf(buf, "Diagnostic failure on component 0x%02x", 216 - sense->ascq); 217 - s = buf; 218 - } else { 219 - int lo = 0, mid, hi = ARRAY_SIZE(sense_data_texts); 220 - unsigned long key = (sense->sense_key << 16); 221 - key |= (sense->asc << 8); 222 - if (!(sense->ascq >= 0x80 && sense->ascq <= 0xdd)) 223 - key |= sense->ascq; 224 - s = NULL; 225 - 226 - while (hi > lo) { 227 - mid = (lo + hi) / 2; 228 - if (sense_data_texts[mid].asc_ascq == key || 229 - sense_data_texts[mid].asc_ascq == (0xff0000|key)) { 230 - s = sense_data_texts[mid].text; 231 - break; 232 - } 233 - else if (sense_data_texts[mid].asc_ascq > key) 234 - hi = mid; 235 - else 236 - lo = mid+1; 237 - } 238 - } 239 - 240 - if (s == NULL) { 241 - if (sense->asc > 0x80) 242 - s = "(vendor-specific error)"; 243 - else 244 - s = "(reserved error code)"; 245 - } 246 - 247 - printk(KERN_ERR " %s -- (asc=0x%02x, ascq=0x%02x)\n", 248 - s, sense->asc, sense->ascq); 249 - 250 - if (failed_command != NULL) { 251 - 252 - int lo=0, mid, hi= ARRAY_SIZE(packet_command_texts); 253 - s = NULL; 254 - 255 - while (hi > lo) { 256 - mid = (lo + hi) / 2; 257 - if (packet_command_texts[mid].packet_command == 258 - failed_command->cmd[0]) { 259 - s = packet_command_texts[mid].text; 260 - break; 261 - } 262 - if (packet_command_texts[mid].packet_command > 263 - failed_command->cmd[0]) 264 - hi = mid; 265 - else 266 - lo = mid+1; 267 - } 268 - 269 - printk (KERN_ERR " The failed \"%s\" packet command was: \n \"", s); 270 - for (i=0; i<sizeof (failed_command->cmd); i++) 271 - printk ("%02x ", failed_command->cmd[i]); 272 - printk ("\"\n"); 273 - } 274 - 275 - /* The SKSV bit specifies validity of the sense_key_specific 276 - * in the next two commands. It is bit 7 of the first byte. 277 - * In the case of NOT_READY, if SKSV is set the drive can 278 - * give us nice ETA readings. 279 - */ 280 - if (sense->sense_key == NOT_READY && (sense->sks[0] & 0x80)) { 281 - int progress = (sense->sks[1] << 8 | sense->sks[2]) * 100; 282 - printk(KERN_ERR " Command is %02d%% complete\n", progress / 0xffff); 283 - 284 - } 285 - 286 - if (sense->sense_key == ILLEGAL_REQUEST && 287 - (sense->sks[0] & 0x80) != 0) { 288 - printk(KERN_ERR " Error in %s byte %d", 289 - (sense->sks[0] & 0x40) != 0 ? 290 - "command packet" : "command data", 291 - (sense->sks[1] << 8) + sense->sks[2]); 292 - 293 - if ((sense->sks[0] & 0x40) != 0) 294 - printk (" bit %d", sense->sks[0] & 0x07); 295 - 296 - printk ("\n"); 297 - } 298 - } 299 - 300 - #else /* not VERBOSE_IDE_CD_ERRORS */ 301 - 302 - /* Suppress printing unit attention and `in progress of becoming ready' 303 - errors when we're not being verbose. */ 304 - 305 - if (sense->sense_key == UNIT_ATTENTION || 306 - (sense->sense_key == NOT_READY && (sense->asc == 4 || 307 - sense->asc == 0x3a))) 308 - return; 309 - 310 - printk(KERN_ERR "%s: error code: 0x%02x sense_key: 0x%02x asc: 0x%02x ascq: 0x%02x\n", 311 - drive->name, 312 - sense->error_code, sense->sense_key, 313 - sense->asc, sense->ascq); 314 - #endif /* not VERBOSE_IDE_CD_ERRORS */ 315 } 316 317 /* 318 * Initialize a ide-cd packet command request 319 */ 320 - static void cdrom_prepare_request(ide_drive_t *drive, struct request *rq) 321 { 322 struct cdrom_info *cd = drive->driver_data; 323 ··· 216 sense = &info->sense_data; 217 218 /* stuff the sense request in front of our current request */ 219 - cdrom_prepare_request(drive, rq); 220 221 rq->data = sense; 222 rq->cmd[0] = GPCMD_REQUEST_SENSE; ··· 323 324 } else if (blk_pc_request(rq) || rq->cmd_type == REQ_TYPE_ATA_PC) { 325 /* All other functions, except for READ. */ 326 - unsigned long flags; 327 328 /* 329 * if we have an error, pass back CHECK_CONDITION as the ··· 360 * remove failed request completely and end it when the 361 * request sense has completed 362 */ 363 - if (stat & ERR_STAT) { 364 - spin_lock_irqsave(&ide_lock, flags); 365 - blkdev_dequeue_request(rq); 366 - HWGROUP(drive)->rq = NULL; 367 - spin_unlock_irqrestore(&ide_lock, flags); 368 - 369 - cdrom_queue_request_sense(drive, rq->sense, rq); 370 - } else 371 - cdrom_end_request(drive, 0); 372 373 } else if (blk_fs_request(rq)) { 374 int do_end_request = 0; ··· 440 sense data. We need this in order to perform end of media 441 processing */ 442 443 - if (do_end_request) { 444 - if (stat & ERR_STAT) { 445 - unsigned long flags; 446 - spin_lock_irqsave(&ide_lock, flags); 447 - blkdev_dequeue_request(rq); 448 - HWGROUP(drive)->rq = NULL; 449 - spin_unlock_irqrestore(&ide_lock, flags); 450 451 - cdrom_queue_request_sense(drive, rq->sense, rq); 452 - } else 453 - cdrom_end_request(drive, 0); 454 - } else { 455 - /* If we got a CHECK_CONDITION status, 456 - queue a request sense command. */ 457 - if (stat & ERR_STAT) 458 - cdrom_queue_request_sense(drive, NULL, NULL); 459 - } 460 } else { 461 blk_dump_rq_flags(rq, "ide-cd: bad rq"); 462 cdrom_end_request(drive, 0); 463 } 464 465 /* Retry, or handle the next request. */ 466 return 1; 467 } 468 ··· 527 /* Set up the controller registers. */ 528 ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | 529 IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); 530 - 531 - if (CDROM_CONFIG_FLAGS (drive)->drq_interrupt) { 532 /* waiting for CDB interrupt, not DMA yet. */ 533 if (info->dma) 534 drive->waiting_for_dma = 0; ··· 554 by cdrom_start_packet_command. 555 HANDLER is the interrupt handler to call when the command completes 556 or there's data ready. */ 557 - /* 558 - * changed 5 parameters to 3 for dvd-ram 559 - * struct packet_command *pc; now packet_command_t *pc; 560 - */ 561 #define ATAPI_MIN_CDB_BYTES 12 562 static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, 563 struct request *rq, ··· 564 struct cdrom_info *info = drive->driver_data; 565 ide_startstop_t startstop; 566 567 - if (CDROM_CONFIG_FLAGS(drive)->drq_interrupt) { 568 /* Here we should have been called after receiving an interrupt 569 from the device. DRQ should how be set. */ 570 ··· 604 * Block read functions. 605 */ 606 607 /* 608 * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector 609 * buffer. Once the first sector is added, any subsequent sectors are ··· 663 } 664 665 /* Throw away any remaining data. */ 666 - while (sectors_to_transfer > 0) { 667 - static char dum[SECTOR_SIZE]; 668 - HWIF(drive)->atapi_input_bytes(drive, dum, sizeof (dum)); 669 - --sectors_to_transfer; 670 - } 671 } 672 673 /* ··· 672 * ok; nonzero if the request has been terminated. 673 */ 674 static 675 - int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason) 676 { 677 - if (ireason == 2) 678 return 0; 679 - else if (ireason == 0) { 680 - /* Whoops... The drive is expecting to receive data from us! */ 681 printk(KERN_ERR "%s: %s: wrong transfer direction!\n", 682 drive->name, __FUNCTION__); 683 684 - /* Throw some data at the drive so it doesn't hang 685 - and quit this request. */ 686 - while (len > 0) { 687 - int dum = 0; 688 - HWIF(drive)->atapi_output_bytes(drive, &dum, sizeof (dum)); 689 - len -= sizeof (dum); 690 - } 691 - } else if (ireason == 1) { 692 /* Some drives (ASUS) seem to tell us that status 693 * info is available. just get it and ignore. 694 */ ··· 707 } 708 709 /* 710 - * Interrupt routine. Called when a read request has completed. 711 */ 712 - static ide_startstop_t cdrom_read_intr (ide_drive_t *drive) 713 { 714 - int stat; 715 - int ireason, len, sectors_to_transfer, nskip; 716 - struct cdrom_info *info = drive->driver_data; 717 - u8 lowcyl = 0, highcyl = 0; 718 - int dma = info->dma, dma_error = 0; 719 720 - struct request *rq = HWGROUP(drive)->rq; 721 722 - /* 723 - * handle dma case 724 - */ 725 - if (dma) { 726 - info->dma = 0; 727 - dma_error = HWIF(drive)->ide_dma_end(drive); 728 - if (dma_error) { 729 - printk(KERN_ERR "%s: DMA read error\n", drive->name); 730 - ide_dma_off(drive); 731 - } 732 } 733 734 - if (cdrom_decode_status(drive, 0, &stat)) 735 - return ide_stopped; 736 - 737 - if (dma) { 738 - if (!dma_error) { 739 - ide_end_request(drive, 1, rq->nr_sectors); 740 - return ide_stopped; 741 - } else 742 - return ide_error(drive, "dma error", stat); 743 - } 744 - 745 - /* Read the interrupt reason and the transfer length. */ 746 - ireason = HWIF(drive)->INB(IDE_IREASON_REG) & 0x3; 747 - lowcyl = HWIF(drive)->INB(IDE_BCOUNTL_REG); 748 - highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG); 749 - 750 - len = lowcyl + (256 * highcyl); 751 - 752 - /* If DRQ is clear, the command has completed. */ 753 - if ((stat & DRQ_STAT) == 0) { 754 - /* If we're not done filling the current buffer, complain. 755 - Otherwise, complete the command normally. */ 756 - if (rq->current_nr_sectors > 0) { 757 - printk (KERN_ERR "%s: cdrom_read_intr: data underrun (%d blocks)\n", 758 - drive->name, rq->current_nr_sectors); 759 - rq->cmd_flags |= REQ_FAILED; 760 - cdrom_end_request(drive, 0); 761 - } else 762 - cdrom_end_request(drive, 1); 763 - return ide_stopped; 764 - } 765 - 766 - /* Check that the drive is expecting to do the same thing we are. */ 767 - if (cdrom_read_check_ireason (drive, len, ireason)) 768 - return ide_stopped; 769 - 770 - /* Assume that the drive will always provide data in multiples 771 - of at least SECTOR_SIZE, as it gets hairy to keep track 772 - of the transfers otherwise. */ 773 - if ((len % SECTOR_SIZE) != 0) { 774 - printk (KERN_ERR "%s: cdrom_read_intr: Bad transfer size %d\n", 775 - drive->name, len); 776 - if (CDROM_CONFIG_FLAGS(drive)->limit_nframes) 777 - printk (KERN_ERR " This drive is not supported by this version of the driver\n"); 778 - else { 779 - printk (KERN_ERR " Trying to limit transfer sizes\n"); 780 - CDROM_CONFIG_FLAGS(drive)->limit_nframes = 1; 781 - } 782 - cdrom_end_request(drive, 0); 783 - return ide_stopped; 784 - } 785 - 786 - /* The number of sectors we need to read from the drive. */ 787 - sectors_to_transfer = len / SECTOR_SIZE; 788 - 789 - /* First, figure out if we need to bit-bucket 790 - any of the leading sectors. */ 791 - nskip = min_t(int, rq->current_nr_sectors - bio_cur_sectors(rq->bio), sectors_to_transfer); 792 - 793 - while (nskip > 0) { 794 - /* We need to throw away a sector. */ 795 - static char dum[SECTOR_SIZE]; 796 - HWIF(drive)->atapi_input_bytes(drive, dum, sizeof (dum)); 797 - 798 - --rq->current_nr_sectors; 799 - --nskip; 800 - --sectors_to_transfer; 801 - } 802 - 803 - /* Now loop while we still have data to read from the drive. */ 804 - while (sectors_to_transfer > 0) { 805 - int this_transfer; 806 - 807 - /* If we've filled the present buffer but there's another 808 - chained buffer after it, move on. */ 809 - if (rq->current_nr_sectors == 0 && rq->nr_sectors) 810 - cdrom_end_request(drive, 1); 811 - 812 - /* If the buffers are full, cache the rest of the data in our 813 - internal buffer. */ 814 - if (rq->current_nr_sectors == 0) { 815 - cdrom_buffer_sectors(drive, rq->sector, sectors_to_transfer); 816 - sectors_to_transfer = 0; 817 - } else { 818 - /* Transfer data to the buffers. 819 - Figure out how many sectors we can transfer 820 - to the current buffer. */ 821 - this_transfer = min_t(int, sectors_to_transfer, 822 - rq->current_nr_sectors); 823 - 824 - /* Read this_transfer sectors 825 - into the current buffer. */ 826 - while (this_transfer > 0) { 827 - HWIF(drive)->atapi_input_bytes(drive, rq->buffer, SECTOR_SIZE); 828 - rq->buffer += SECTOR_SIZE; 829 - --rq->nr_sectors; 830 - --rq->current_nr_sectors; 831 - ++rq->sector; 832 - --this_transfer; 833 - --sectors_to_transfer; 834 - } 835 - } 836 - } 837 - 838 - /* Done moving data! Wait for another interrupt. */ 839 - ide_set_handler(drive, &cdrom_read_intr, ATAPI_WAIT_PC, NULL); 840 - return ide_started; 841 } 842 843 /* ··· 790 return 0; 791 } 792 793 /* 794 - * Routine to send a read packet command to the drive. 795 - * This is usually called directly from cdrom_start_read. 796 * However, for drq_interrupt devices, it is called from an interrupt 797 * when the drive is ready to accept the command. 798 */ 799 - static ide_startstop_t cdrom_start_read_continuation (ide_drive_t *drive) 800 { 801 struct request *rq = HWGROUP(drive)->rq; 802 - unsigned short sectors_per_frame; 803 - int nskip; 804 805 - sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS; 806 807 - /* If the requested sector doesn't start on a cdrom block boundary, 808 - we must adjust the start of the transfer so that it does, 809 - and remember to skip the first few sectors. 810 - If the CURRENT_NR_SECTORS field is larger than the size 811 - of the buffer, it will mean that we're to skip a number 812 - of sectors equal to the amount by which CURRENT_NR_SECTORS 813 - is larger than the buffer size. */ 814 - nskip = rq->sector & (sectors_per_frame - 1); 815 - if (nskip > 0) { 816 - /* Sanity check... */ 817 - if (rq->current_nr_sectors != bio_cur_sectors(rq->bio) && 818 - (rq->sector & (sectors_per_frame - 1))) { 819 - printk(KERN_ERR "%s: cdrom_start_read_continuation: buffer botch (%u)\n", 820 - drive->name, rq->current_nr_sectors); 821 - cdrom_end_request(drive, 0); 822 - return ide_stopped; 823 } 824 - rq->current_nr_sectors += nskip; 825 } 826 - 827 /* Set up the command */ 828 rq->timeout = ATAPI_WAIT_PC; 829 830 /* Send the command to the drive and return. */ 831 - return cdrom_transfer_packet_command(drive, rq, &cdrom_read_intr); 832 } 833 - 834 835 #define IDECD_SEEK_THRESHOLD (1000) /* 1000 blocks */ 836 #define IDECD_SEEK_TIMER (5 * WAIT_MIN_SLEEP) /* 100 ms */ ··· 854 855 if (cdrom_decode_status(drive, 0, &stat)) 856 return ide_stopped; 857 - CDROM_CONFIG_FLAGS(drive)->seeking = 1; 858 859 if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) { 860 if (--retry == 0) { ··· 911 rq->q->prep_rq_fn(rq->q, rq); 912 } 913 914 - /* 915 - * Start a read request from the CD-ROM. 916 - */ 917 - static ide_startstop_t cdrom_start_read (ide_drive_t *drive, unsigned int block) 918 - { 919 - struct cdrom_info *info = drive->driver_data; 920 - struct request *rq = HWGROUP(drive)->rq; 921 - unsigned short sectors_per_frame; 922 - 923 - sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS; 924 - 925 - /* We may be retrying this request after an error. Fix up 926 - any weirdness which might be present in the request packet. */ 927 - restore_request(rq); 928 - 929 - /* Satisfy whatever we can of this request from our cached sector. */ 930 - if (cdrom_read_from_buffer(drive)) 931 - return ide_stopped; 932 - 933 - /* Clear the local sector buffer. */ 934 - info->nsectors_buffered = 0; 935 - 936 - /* use dma, if possible. */ 937 - info->dma = drive->using_dma; 938 - if ((rq->sector & (sectors_per_frame - 1)) || 939 - (rq->nr_sectors & (sectors_per_frame - 1))) 940 - info->dma = 0; 941 - 942 - /* Start sending the read request to the drive. */ 943 - return cdrom_start_packet_command(drive, 32768, cdrom_start_read_continuation); 944 - } 945 - 946 /**************************************************************************** 947 * Execute all other packet commands. 948 */ 949 950 - /* Interrupt routine for packet command completion. */ 951 - static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive) 952 { 953 - int ireason, len, thislen; 954 - struct request *rq = HWGROUP(drive)->rq; 955 - u8 lowcyl = 0, highcyl = 0; 956 - int stat; 957 - 958 - /* Check for errors. */ 959 - if (cdrom_decode_status(drive, 0, &stat)) 960 - return ide_stopped; 961 - 962 - /* Read the interrupt reason and the transfer length. */ 963 - ireason = HWIF(drive)->INB(IDE_IREASON_REG) & 0x3; 964 - lowcyl = HWIF(drive)->INB(IDE_BCOUNTL_REG); 965 - highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG); 966 - 967 - len = lowcyl + (256 * highcyl); 968 - 969 - /* If DRQ is clear, the command has completed. 970 - Complain if we still have data left to transfer. */ 971 - if ((stat & DRQ_STAT) == 0) { 972 - /* Some of the trailing request sense fields are optional, and 973 - some drives don't send them. Sigh. */ 974 - if (rq->cmd[0] == GPCMD_REQUEST_SENSE && 975 - rq->data_len > 0 && 976 - rq->data_len <= 5) { 977 - while (rq->data_len > 0) { 978 - *(unsigned char *)rq->data++ = 0; 979 - --rq->data_len; 980 - } 981 } 982 - 983 - if (rq->data_len == 0) 984 - cdrom_end_request(drive, 1); 985 - else { 986 - /* Comment this out, because this always happens 987 - right after a reset occurs, and it is annoying to 988 - always print expected stuff. */ 989 - /* 990 - printk ("%s: cdrom_pc_intr: data underrun %d\n", 991 - drive->name, pc->buflen); 992 - */ 993 - rq->cmd_flags |= REQ_FAILED; 994 - cdrom_end_request(drive, 0); 995 - } 996 - return ide_stopped; 997 - } 998 - 999 - /* Figure out how much data to transfer. */ 1000 - thislen = rq->data_len; 1001 - if (thislen > len) thislen = len; 1002 - 1003 - /* The drive wants to be written to. */ 1004 - if (ireason == 0) { 1005 - if (!rq->data) { 1006 - blk_dump_rq_flags(rq, "cdrom_pc_intr, write"); 1007 - goto confused; 1008 - } 1009 - /* Transfer the data. */ 1010 - HWIF(drive)->atapi_output_bytes(drive, rq->data, thislen); 1011 - 1012 - /* If we haven't moved enough data to satisfy the drive, 1013 - add some padding. */ 1014 - while (len > thislen) { 1015 - int dum = 0; 1016 - HWIF(drive)->atapi_output_bytes(drive, &dum, sizeof(dum)); 1017 - len -= sizeof(dum); 1018 - } 1019 - 1020 - /* Keep count of how much data we've moved. */ 1021 - rq->data += thislen; 1022 - rq->data_len -= thislen; 1023 - } 1024 - 1025 - /* Same drill for reading. */ 1026 - else if (ireason == 2) { 1027 - if (!rq->data) { 1028 - blk_dump_rq_flags(rq, "cdrom_pc_intr, read"); 1029 - goto confused; 1030 - } 1031 - /* Transfer the data. */ 1032 - HWIF(drive)->atapi_input_bytes(drive, rq->data, thislen); 1033 - 1034 - /* If we haven't moved enough data to satisfy the drive, 1035 - add some padding. */ 1036 - while (len > thislen) { 1037 - int dum = 0; 1038 - HWIF(drive)->atapi_input_bytes(drive, &dum, sizeof(dum)); 1039 - len -= sizeof(dum); 1040 - } 1041 - 1042 - /* Keep count of how much data we've moved. */ 1043 - rq->data += thislen; 1044 - rq->data_len -= thislen; 1045 - 1046 - if (blk_sense_request(rq)) 1047 - rq->sense_len += thislen; 1048 - } else { 1049 - confused: 1050 - printk (KERN_ERR "%s: cdrom_pc_intr: The drive " 1051 - "appears confused (ireason = 0x%02x). " 1052 - "Trying to recover by ending request.\n", 1053 - drive->name, ireason); 1054 - rq->cmd_flags |= REQ_FAILED; 1055 - cdrom_end_request(drive, 0); 1056 - return ide_stopped; 1057 - } 1058 - 1059 - /* Now we wait for another interrupt. */ 1060 - ide_set_handler(drive, &cdrom_pc_intr, ATAPI_WAIT_PC, cdrom_timer_expiry); 1061 - return ide_started; 1062 } 1063 1064 - static ide_startstop_t cdrom_do_pc_continuation (ide_drive_t *drive) 1065 - { 1066 - struct request *rq = HWGROUP(drive)->rq; 1067 - 1068 - if (!rq->timeout) 1069 - rq->timeout = ATAPI_WAIT_PC; 1070 - 1071 - /* Send the command to the drive and return. */ 1072 - return cdrom_transfer_packet_command(drive, rq, &cdrom_pc_intr); 1073 - } 1074 - 1075 - 1076 - static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive) 1077 - { 1078 - int len; 1079 - struct request *rq = HWGROUP(drive)->rq; 1080 - struct cdrom_info *info = drive->driver_data; 1081 - 1082 - info->dma = 0; 1083 - rq->cmd_flags &= ~REQ_FAILED; 1084 - len = rq->data_len; 1085 - 1086 - /* Start sending the command to the drive. */ 1087 - return cdrom_start_packet_command(drive, len, cdrom_do_pc_continuation); 1088 - } 1089 - 1090 - 1091 - static int cdrom_queue_packet_command(ide_drive_t *drive, struct request *rq) 1092 { 1093 struct request_sense sense; 1094 int retries = 10; ··· 978 } 979 980 /* 981 - * Write handling 982 - */ 983 - static int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ireason) 984 - { 985 - /* Two notes about IDE interrupt reason here - 0 means that 986 - * the drive wants to receive data from us, 2 means that 987 - * the drive is expecting to transfer data to us. 988 - */ 989 - if (ireason == 0) 990 - return 0; 991 - else if (ireason == 2) { 992 - /* Whoops... The drive wants to send data. */ 993 - printk(KERN_ERR "%s: %s: wrong transfer direction!\n", 994 - drive->name, __FUNCTION__); 995 - 996 - while (len > 0) { 997 - int dum = 0; 998 - HWIF(drive)->atapi_input_bytes(drive, &dum, sizeof(dum)); 999 - len -= sizeof(dum); 1000 - } 1001 - } else { 1002 - /* Drive wants a command packet, or invalid ireason... */ 1003 - printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n", 1004 - drive->name, __FUNCTION__, ireason); 1005 - } 1006 - 1007 - cdrom_end_request(drive, 0); 1008 - return 1; 1009 - } 1010 - 1011 - /* 1012 * Called from blk_end_request_callback() after the data of the request 1013 * is completed and before the request is completed. 1014 * By returning value '1', blk_end_request_callback() returns immediately ··· 988 return 1; 989 } 990 991 - typedef void (xfer_func_t)(ide_drive_t *, void *, u32); 992 - 993 - /* 994 - * best way to deal with dma that is not sector aligned right now... note 995 - * that in this path we are not using ->data or ->buffer at all. this irs 996 - * can replace cdrom_pc_intr, cdrom_read_intr, and cdrom_write_intr in the 997 - * future. 998 - */ 999 static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) 1000 { 1001 struct cdrom_info *info = drive->driver_data; 1002 struct request *rq = HWGROUP(drive)->rq; 1003 - int dma_error, dma, stat, ireason, len, thislen; 1004 - u8 lowcyl, highcyl; 1005 xfer_func_t *xferfunc; 1006 - unsigned long flags; 1007 1008 /* Check for errors. */ 1009 - dma_error = 0; 1010 dma = info->dma; 1011 if (dma) { 1012 info->dma = 0; 1013 dma_error = HWIF(drive)->ide_dma_end(drive); 1014 - } 1015 - 1016 - if (cdrom_decode_status(drive, 0, &stat)) 1017 - return ide_stopped; 1018 - 1019 - /* 1020 - * using dma, transfer is complete now 1021 - */ 1022 - if (dma) { 1023 if (dma_error) { 1024 - printk(KERN_ERR "ide-cd: dma error\n"); 1025 - ide_dma_off(drive); 1026 - return ide_error(drive, "dma error", stat); 1027 - } 1028 - 1029 - spin_lock_irqsave(&ide_lock, flags); 1030 - if (__blk_end_request(rq, 0, rq->data_len)) 1031 - BUG(); 1032 - HWGROUP(drive)->rq = NULL; 1033 - spin_unlock_irqrestore(&ide_lock, flags); 1034 - 1035 - return ide_stopped; 1036 - } 1037 - 1038 - /* 1039 - * ok we fall to pio :/ 1040 - */ 1041 - ireason = HWIF(drive)->INB(IDE_IREASON_REG) & 0x3; 1042 - lowcyl = HWIF(drive)->INB(IDE_BCOUNTL_REG); 1043 - highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG); 1044 - 1045 - len = lowcyl + (256 * highcyl); 1046 - thislen = rq->data_len; 1047 - if (thislen > len) 1048 - thislen = len; 1049 - 1050 - /* 1051 - * If DRQ is clear, the command has completed. 1052 - */ 1053 - if ((stat & DRQ_STAT) == 0) { 1054 - spin_lock_irqsave(&ide_lock, flags); 1055 - if (__blk_end_request(rq, 0, rq->data_len)) 1056 - BUG(); 1057 - HWGROUP(drive)->rq = NULL; 1058 - spin_unlock_irqrestore(&ide_lock, flags); 1059 - 1060 - return ide_stopped; 1061 - } 1062 - 1063 - /* 1064 - * check which way to transfer data 1065 - */ 1066 - if (rq_data_dir(rq) == WRITE) { 1067 - /* 1068 - * write to drive 1069 - */ 1070 - if (cdrom_write_check_ireason(drive, len, ireason)) 1071 - return ide_stopped; 1072 - 1073 - xferfunc = HWIF(drive)->atapi_output_bytes; 1074 - } else { 1075 - /* 1076 - * read from drive 1077 - */ 1078 - if (cdrom_read_check_ireason(drive, len, ireason)) 1079 - return ide_stopped; 1080 - 1081 - xferfunc = HWIF(drive)->atapi_input_bytes; 1082 - } 1083 - 1084 - /* 1085 - * transfer data 1086 - */ 1087 - while (thislen > 0) { 1088 - int blen = blen = rq->data_len; 1089 - char *ptr = rq->data; 1090 - 1091 - /* 1092 - * bio backed? 1093 - */ 1094 - if (rq->bio) { 1095 - ptr = bio_data(rq->bio); 1096 - blen = bio_iovec(rq->bio)->bv_len; 1097 - } 1098 - 1099 - if (!ptr) { 1100 - printk(KERN_ERR "%s: confused, missing data\n", drive->name); 1101 - break; 1102 - } 1103 - 1104 - if (blen > thislen) 1105 - blen = thislen; 1106 - 1107 - xferfunc(drive, ptr, blen); 1108 - 1109 - thislen -= blen; 1110 - len -= blen; 1111 - rq->data_len -= blen; 1112 - 1113 - if (rq->bio) 1114 - /* 1115 - * The request can't be completed until DRQ is cleared. 1116 - * So complete the data, but don't complete the request 1117 - * using the dummy function for the callback feature 1118 - * of blk_end_request_callback(). 1119 - */ 1120 - blk_end_request_callback(rq, 0, blen, 1121 - cdrom_newpc_intr_dummy_cb); 1122 - else 1123 - rq->data += blen; 1124 - } 1125 - 1126 - /* 1127 - * pad, if necessary 1128 - */ 1129 - if (len > 0) { 1130 - while (len > 0) { 1131 - int pad = 0; 1132 - 1133 - xferfunc(drive, &pad, sizeof(pad)); 1134 - len -= sizeof(pad); 1135 - } 1136 - } 1137 - 1138 - BUG_ON(HWGROUP(drive)->handler != NULL); 1139 - 1140 - ide_set_handler(drive, cdrom_newpc_intr, rq->timeout, NULL); 1141 - return ide_started; 1142 - } 1143 - 1144 - static ide_startstop_t cdrom_write_intr(ide_drive_t *drive) 1145 - { 1146 - int stat, ireason, len, sectors_to_transfer, uptodate; 1147 - struct cdrom_info *info = drive->driver_data; 1148 - int dma_error = 0, dma = info->dma; 1149 - u8 lowcyl = 0, highcyl = 0; 1150 - 1151 - struct request *rq = HWGROUP(drive)->rq; 1152 - 1153 - /* Check for errors. */ 1154 - if (dma) { 1155 - info->dma = 0; 1156 - dma_error = HWIF(drive)->ide_dma_end(drive); 1157 - if (dma_error) { 1158 - printk(KERN_ERR "%s: DMA write error\n", drive->name); 1159 ide_dma_off(drive); 1160 } 1161 } ··· 1020 if (dma) { 1021 if (dma_error) 1022 return ide_error(drive, "dma error", stat); 1023 - 1024 - ide_end_request(drive, 1, rq->nr_sectors); 1025 - return ide_stopped; 1026 } 1027 1028 - /* Read the interrupt reason and the transfer length. */ 1029 ireason = HWIF(drive)->INB(IDE_IREASON_REG) & 0x3; 1030 lowcyl = HWIF(drive)->INB(IDE_BCOUNTL_REG); 1031 highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG); 1032 1033 len = lowcyl + (256 * highcyl); 1034 1035 - /* If DRQ is clear, the command has completed. */ 1036 - if ((stat & DRQ_STAT) == 0) { 1037 - /* If we're not done writing, complain. 1038 - * Otherwise, complete the command normally. 1039 - */ 1040 - uptodate = 1; 1041 - if (rq->current_nr_sectors > 0) { 1042 - printk(KERN_ERR "%s: %s: data underrun (%d blocks)\n", 1043 - drive->name, __FUNCTION__, 1044 - rq->current_nr_sectors); 1045 - uptodate = 0; 1046 - } 1047 - cdrom_end_request(drive, uptodate); 1048 - return ide_stopped; 1049 - } 1050 - 1051 - /* Check that the drive is expecting to do the same thing we are. */ 1052 - if (cdrom_write_check_ireason(drive, len, ireason)) 1053 - return ide_stopped; 1054 - 1055 - sectors_to_transfer = len / SECTOR_SIZE; 1056 1057 /* 1058 - * now loop and write out the data 1059 */ 1060 - while (sectors_to_transfer > 0) { 1061 - int this_transfer; 1062 1063 - if (!rq->current_nr_sectors) { 1064 - printk(KERN_ERR "%s: %s: confused, missing data\n", 1065 - drive->name, __FUNCTION__); 1066 break; 1067 } 1068 1069 - /* 1070 - * Figure out how many sectors we can transfer 1071 - */ 1072 - this_transfer = min_t(int, sectors_to_transfer, rq->current_nr_sectors); 1073 1074 - while (this_transfer > 0) { 1075 - HWIF(drive)->atapi_output_bytes(drive, rq->buffer, SECTOR_SIZE); 1076 - rq->buffer += SECTOR_SIZE; 1077 - --rq->nr_sectors; 1078 - --rq->current_nr_sectors; 1079 - ++rq->sector; 1080 - --this_transfer; 1081 - --sectors_to_transfer; 1082 } 1083 - 1084 - /* 1085 - * current buffer complete, move on 1086 - */ 1087 - if (rq->current_nr_sectors == 0 && rq->nr_sectors) 1088 - cdrom_end_request(drive, 1); 1089 } 1090 1091 - /* re-arm handler */ 1092 - ide_set_handler(drive, &cdrom_write_intr, ATAPI_WAIT_PC, NULL); 1093 - return ide_started; 1094 - } 1095 - 1096 - static ide_startstop_t cdrom_start_write_cont(ide_drive_t *drive) 1097 - { 1098 - struct request *rq = HWGROUP(drive)->rq; 1099 - 1100 - #if 0 /* the immediate bit */ 1101 - rq->cmd[1] = 1 << 3; 1102 - #endif 1103 - rq->timeout = ATAPI_WAIT_PC; 1104 - 1105 - return cdrom_transfer_packet_command(drive, rq, cdrom_write_intr); 1106 - } 1107 - 1108 - static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq) 1109 - { 1110 - struct cdrom_info *info = drive->driver_data; 1111 - struct gendisk *g = info->disk; 1112 - unsigned short sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS; 1113 1114 /* 1115 - * writes *must* be hardware frame aligned 1116 */ 1117 if ((rq->nr_sectors & (sectors_per_frame - 1)) || 1118 (rq->sector & (sectors_per_frame - 1))) { 1119 - cdrom_end_request(drive, 0); 1120 - return ide_stopped; 1121 - } 1122 1123 - /* 1124 - * disk has become write protected 1125 - */ 1126 - if (g->policy) { 1127 - cdrom_end_request(drive, 0); 1128 - return ide_stopped; 1129 - } 1130 1131 - info->nsectors_buffered = 0; 1132 1133 - /* use dma, if possible. we don't need to check more, since we 1134 - * know that the transfer is always (at least!) frame aligned */ 1135 - info->dma = drive->using_dma ? 1 : 0; 1136 - 1137 - info->devinfo.media_written = 1; 1138 - 1139 - /* Start sending the write request to the drive. */ 1140 - return cdrom_start_packet_command(drive, 32768, cdrom_start_write_cont); 1141 } 1142 1143 static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive) ··· 1286 { 1287 struct cdrom_info *info = drive->driver_data; 1288 1289 - rq->cmd_flags |= REQ_QUIET; 1290 1291 info->dma = 0; 1292 ··· 1326 struct cdrom_info *info = drive->driver_data; 1327 1328 if (blk_fs_request(rq)) { 1329 - if (CDROM_CONFIG_FLAGS(drive)->seeking) { 1330 unsigned long elapsed = jiffies - info->start_seek; 1331 int stat = HWIF(drive)->INB(IDE_STATUS_REG); 1332 ··· 1337 } 1338 printk (KERN_ERR "%s: DSC timeout\n", drive->name); 1339 } 1340 - CDROM_CONFIG_FLAGS(drive)->seeking = 0; 1341 } 1342 if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) { 1343 action = cdrom_start_seek(drive, block); 1344 - } else { 1345 - if (rq_data_dir(rq) == READ) 1346 - action = cdrom_start_read(drive, block); 1347 - else 1348 - action = cdrom_start_write(drive, rq); 1349 - } 1350 info->last_block = block; 1351 return action; 1352 - } else if (rq->cmd_type == REQ_TYPE_SENSE || 1353 rq->cmd_type == REQ_TYPE_ATA_PC) { 1354 - return cdrom_do_packet_command(drive); 1355 - } else if (blk_pc_request(rq)) { 1356 return cdrom_do_block_pc(drive, rq); 1357 } else if (blk_special_request(rq)) { 1358 /* ··· 1373 * can also be NULL, in which case no sense information is returned. 1374 */ 1375 1376 - #if ! STANDARD_ATAPI 1377 - static inline 1378 - int bin2bcd (int x) 1379 - { 1380 - return (x%10) | ((x/10) << 4); 1381 - } 1382 - 1383 - 1384 - static inline 1385 - int bcd2bin (int x) 1386 - { 1387 - return (x >> 4) * 10 + (x & 0x0f); 1388 - } 1389 - 1390 static 1391 void msf_from_bcd (struct atapi_msf *msf) 1392 { 1393 - msf->minute = bcd2bin (msf->minute); 1394 - msf->second = bcd2bin (msf->second); 1395 - msf->frame = bcd2bin (msf->frame); 1396 } 1397 1398 - #endif /* not STANDARD_ATAPI */ 1399 - 1400 - 1401 - static inline 1402 - void lba_to_msf (int lba, byte *m, byte *s, byte *f) 1403 - { 1404 - lba += CD_MSF_OFFSET; 1405 - lba &= 0xffffff; /* negative lbas use only 24 bits */ 1406 - *m = lba / (CD_SECS * CD_FRAMES); 1407 - lba %= (CD_SECS * CD_FRAMES); 1408 - *s = lba / CD_FRAMES; 1409 - *f = lba % CD_FRAMES; 1410 - } 1411 - 1412 - 1413 - static inline 1414 - int msf_to_lba (byte m, byte s, byte f) 1415 - { 1416 - return (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET; 1417 - } 1418 - 1419 - static int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) 1420 { 1421 struct request req; 1422 struct cdrom_info *info = drive->driver_data; 1423 struct cdrom_device_info *cdi = &info->devinfo; 1424 1425 - cdrom_prepare_request(drive, &req); 1426 1427 req.sense = sense; 1428 req.cmd[0] = GPCMD_TEST_UNIT_READY; 1429 req.cmd_flags |= REQ_QUIET; 1430 1431 - #if ! STANDARD_ATAPI 1432 - /* the Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to 1433 - switch CDs instead of supporting the LOAD_UNLOAD opcode */ 1434 - 1435 req.cmd[7] = cdi->sanyo_slot % 3; 1436 - #endif /* not STANDARD_ATAPI */ 1437 1438 - return cdrom_queue_packet_command(drive, &req); 1439 - } 1440 - 1441 - 1442 - /* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */ 1443 - static int 1444 - cdrom_lockdoor(ide_drive_t *drive, int lockflag, struct request_sense *sense) 1445 - { 1446 - struct request_sense my_sense; 1447 - struct request req; 1448 - int stat; 1449 - 1450 - if (sense == NULL) 1451 - sense = &my_sense; 1452 - 1453 - /* If the drive cannot lock the door, just pretend. */ 1454 - if (CDROM_CONFIG_FLAGS(drive)->no_doorlock) { 1455 - stat = 0; 1456 - } else { 1457 - cdrom_prepare_request(drive, &req); 1458 - req.sense = sense; 1459 - req.cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; 1460 - req.cmd[4] = lockflag ? 1 : 0; 1461 - stat = cdrom_queue_packet_command(drive, &req); 1462 - } 1463 - 1464 - /* If we got an illegal field error, the drive 1465 - probably cannot lock the door. */ 1466 - if (stat != 0 && 1467 - sense->sense_key == ILLEGAL_REQUEST && 1468 - (sense->asc == 0x24 || sense->asc == 0x20)) { 1469 - printk (KERN_ERR "%s: door locking not supported\n", 1470 - drive->name); 1471 - CDROM_CONFIG_FLAGS(drive)->no_doorlock = 1; 1472 - stat = 0; 1473 - } 1474 - 1475 - /* no medium, that's alright. */ 1476 - if (stat != 0 && sense->sense_key == NOT_READY && sense->asc == 0x3a) 1477 - stat = 0; 1478 - 1479 - if (stat == 0) 1480 - CDROM_STATE_FLAGS(drive)->door_locked = lockflag; 1481 - 1482 - return stat; 1483 - } 1484 - 1485 - 1486 - /* Eject the disk if EJECTFLAG is 0. 1487 - If EJECTFLAG is 1, try to reload the disk. */ 1488 - static int cdrom_eject(ide_drive_t *drive, int ejectflag, 1489 - struct request_sense *sense) 1490 - { 1491 - struct request req; 1492 - char loej = 0x02; 1493 - 1494 - if (CDROM_CONFIG_FLAGS(drive)->no_eject && !ejectflag) 1495 - return -EDRIVE_CANT_DO_THIS; 1496 - 1497 - /* reload fails on some drives, if the tray is locked */ 1498 - if (CDROM_STATE_FLAGS(drive)->door_locked && ejectflag) 1499 - return 0; 1500 - 1501 - cdrom_prepare_request(drive, &req); 1502 - 1503 - /* only tell drive to close tray if open, if it can do that */ 1504 - if (ejectflag && !CDROM_CONFIG_FLAGS(drive)->close_tray) 1505 - loej = 0; 1506 - 1507 - req.sense = sense; 1508 - req.cmd[0] = GPCMD_START_STOP_UNIT; 1509 - req.cmd[4] = loej | (ejectflag != 0); 1510 - return cdrom_queue_packet_command(drive, &req); 1511 } 1512 1513 static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, ··· 1414 int stat; 1415 struct request req; 1416 1417 - cdrom_prepare_request(drive, &req); 1418 1419 req.sense = sense; 1420 req.cmd[0] = GPCMD_READ_CDVD_CAPACITY; ··· 1422 req.data_len = sizeof(capbuf); 1423 req.cmd_flags |= REQ_QUIET; 1424 1425 - stat = cdrom_queue_packet_command(drive, &req); 1426 if (stat == 0) { 1427 *capacity = 1 + be32_to_cpu(capbuf.lba); 1428 *sectors_per_frame = ··· 1438 { 1439 struct request req; 1440 1441 - cdrom_prepare_request(drive, &req); 1442 1443 req.sense = sense; 1444 req.data = buf; ··· 1453 if (msf_flag) 1454 req.cmd[1] = 2; 1455 1456 - return cdrom_queue_packet_command(drive, &req); 1457 } 1458 1459 - 1460 /* Try to read the entire TOC for the disk into our internal buffer. */ 1461 - static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense) 1462 { 1463 int stat, ntracks, i; 1464 struct cdrom_info *info = drive->driver_data; ··· 1484 If it is, just return. */ 1485 (void) cdrom_check_status(drive, sense); 1486 1487 - if (CDROM_STATE_FLAGS(drive)->toc_valid) 1488 return 0; 1489 1490 /* Try to get the total cdrom capacity and sector size. */ ··· 1506 if (stat) 1507 return stat; 1508 1509 - #if ! STANDARD_ATAPI 1510 - if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) { 1511 - toc->hdr.first_track = bcd2bin(toc->hdr.first_track); 1512 - toc->hdr.last_track = bcd2bin(toc->hdr.last_track); 1513 } 1514 - #endif /* not STANDARD_ATAPI */ 1515 1516 ntracks = toc->hdr.last_track - toc->hdr.first_track + 1; 1517 if (ntracks <= 0) ··· 1541 (ntracks + 1) * 1542 sizeof(struct atapi_toc_entry), 1543 sense); 1544 - if (stat) { 1545 return stat; 1546 - } 1547 - #if ! STANDARD_ATAPI 1548 - if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) { 1549 - toc->hdr.first_track = bin2bcd(CDROM_LEADOUT); 1550 - toc->hdr.last_track = bin2bcd(CDROM_LEADOUT); 1551 - } else 1552 - #endif /* not STANDARD_ATAPI */ 1553 - { 1554 toc->hdr.first_track = CDROM_LEADOUT; 1555 toc->hdr.last_track = CDROM_LEADOUT; 1556 } ··· 1558 1559 toc->hdr.toc_length = ntohs (toc->hdr.toc_length); 1560 1561 - #if ! STANDARD_ATAPI 1562 - if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) { 1563 - toc->hdr.first_track = bcd2bin(toc->hdr.first_track); 1564 - toc->hdr.last_track = bcd2bin(toc->hdr.last_track); 1565 } 1566 - #endif /* not STANDARD_ATAPI */ 1567 1568 - for (i=0; i<=ntracks; i++) { 1569 - #if ! STANDARD_ATAPI 1570 - if (CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd) { 1571 - if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) 1572 - toc->ent[i].track = bcd2bin(toc->ent[i].track); 1573 msf_from_bcd(&toc->ent[i].addr.msf); 1574 } 1575 - #endif /* not STANDARD_ATAPI */ 1576 toc->ent[i].addr.lba = msf_to_lba (toc->ent[i].addr.msf.minute, 1577 toc->ent[i].addr.msf.second, 1578 toc->ent[i].addr.msf.frame); ··· 1588 toc->last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */ 1589 } 1590 1591 - #if ! STANDARD_ATAPI 1592 - if (CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd) { 1593 /* Re-read multisession information using MSF format */ 1594 stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp, 1595 sizeof(ms_tmp), sense); ··· 1600 ms_tmp.ent.addr.msf.second, 1601 ms_tmp.ent.addr.msf.frame); 1602 } 1603 - #endif /* not STANDARD_ATAPI */ 1604 1605 toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track); 1606 ··· 1612 } 1613 1614 /* Remember that we've read this stuff. */ 1615 - CDROM_STATE_FLAGS(drive)->toc_valid = 1; 1616 1617 return 0; 1618 } 1619 1620 - 1621 - static int cdrom_read_subchannel(ide_drive_t *drive, int format, char *buf, 1622 - int buflen, struct request_sense *sense) 1623 - { 1624 - struct request req; 1625 - 1626 - cdrom_prepare_request(drive, &req); 1627 - 1628 - req.sense = sense; 1629 - req.data = buf; 1630 - req.data_len = buflen; 1631 - req.cmd[0] = GPCMD_READ_SUBCHANNEL; 1632 - req.cmd[1] = 2; /* MSF addressing */ 1633 - req.cmd[2] = 0x40; /* request subQ data */ 1634 - req.cmd[3] = format; 1635 - req.cmd[7] = (buflen >> 8); 1636 - req.cmd[8] = (buflen & 0xff); 1637 - return cdrom_queue_packet_command(drive, &req); 1638 - } 1639 - 1640 - /* ATAPI cdrom drives are free to select the speed you request or any slower 1641 - rate :-( Requesting too fast a speed will _not_ produce an error. */ 1642 - static int cdrom_select_speed(ide_drive_t *drive, int speed, 1643 - struct request_sense *sense) 1644 - { 1645 - struct request req; 1646 - cdrom_prepare_request(drive, &req); 1647 - 1648 - req.sense = sense; 1649 - if (speed == 0) 1650 - speed = 0xffff; /* set to max */ 1651 - else 1652 - speed *= 177; /* Nx to kbytes/s */ 1653 - 1654 - req.cmd[0] = GPCMD_SET_SPEED; 1655 - /* Read Drive speed in kbytes/second MSB */ 1656 - req.cmd[2] = (speed >> 8) & 0xff; 1657 - /* Read Drive speed in kbytes/second LSB */ 1658 - req.cmd[3] = speed & 0xff; 1659 - if (CDROM_CONFIG_FLAGS(drive)->cd_r || 1660 - CDROM_CONFIG_FLAGS(drive)->cd_rw || 1661 - CDROM_CONFIG_FLAGS(drive)->dvd_r) { 1662 - /* Write Drive speed in kbytes/second MSB */ 1663 - req.cmd[4] = (speed >> 8) & 0xff; 1664 - /* Write Drive speed in kbytes/second LSB */ 1665 - req.cmd[5] = speed & 0xff; 1666 - } 1667 - 1668 - return cdrom_queue_packet_command(drive, &req); 1669 - } 1670 - 1671 - static int cdrom_play_audio(ide_drive_t *drive, int lba_start, int lba_end) 1672 - { 1673 - struct request_sense sense; 1674 - struct request req; 1675 - 1676 - cdrom_prepare_request(drive, &req); 1677 - 1678 - req.sense = &sense; 1679 - req.cmd[0] = GPCMD_PLAY_AUDIO_MSF; 1680 - lba_to_msf(lba_start, &req.cmd[3], &req.cmd[4], &req.cmd[5]); 1681 - lba_to_msf(lba_end-1, &req.cmd[6], &req.cmd[7], &req.cmd[8]); 1682 - 1683 - return cdrom_queue_packet_command(drive, &req); 1684 - } 1685 - 1686 - static int cdrom_get_toc_entry(ide_drive_t *drive, int track, 1687 - struct atapi_toc_entry **ent) 1688 - { 1689 - struct cdrom_info *info = drive->driver_data; 1690 - struct atapi_toc *toc = info->toc; 1691 - int ntracks; 1692 - 1693 - /* 1694 - * don't serve cached data, if the toc isn't valid 1695 - */ 1696 - if (!CDROM_STATE_FLAGS(drive)->toc_valid) 1697 - return -EINVAL; 1698 - 1699 - /* Check validity of requested track number. */ 1700 - ntracks = toc->hdr.last_track - toc->hdr.first_track + 1; 1701 - if (toc->hdr.first_track == CDROM_LEADOUT) ntracks = 0; 1702 - if (track == CDROM_LEADOUT) 1703 - *ent = &toc->ent[ntracks]; 1704 - else if (track < toc->hdr.first_track || 1705 - track > toc->hdr.last_track) 1706 - return -EINVAL; 1707 - else 1708 - *ent = &toc->ent[track - toc->hdr.first_track]; 1709 - 1710 - return 0; 1711 - } 1712 - 1713 - /* the generic packet interface to cdrom.c */ 1714 - static int ide_cdrom_packet(struct cdrom_device_info *cdi, 1715 - struct packet_command *cgc) 1716 - { 1717 - struct request req; 1718 - ide_drive_t *drive = cdi->handle; 1719 - 1720 - if (cgc->timeout <= 0) 1721 - cgc->timeout = ATAPI_WAIT_PC; 1722 - 1723 - /* here we queue the commands from the uniform CD-ROM 1724 - layer. the packet must be complete, as we do not 1725 - touch it at all. */ 1726 - cdrom_prepare_request(drive, &req); 1727 - memcpy(req.cmd, cgc->cmd, CDROM_PACKET_SIZE); 1728 - if (cgc->sense) 1729 - memset(cgc->sense, 0, sizeof(struct request_sense)); 1730 - req.data = cgc->buffer; 1731 - req.data_len = cgc->buflen; 1732 - req.timeout = cgc->timeout; 1733 - 1734 - if (cgc->quiet) 1735 - req.cmd_flags |= REQ_QUIET; 1736 - 1737 - req.sense = cgc->sense; 1738 - cgc->stat = cdrom_queue_packet_command(drive, &req); 1739 - if (!cgc->stat) 1740 - cgc->buflen -= req.data_len; 1741 - return cgc->stat; 1742 - } 1743 - 1744 - static 1745 - int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi, 1746 - unsigned int cmd, void *arg) 1747 - 1748 - { 1749 - ide_drive_t *drive = cdi->handle; 1750 - struct cdrom_info *info = drive->driver_data; 1751 - int stat; 1752 - 1753 - switch (cmd) { 1754 - /* 1755 - * emulate PLAY_AUDIO_TI command with PLAY_AUDIO_10, since 1756 - * atapi doesn't support it 1757 - */ 1758 - case CDROMPLAYTRKIND: { 1759 - unsigned long lba_start, lba_end; 1760 - struct cdrom_ti *ti = arg; 1761 - struct atapi_toc_entry *first_toc, *last_toc; 1762 - 1763 - stat = cdrom_get_toc_entry(drive, ti->cdti_trk0, &first_toc); 1764 - if (stat) 1765 - return stat; 1766 - 1767 - stat = cdrom_get_toc_entry(drive, ti->cdti_trk1, &last_toc); 1768 - if (stat) 1769 - return stat; 1770 - 1771 - if (ti->cdti_trk1 != CDROM_LEADOUT) 1772 - ++last_toc; 1773 - lba_start = first_toc->addr.lba; 1774 - lba_end = last_toc->addr.lba; 1775 - 1776 - if (lba_end <= lba_start) 1777 - return -EINVAL; 1778 - 1779 - return cdrom_play_audio(drive, lba_start, lba_end); 1780 - } 1781 - 1782 - case CDROMREADTOCHDR: { 1783 - struct cdrom_tochdr *tochdr = arg; 1784 - struct atapi_toc *toc; 1785 - 1786 - /* Make sure our saved TOC is valid. */ 1787 - stat = cdrom_read_toc(drive, NULL); 1788 - if (stat) 1789 - return stat; 1790 - 1791 - toc = info->toc; 1792 - tochdr->cdth_trk0 = toc->hdr.first_track; 1793 - tochdr->cdth_trk1 = toc->hdr.last_track; 1794 - 1795 - return 0; 1796 - } 1797 - 1798 - case CDROMREADTOCENTRY: { 1799 - struct cdrom_tocentry *tocentry = arg; 1800 - struct atapi_toc_entry *toce; 1801 - 1802 - stat = cdrom_get_toc_entry(drive, tocentry->cdte_track, &toce); 1803 - if (stat) 1804 - return stat; 1805 - 1806 - tocentry->cdte_ctrl = toce->control; 1807 - tocentry->cdte_adr = toce->adr; 1808 - if (tocentry->cdte_format == CDROM_MSF) { 1809 - lba_to_msf (toce->addr.lba, 1810 - &tocentry->cdte_addr.msf.minute, 1811 - &tocentry->cdte_addr.msf.second, 1812 - &tocentry->cdte_addr.msf.frame); 1813 - } else 1814 - tocentry->cdte_addr.lba = toce->addr.lba; 1815 - 1816 - return 0; 1817 - } 1818 - 1819 - default: 1820 - return -EINVAL; 1821 - } 1822 - } 1823 - 1824 - static 1825 - int ide_cdrom_reset (struct cdrom_device_info *cdi) 1826 - { 1827 - ide_drive_t *drive = cdi->handle; 1828 - struct request_sense sense; 1829 - struct request req; 1830 - int ret; 1831 - 1832 - cdrom_prepare_request(drive, &req); 1833 - req.cmd_type = REQ_TYPE_SPECIAL; 1834 - req.cmd_flags = REQ_QUIET; 1835 - ret = ide_do_drive_cmd(drive, &req, ide_wait); 1836 - 1837 - /* 1838 - * A reset will unlock the door. If it was previously locked, 1839 - * lock it again. 1840 - */ 1841 - if (CDROM_STATE_FLAGS(drive)->door_locked) 1842 - (void) cdrom_lockdoor(drive, 1, &sense); 1843 - 1844 - return ret; 1845 - } 1846 - 1847 - 1848 - static 1849 - int ide_cdrom_tray_move (struct cdrom_device_info *cdi, int position) 1850 - { 1851 - ide_drive_t *drive = cdi->handle; 1852 - struct request_sense sense; 1853 - 1854 - if (position) { 1855 - int stat = cdrom_lockdoor(drive, 0, &sense); 1856 - if (stat) 1857 - return stat; 1858 - } 1859 - 1860 - return cdrom_eject(drive, !position, &sense); 1861 - } 1862 - 1863 - static 1864 - int ide_cdrom_lock_door (struct cdrom_device_info *cdi, int lock) 1865 - { 1866 - ide_drive_t *drive = cdi->handle; 1867 - return cdrom_lockdoor(drive, lock, NULL); 1868 - } 1869 - 1870 - static 1871 - int ide_cdrom_get_capabilities(ide_drive_t *drive, struct atapi_capabilities_page *cap) 1872 { 1873 struct cdrom_info *info = drive->driver_data; 1874 struct cdrom_device_info *cdi = &info->devinfo; 1875 struct packet_command cgc; 1876 - int stat, attempts = 3, size = sizeof(*cap); 1877 1878 - /* 1879 - * ACER50 (and others?) require the full spec length mode sense 1880 - * page capabilities size, but older drives break. 1881 - */ 1882 - if (!(!strcmp(drive->id->model, "ATAPI CD ROM DRIVE 50X MAX") || 1883 - !strcmp(drive->id->model, "WPI CDS-32X"))) 1884 - size -= sizeof(cap->pad); 1885 1886 - init_cdrom_command(&cgc, cap, size, CGC_DATA_UNKNOWN); 1887 do { /* we seem to get stat=0x01,err=0x00 the first time (??) */ 1888 stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0); 1889 if (!stat) ··· 1636 return stat; 1637 } 1638 1639 - static 1640 - void ide_cdrom_update_speed (ide_drive_t *drive, struct atapi_capabilities_page *cap) 1641 { 1642 - /* The ACER/AOpen 24X cdrom has the speed fields byte-swapped */ 1643 - if (!drive->id->model[0] && 1644 - !strncmp(drive->id->fw_rev, "241N", 4)) { 1645 - CDROM_STATE_FLAGS(drive)->current_speed = 1646 - (le16_to_cpu(cap->curspeed) + (176/2)) / 176; 1647 - CDROM_CONFIG_FLAGS(drive)->max_speed = 1648 - (le16_to_cpu(cap->maxspeed) + (176/2)) / 176; 1649 } else { 1650 - CDROM_STATE_FLAGS(drive)->current_speed = 1651 - (be16_to_cpu(cap->curspeed) + (176/2)) / 176; 1652 - CDROM_CONFIG_FLAGS(drive)->max_speed = 1653 - (be16_to_cpu(cap->maxspeed) + (176/2)) / 176; 1654 - } 1655 - } 1656 - 1657 - static 1658 - int ide_cdrom_select_speed (struct cdrom_device_info *cdi, int speed) 1659 - { 1660 - ide_drive_t *drive = cdi->handle; 1661 - struct request_sense sense; 1662 - struct atapi_capabilities_page cap; 1663 - int stat; 1664 - 1665 - if ((stat = cdrom_select_speed(drive, speed, &sense)) < 0) 1666 - return stat; 1667 - 1668 - if (!ide_cdrom_get_capabilities(drive, &cap)) { 1669 - ide_cdrom_update_speed(drive, &cap); 1670 - cdi->speed = CDROM_STATE_FLAGS(drive)->current_speed; 1671 - } 1672 - return 0; 1673 - } 1674 - 1675 - /* 1676 - * add logic to try GET_EVENT command first to check for media and tray 1677 - * status. this should be supported by newer cd-r/w and all DVD etc 1678 - * drives 1679 - */ 1680 - static 1681 - int ide_cdrom_drive_status (struct cdrom_device_info *cdi, int slot_nr) 1682 - { 1683 - ide_drive_t *drive = cdi->handle; 1684 - struct media_event_desc med; 1685 - struct request_sense sense; 1686 - int stat; 1687 - 1688 - if (slot_nr != CDSL_CURRENT) 1689 - return -EINVAL; 1690 - 1691 - stat = cdrom_check_status(drive, &sense); 1692 - if (!stat || sense.sense_key == UNIT_ATTENTION) 1693 - return CDS_DISC_OK; 1694 - 1695 - if (!cdrom_get_media_event(cdi, &med)) { 1696 - if (med.media_present) 1697 - return CDS_DISC_OK; 1698 - else if (med.door_open) 1699 - return CDS_TRAY_OPEN; 1700 - else 1701 - return CDS_NO_DISC; 1702 } 1703 1704 - if (sense.sense_key == NOT_READY && sense.asc == 0x04 && sense.ascq == 0x04) 1705 - return CDS_DISC_OK; 1706 - 1707 - /* 1708 - * If not using Mt Fuji extended media tray reports, 1709 - * just return TRAY_OPEN since ATAPI doesn't provide 1710 - * any other way to detect this... 1711 - */ 1712 - if (sense.sense_key == NOT_READY) { 1713 - if (sense.asc == 0x3a && sense.ascq == 1) 1714 - return CDS_NO_DISC; 1715 - else 1716 - return CDS_TRAY_OPEN; 1717 - } 1718 - return CDS_DRIVE_NOT_READY; 1719 } 1720 1721 - static 1722 - int ide_cdrom_get_last_session (struct cdrom_device_info *cdi, 1723 - struct cdrom_multisession *ms_info) 1724 - { 1725 - struct atapi_toc *toc; 1726 - ide_drive_t *drive = cdi->handle; 1727 - struct cdrom_info *info = drive->driver_data; 1728 - struct request_sense sense; 1729 - int ret; 1730 1731 - if (!CDROM_STATE_FLAGS(drive)->toc_valid || info->toc == NULL) 1732 - if ((ret = cdrom_read_toc(drive, &sense))) 1733 - return ret; 1734 - 1735 - toc = info->toc; 1736 - ms_info->addr.lba = toc->last_session_lba; 1737 - ms_info->xa_flag = toc->xa_flag; 1738 - 1739 - return 0; 1740 - } 1741 - 1742 - static 1743 - int ide_cdrom_get_mcn (struct cdrom_device_info *cdi, 1744 - struct cdrom_mcn *mcn_info) 1745 - { 1746 - int stat; 1747 - char mcnbuf[24]; 1748 - ide_drive_t *drive = cdi->handle; 1749 - 1750 - /* get MCN */ 1751 - if ((stat = cdrom_read_subchannel(drive, 2, mcnbuf, sizeof (mcnbuf), NULL))) 1752 - return stat; 1753 - 1754 - memcpy (mcn_info->medium_catalog_number, mcnbuf+9, 1755 - sizeof (mcn_info->medium_catalog_number)-1); 1756 - mcn_info->medium_catalog_number[sizeof (mcn_info->medium_catalog_number)-1] 1757 - = '\0'; 1758 - 1759 - return 0; 1760 - } 1761 - 1762 - 1763 - 1764 - /**************************************************************************** 1765 - * Other driver requests (open, close, check media change). 1766 - */ 1767 - 1768 - static 1769 - int ide_cdrom_check_media_change_real (struct cdrom_device_info *cdi, 1770 - int slot_nr) 1771 - { 1772 - ide_drive_t *drive = cdi->handle; 1773 - int retval; 1774 - 1775 - if (slot_nr == CDSL_CURRENT) { 1776 - (void) cdrom_check_status(drive, NULL); 1777 - retval = CDROM_STATE_FLAGS(drive)->media_changed; 1778 - CDROM_STATE_FLAGS(drive)->media_changed = 0; 1779 - return retval; 1780 - } else { 1781 - return -EINVAL; 1782 - } 1783 - } 1784 - 1785 - 1786 - static 1787 - int ide_cdrom_open_real (struct cdrom_device_info *cdi, int purpose) 1788 - { 1789 - return 0; 1790 - } 1791 - 1792 - /* 1793 - * Close down the device. Invalidate all cached blocks. 1794 - */ 1795 - 1796 - static 1797 - void ide_cdrom_release_real (struct cdrom_device_info *cdi) 1798 - { 1799 - ide_drive_t *drive = cdi->handle; 1800 - 1801 - if (!cdi->use_count) 1802 - CDROM_STATE_FLAGS(drive)->toc_valid = 0; 1803 - } 1804 - 1805 - 1806 - 1807 - /**************************************************************************** 1808 - * Device initialization. 1809 - */ 1810 static struct cdrom_device_ops ide_cdrom_dops = { 1811 .open = ide_cdrom_open_real, 1812 .release = ide_cdrom_release_real, ··· 1675 .get_mcn = ide_cdrom_get_mcn, 1676 .reset = ide_cdrom_reset, 1677 .audio_ioctl = ide_cdrom_audio_ioctl, 1678 - .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | 1679 - CDC_SELECT_SPEED | CDC_SELECT_DISC | 1680 - CDC_MULTI_SESSION | CDC_MCN | 1681 - CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | 1682 - CDC_DRIVE_STATUS | CDC_CD_R | 1683 - CDC_CD_RW | CDC_DVD | CDC_DVD_R| CDC_DVD_RAM | 1684 - CDC_GENERIC_PACKET | CDC_MO_DRIVE | CDC_MRW | 1685 - CDC_MRW_W | CDC_RAM, 1686 .generic_packet = ide_cdrom_packet, 1687 }; 1688 ··· 1685 struct cdrom_device_info *devinfo = &info->devinfo; 1686 1687 devinfo->ops = &ide_cdrom_dops; 1688 - devinfo->mask = 0; 1689 - devinfo->speed = CDROM_STATE_FLAGS(drive)->current_speed; 1690 devinfo->capacity = nslots; 1691 devinfo->handle = drive; 1692 strcpy(devinfo->name, drive->name); 1693 - 1694 - /* set capability mask to match the probe. */ 1695 - if (!CDROM_CONFIG_FLAGS(drive)->cd_r) 1696 - devinfo->mask |= CDC_CD_R; 1697 - if (!CDROM_CONFIG_FLAGS(drive)->cd_rw) 1698 - devinfo->mask |= CDC_CD_RW; 1699 - if (!CDROM_CONFIG_FLAGS(drive)->dvd) 1700 - devinfo->mask |= CDC_DVD; 1701 - if (!CDROM_CONFIG_FLAGS(drive)->dvd_r) 1702 - devinfo->mask |= CDC_DVD_R; 1703 - if (!CDROM_CONFIG_FLAGS(drive)->dvd_ram) 1704 - devinfo->mask |= CDC_DVD_RAM; 1705 - if (!CDROM_CONFIG_FLAGS(drive)->is_changer) 1706 - devinfo->mask |= CDC_SELECT_DISC; 1707 - if (!CDROM_CONFIG_FLAGS(drive)->audio_play) 1708 - devinfo->mask |= CDC_PLAY_AUDIO; 1709 - if (!CDROM_CONFIG_FLAGS(drive)->close_tray) 1710 - devinfo->mask |= CDC_CLOSE_TRAY; 1711 - if (!CDROM_CONFIG_FLAGS(drive)->mo_drive) 1712 - devinfo->mask |= CDC_MO_DRIVE; 1713 - if (!CDROM_CONFIG_FLAGS(drive)->ram) 1714 - devinfo->mask |= CDC_RAM; 1715 1716 - if (CDROM_CONFIG_FLAGS(drive)->no_speed_select) 1717 devinfo->mask |= CDC_SELECT_SPEED; 1718 1719 devinfo->disk = info->disk; ··· 1700 static 1701 int ide_cdrom_probe_capabilities (ide_drive_t *drive) 1702 { 1703 - struct cdrom_info *info = drive->driver_data; 1704 - struct cdrom_device_info *cdi = &info->devinfo; 1705 - struct atapi_capabilities_page cap; 1706 int nslots = 1; 1707 1708 if (drive->media == ide_optical) { 1709 - CDROM_CONFIG_FLAGS(drive)->mo_drive = 1; 1710 - CDROM_CONFIG_FLAGS(drive)->ram = 1; 1711 printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", drive->name); 1712 return nslots; 1713 } 1714 1715 - if (CDROM_CONFIG_FLAGS(drive)->nec260 || 1716 - !strcmp(drive->id->model,"STINGRAY 8422 IDE 8X CD-ROM 7-27-95")) { 1717 - CDROM_CONFIG_FLAGS(drive)->no_eject = 0; 1718 - CDROM_CONFIG_FLAGS(drive)->audio_play = 1; 1719 return nslots; 1720 } 1721 ··· 1732 cdi->handle = drive; 1733 cdi->ops = &ide_cdrom_dops; 1734 1735 - if (ide_cdrom_get_capabilities(drive, &cap)) 1736 return 0; 1737 1738 - if (cap.lock == 0) 1739 - CDROM_CONFIG_FLAGS(drive)->no_doorlock = 1; 1740 - if (cap.eject) 1741 - CDROM_CONFIG_FLAGS(drive)->no_eject = 0; 1742 - if (cap.cd_r_write) 1743 - CDROM_CONFIG_FLAGS(drive)->cd_r = 1; 1744 - if (cap.cd_rw_write) { 1745 - CDROM_CONFIG_FLAGS(drive)->cd_rw = 1; 1746 - CDROM_CONFIG_FLAGS(drive)->ram = 1; 1747 - } 1748 - if (cap.test_write) 1749 - CDROM_CONFIG_FLAGS(drive)->test_write = 1; 1750 - if (cap.dvd_ram_read || cap.dvd_r_read || cap.dvd_rom) 1751 - CDROM_CONFIG_FLAGS(drive)->dvd = 1; 1752 - if (cap.dvd_ram_write) { 1753 - CDROM_CONFIG_FLAGS(drive)->dvd_ram = 1; 1754 - CDROM_CONFIG_FLAGS(drive)->ram = 1; 1755 - } 1756 - if (cap.dvd_r_write) 1757 - CDROM_CONFIG_FLAGS(drive)->dvd_r = 1; 1758 - if (cap.audio_play) 1759 - CDROM_CONFIG_FLAGS(drive)->audio_play = 1; 1760 - if (cap.mechtype == mechtype_caddy || cap.mechtype == mechtype_popup) 1761 - CDROM_CONFIG_FLAGS(drive)->close_tray = 0; 1762 1763 - /* Some drives used by Apple don't advertise audio play 1764 - * but they do support reading TOC & audio datas 1765 - */ 1766 - if (strcmp(drive->id->model, "MATSHITADVD-ROM SR-8187") == 0 || 1767 - strcmp(drive->id->model, "MATSHITADVD-ROM SR-8186") == 0 || 1768 - strcmp(drive->id->model, "MATSHITADVD-ROM SR-8176") == 0 || 1769 - strcmp(drive->id->model, "MATSHITADVD-ROM SR-8174") == 0) 1770 - CDROM_CONFIG_FLAGS(drive)->audio_play = 1; 1771 1772 - #if ! STANDARD_ATAPI 1773 if (cdi->sanyo_slot > 0) { 1774 - CDROM_CONFIG_FLAGS(drive)->is_changer = 1; 1775 nslots = 3; 1776 } 1777 1778 - else 1779 - #endif /* not STANDARD_ATAPI */ 1780 - if (cap.mechtype == mechtype_individual_changer || 1781 - cap.mechtype == mechtype_cartridge_changer) { 1782 - if ((nslots = cdrom_number_of_slots(cdi)) > 1) { 1783 - CDROM_CONFIG_FLAGS(drive)->is_changer = 1; 1784 - CDROM_CONFIG_FLAGS(drive)->supp_disc_present = 1; 1785 - } 1786 - } 1787 1788 - ide_cdrom_update_speed(drive, &cap); 1789 - /* don't print speed if the drive reported 0. 1790 - */ 1791 printk(KERN_INFO "%s: ATAPI", drive->name); 1792 - if (CDROM_CONFIG_FLAGS(drive)->max_speed) 1793 - printk(" %dX", CDROM_CONFIG_FLAGS(drive)->max_speed); 1794 - printk(" %s", CDROM_CONFIG_FLAGS(drive)->dvd ? "DVD-ROM" : "CD-ROM"); 1795 1796 - if (CDROM_CONFIG_FLAGS(drive)->dvd_r|CDROM_CONFIG_FLAGS(drive)->dvd_ram) 1797 - printk(" DVD%s%s", 1798 - (CDROM_CONFIG_FLAGS(drive)->dvd_r)? "-R" : "", 1799 - (CDROM_CONFIG_FLAGS(drive)->dvd_ram)? "-RAM" : ""); 1800 1801 - if (CDROM_CONFIG_FLAGS(drive)->cd_r|CDROM_CONFIG_FLAGS(drive)->cd_rw) 1802 - printk(" CD%s%s", 1803 - (CDROM_CONFIG_FLAGS(drive)->cd_r)? "-R" : "", 1804 - (CDROM_CONFIG_FLAGS(drive)->cd_rw)? "/RW" : ""); 1805 1806 - if (CDROM_CONFIG_FLAGS(drive)->is_changer) 1807 - printk(" changer w/%d slots", nslots); 1808 - else 1809 - printk(" drive"); 1810 1811 - printk(KERN_CONT ", %dkB Cache\n", be16_to_cpu(cap.buffer_size)); 1812 1813 return nslots; 1814 } ··· 1884 return 0; 1885 } 1886 1887 static 1888 int ide_cdrom_setup (ide_drive_t *drive) 1889 { 1890 - struct cdrom_info *info = drive->driver_data; 1891 - struct cdrom_device_info *cdi = &info->devinfo; 1892 int nslots; 1893 1894 blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn); ··· 1962 1963 drive->special.all = 0; 1964 1965 - CDROM_STATE_FLAGS(drive)->media_changed = 1; 1966 - CDROM_STATE_FLAGS(drive)->toc_valid = 0; 1967 - CDROM_STATE_FLAGS(drive)->door_locked = 0; 1968 1969 - #if NO_DOOR_LOCKING 1970 - CDROM_CONFIG_FLAGS(drive)->no_doorlock = 1; 1971 - #else 1972 - CDROM_CONFIG_FLAGS(drive)->no_doorlock = 0; 1973 - #endif 1974 1975 - CDROM_CONFIG_FLAGS(drive)->drq_interrupt = ((drive->id->config & 0x0060) == 0x20); 1976 - CDROM_CONFIG_FLAGS(drive)->is_changer = 0; 1977 - CDROM_CONFIG_FLAGS(drive)->cd_r = 0; 1978 - CDROM_CONFIG_FLAGS(drive)->cd_rw = 0; 1979 - CDROM_CONFIG_FLAGS(drive)->test_write = 0; 1980 - CDROM_CONFIG_FLAGS(drive)->dvd = 0; 1981 - CDROM_CONFIG_FLAGS(drive)->dvd_r = 0; 1982 - CDROM_CONFIG_FLAGS(drive)->dvd_ram = 0; 1983 - CDROM_CONFIG_FLAGS(drive)->no_eject = 1; 1984 - CDROM_CONFIG_FLAGS(drive)->supp_disc_present = 0; 1985 - CDROM_CONFIG_FLAGS(drive)->audio_play = 0; 1986 - CDROM_CONFIG_FLAGS(drive)->close_tray = 1; 1987 - 1988 - /* limit transfer size per interrupt. */ 1989 - CDROM_CONFIG_FLAGS(drive)->limit_nframes = 0; 1990 - /* a testament to the nice quality of Samsung drives... */ 1991 - if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-2430")) 1992 - CDROM_CONFIG_FLAGS(drive)->limit_nframes = 1; 1993 - else if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-2432")) 1994 - CDROM_CONFIG_FLAGS(drive)->limit_nframes = 1; 1995 - /* the 3231 model does not support the SET_CD_SPEED command */ 1996 - else if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-3231")) 1997 - CDROM_CONFIG_FLAGS(drive)->no_speed_select = 1; 1998 - 1999 - #if ! STANDARD_ATAPI 2000 - /* by default Sanyo 3 CD changer support is turned off and 2001 - ATAPI Rev 2.2+ standard support for CD changers is used */ 2002 - cdi->sanyo_slot = 0; 2003 - 2004 - CDROM_CONFIG_FLAGS(drive)->nec260 = 0; 2005 - CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd = 0; 2006 - CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd = 0; 2007 - CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 0; 2008 - CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 0; 2009 - 2010 - if (strcmp (drive->id->model, "V003S0DS") == 0 && 2011 - drive->id->fw_rev[4] == '1' && 2012 - drive->id->fw_rev[6] <= '2') { 2013 - /* Vertos 300. 2014 - Some versions of this drive like to talk BCD. */ 2015 - CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd = 1; 2016 - CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd = 1; 2017 - CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 1; 2018 - CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 1; 2019 - } 2020 - 2021 - else if (strcmp (drive->id->model, "V006E0DS") == 0 && 2022 - drive->id->fw_rev[4] == '1' && 2023 - drive->id->fw_rev[6] <= '2') { 2024 - /* Vertos 600 ESD. */ 2025 - CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd = 1; 2026 - } 2027 - else if (strcmp(drive->id->model, "NEC CD-ROM DRIVE:260") == 0 && 2028 - strncmp(drive->id->fw_rev, "1.01", 4) == 0) { /* FIXME */ 2029 - /* Old NEC260 (not R). 2030 - This drive was released before the 1.2 version 2031 - of the spec. */ 2032 - CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd = 1; 2033 - CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 1; 2034 - CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 1; 2035 - CDROM_CONFIG_FLAGS(drive)->nec260 = 1; 2036 - } 2037 - else if (strcmp(drive->id->model, "WEARNES CDD-120") == 0 && 2038 - strncmp(drive->id->fw_rev, "A1.1", 4) == 0) { /* FIXME */ 2039 - /* Wearnes */ 2040 - CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 1; 2041 - CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 1; 2042 - } 2043 - /* Sanyo 3 CD changer uses a non-standard command 2044 - for CD changing */ 2045 - else if ((strcmp(drive->id->model, "CD-ROM CDR-C3 G") == 0) || 2046 - (strcmp(drive->id->model, "CD-ROM CDR-C3G") == 0) || 2047 - (strcmp(drive->id->model, "CD-ROM CDR_C36") == 0)) { 2048 - /* uses CD in slot 0 when value is set to 3 */ 2049 - cdi->sanyo_slot = 3; 2050 - } 2051 - #endif /* not STANDARD_ATAPI */ 2052 - 2053 - info->toc = NULL; 2054 - info->buffer = NULL; 2055 - info->sector_buffered = 0; 2056 - info->nsectors_buffered = 0; 2057 - info->changer_info = NULL; 2058 - info->last_block = 0; 2059 - info->start_seek = 0; 2060 2061 nslots = ide_cdrom_probe_capabilities (drive); 2062 ··· 1991 1992 if (ide_cdrom_register(drive, nslots)) { 1993 printk (KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name); 1994 - info->devinfo.handle = NULL; 1995 return 1; 1996 } 1997 ide_cdrom_add_settings(drive); ··· 2031 2032 kfree(info->buffer); 2033 kfree(info->toc); 2034 - kfree(info->changer_info); 2035 if (devinfo->handle == drive && unregister_cdrom(devinfo)) 2036 printk(KERN_ERR "%s: %s failed to unregister device from the cdrom " 2037 "driver.\n", __FUNCTION__, drive->name); ··· 2186 { 2187 struct cdrom_info *info = ide_cd_g(disk); 2188 struct request_sense sense; 2189 - cdrom_read_toc(info->drive, &sense); 2190 return 0; 2191 } 2192 ··· 2263 goto failed; 2264 } 2265 2266 - cdrom_read_toc(drive, &sense); 2267 g->fops = &idecd_ops; 2268 g->flags |= GENHD_FL_REMOVABLE; 2269 add_disk(g); ··· 2286 } 2287 2288 MODULE_ALIAS("ide:*m-cdrom*"); 2289 module_init(ide_cdrom_init); 2290 module_exit(ide_cdrom_exit); 2291 MODULE_LICENSE("GPL");
··· 1 /* 2 + * ATAPI CD-ROM driver. 3 * 4 + * Copyright (C) 1994-1996 Scott Snyder <snyder@fnald0.fnal.gov> 5 + * Copyright (C) 1996-1998 Erik Andersen <andersee@debian.org> 6 + * Copyright (C) 1998-2000 Jens Axboe <axboe@suse.de> 7 + * Copyright (C) 2005, 2007 Bartlomiej Zolnierkiewicz 8 * 9 * May be copied or modified under the terms of the GNU General Public 10 * License. See linux/COPYING for more information. 11 * 12 * See Documentation/cdrom/ide-cd for usage information. 13 * 14 * Suggestions are welcome. Patches that work are more welcome though. ;-) ··· 19 * ftp://fission.dt.wdc.com/pub/standards/SFF_atapi/spec/SFF8020-r2.6/PS/8020r26.ps 20 * ftp://ftp.avc-pioneer.com/Mtfuji4/Spec/Fuji4r10.pdf 21 * 22 + * For historical changelog please see: 23 + * Documentation/ide/ChangeLog.ide-cd.1994-2004 24 + */ 25 + 26 + #define IDECD_VERSION "5.00" 27 28 #include <linux/module.h> 29 #include <linux/types.h> ··· 313 #include <linux/ide.h> 314 #include <linux/completion.h> 315 #include <linux/mutex.h> 316 + #include <linux/bcd.h> 317 318 #include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */ 319 ··· 360 buffers. */ 361 static void cdrom_saw_media_change (ide_drive_t *drive) 362 { 363 + struct cdrom_info *cd = drive->driver_data; 364 + 365 + cd->cd_flags |= IDE_CD_FLAG_MEDIA_CHANGED; 366 + cd->cd_flags &= ~IDE_CD_FLAG_TOC_VALID; 367 + cd->nsectors_buffered = 0; 368 } 369 370 static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, ··· 465 } 466 } 467 } 468 469 + ide_cd_log_error(drive->name, failed_command, sense); 470 } 471 472 /* 473 * Initialize a ide-cd packet command request 474 */ 475 + void ide_cd_init_rq(ide_drive_t *drive, struct request *rq) 476 { 477 struct cdrom_info *cd = drive->driver_data; 478 ··· 611 sense = &info->sense_data; 612 613 /* stuff the sense request in front of our current request */ 614 + ide_cd_init_rq(drive, rq); 615 616 rq->data = sense; 617 rq->cmd[0] = GPCMD_REQUEST_SENSE; ··· 718 719 } else if (blk_pc_request(rq) || rq->cmd_type == REQ_TYPE_ATA_PC) { 720 /* All other functions, except for READ. */ 721 722 /* 723 * if we have an error, pass back CHECK_CONDITION as the ··· 756 * remove failed request completely and end it when the 757 * request sense has completed 758 */ 759 + goto end_request; 760 761 } else if (blk_fs_request(rq)) { 762 int do_end_request = 0; ··· 844 sense data. We need this in order to perform end of media 845 processing */ 846 847 + if (do_end_request) 848 + goto end_request; 849 850 + /* 851 + * If we got a CHECK_CONDITION status, 852 + * queue a request sense command. 853 + */ 854 + if (stat & ERR_STAT) 855 + cdrom_queue_request_sense(drive, NULL, NULL); 856 } else { 857 blk_dump_rq_flags(rq, "ide-cd: bad rq"); 858 cdrom_end_request(drive, 0); 859 } 860 861 /* Retry, or handle the next request. */ 862 + return 1; 863 + 864 + end_request: 865 + if (stat & ERR_STAT) { 866 + unsigned long flags; 867 + 868 + spin_lock_irqsave(&ide_lock, flags); 869 + blkdev_dequeue_request(rq); 870 + HWGROUP(drive)->rq = NULL; 871 + spin_unlock_irqrestore(&ide_lock, flags); 872 + 873 + cdrom_queue_request_sense(drive, rq->sense, rq); 874 + } else 875 + cdrom_end_request(drive, 0); 876 + 877 return 1; 878 } 879 ··· 924 /* Set up the controller registers. */ 925 ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | 926 IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); 927 + 928 + if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { 929 /* waiting for CDB interrupt, not DMA yet. */ 930 if (info->dma) 931 drive->waiting_for_dma = 0; ··· 951 by cdrom_start_packet_command. 952 HANDLER is the interrupt handler to call when the command completes 953 or there's data ready. */ 954 #define ATAPI_MIN_CDB_BYTES 12 955 static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, 956 struct request *rq, ··· 965 struct cdrom_info *info = drive->driver_data; 966 ide_startstop_t startstop; 967 968 + if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { 969 /* Here we should have been called after receiving an interrupt 970 from the device. DRQ should how be set. */ 971 ··· 1005 * Block read functions. 1006 */ 1007 1008 + typedef void (xfer_func_t)(ide_drive_t *, void *, u32); 1009 + 1010 + static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len) 1011 + { 1012 + while (len > 0) { 1013 + int dum = 0; 1014 + xf(drive, &dum, sizeof(dum)); 1015 + len -= sizeof(dum); 1016 + } 1017 + } 1018 + 1019 + static void ide_cd_drain_data(ide_drive_t *drive, int nsects) 1020 + { 1021 + while (nsects > 0) { 1022 + static char dum[SECTOR_SIZE]; 1023 + 1024 + drive->hwif->atapi_input_bytes(drive, dum, sizeof(dum)); 1025 + nsects--; 1026 + } 1027 + } 1028 + 1029 /* 1030 * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector 1031 * buffer. Once the first sector is added, any subsequent sectors are ··· 1043 } 1044 1045 /* Throw away any remaining data. */ 1046 + ide_cd_drain_data(drive, sectors_to_transfer); 1047 } 1048 1049 /* ··· 1056 * ok; nonzero if the request has been terminated. 1057 */ 1058 static 1059 + int ide_cd_check_ireason(ide_drive_t *drive, int len, int ireason, int rw) 1060 { 1061 + /* 1062 + * ireason == 0: the drive wants to receive data from us 1063 + * ireason == 2: the drive is expecting to transfer data to us 1064 + */ 1065 + if (ireason == (!rw << 1)) 1066 return 0; 1067 + else if (ireason == (rw << 1)) { 1068 + ide_hwif_t *hwif = drive->hwif; 1069 + xfer_func_t *xf; 1070 + 1071 + /* Whoops... */ 1072 printk(KERN_ERR "%s: %s: wrong transfer direction!\n", 1073 drive->name, __FUNCTION__); 1074 1075 + xf = rw ? hwif->atapi_output_bytes : hwif->atapi_input_bytes; 1076 + ide_cd_pad_transfer(drive, xf, len); 1077 + } else if (rw == 0 && ireason == 1) { 1078 /* Some drives (ASUS) seem to tell us that status 1079 * info is available. just get it and ignore. 1080 */ ··· 1089 } 1090 1091 /* 1092 + * Assume that the drive will always provide data in multiples of at least 1093 + * SECTOR_SIZE, as it gets hairy to keep track of the transfers otherwise. 1094 */ 1095 + static int ide_cd_check_transfer_size(ide_drive_t *drive, int len) 1096 { 1097 + struct cdrom_info *cd = drive->driver_data; 1098 1099 + if ((len % SECTOR_SIZE) == 0) 1100 + return 0; 1101 1102 + printk(KERN_ERR "%s: %s: Bad transfer size %d\n", 1103 + drive->name, __FUNCTION__, len); 1104 + 1105 + if (cd->cd_flags & IDE_CD_FLAG_LIMIT_NFRAMES) 1106 + printk(KERN_ERR " This drive is not supported by " 1107 + "this version of the driver\n"); 1108 + else { 1109 + printk(KERN_ERR " Trying to limit transfer sizes\n"); 1110 + cd->cd_flags |= IDE_CD_FLAG_LIMIT_NFRAMES; 1111 } 1112 1113 + return 1; 1114 } 1115 1116 /* ··· 1281 return 0; 1282 } 1283 1284 + static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); 1285 + 1286 /* 1287 + * Routine to send a read/write packet command to the drive. 1288 + * This is usually called directly from cdrom_start_{read,write}(). 1289 * However, for drq_interrupt devices, it is called from an interrupt 1290 * when the drive is ready to accept the command. 1291 */ 1292 + static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) 1293 { 1294 struct request *rq = HWGROUP(drive)->rq; 1295 1296 + if (rq_data_dir(rq) == READ) { 1297 + unsigned short sectors_per_frame = 1298 + queue_hardsect_size(drive->queue) >> SECTOR_BITS; 1299 + int nskip = rq->sector & (sectors_per_frame - 1); 1300 1301 + /* 1302 + * If the requested sector doesn't start on a frame boundary, 1303 + * we must adjust the start of the transfer so that it does, 1304 + * and remember to skip the first few sectors. 1305 + * 1306 + * If the rq->current_nr_sectors field is larger than the size 1307 + * of the buffer, it will mean that we're to skip a number of 1308 + * sectors equal to the amount by which rq->current_nr_sectors 1309 + * is larger than the buffer size. 1310 + */ 1311 + if (nskip > 0) { 1312 + /* Sanity check... */ 1313 + if (rq->current_nr_sectors != 1314 + bio_cur_sectors(rq->bio)) { 1315 + printk(KERN_ERR "%s: %s: buffer botch (%u)\n", 1316 + drive->name, __FUNCTION__, 1317 + rq->current_nr_sectors); 1318 + cdrom_end_request(drive, 0); 1319 + return ide_stopped; 1320 + } 1321 + rq->current_nr_sectors += nskip; 1322 } 1323 } 1324 + #if 0 1325 + else 1326 + /* the immediate bit */ 1327 + rq->cmd[1] = 1 << 3; 1328 + #endif 1329 /* Set up the command */ 1330 rq->timeout = ATAPI_WAIT_PC; 1331 1332 /* Send the command to the drive and return. */ 1333 + return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); 1334 } 1335 1336 #define IDECD_SEEK_THRESHOLD (1000) /* 1000 blocks */ 1337 #define IDECD_SEEK_TIMER (5 * WAIT_MIN_SLEEP) /* 100 ms */ ··· 1335 1336 if (cdrom_decode_status(drive, 0, &stat)) 1337 return ide_stopped; 1338 + 1339 + info->cd_flags |= IDE_CD_FLAG_SEEKING; 1340 1341 if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) { 1342 if (--retry == 0) { ··· 1391 rq->q->prep_rq_fn(rq->q, rq); 1392 } 1393 1394 /**************************************************************************** 1395 * Execute all other packet commands. 1396 */ 1397 1398 + static void ide_cd_request_sense_fixup(struct request *rq) 1399 { 1400 + /* 1401 + * Some of the trailing request sense fields are optional, 1402 + * and some drives don't send them. Sigh. 1403 + */ 1404 + if (rq->cmd[0] == GPCMD_REQUEST_SENSE && 1405 + rq->data_len > 0 && rq->data_len <= 5) 1406 + while (rq->data_len > 0) { 1407 + *(u8 *)rq->data++ = 0; 1408 + --rq->data_len; 1409 } 1410 } 1411 1412 + int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) 1413 { 1414 struct request_sense sense; 1415 int retries = 10; ··· 1617 } 1618 1619 /* 1620 * Called from blk_end_request_callback() after the data of the request 1621 * is completed and before the request is completed. 1622 * By returning value '1', blk_end_request_callback() returns immediately ··· 1658 return 1; 1659 } 1660 1661 static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) 1662 { 1663 struct cdrom_info *info = drive->driver_data; 1664 struct request *rq = HWGROUP(drive)->rq; 1665 xfer_func_t *xferfunc; 1666 + ide_expiry_t *expiry = NULL; 1667 + int dma_error = 0, dma, stat, ireason, len, thislen, uptodate = 0; 1668 + int write = (rq_data_dir(rq) == WRITE) ? 1 : 0; 1669 + unsigned int timeout; 1670 + u8 lowcyl, highcyl; 1671 1672 /* Check for errors. */ 1673 dma = info->dma; 1674 if (dma) { 1675 info->dma = 0; 1676 dma_error = HWIF(drive)->ide_dma_end(drive); 1677 if (dma_error) { 1678 + printk(KERN_ERR "%s: DMA %s error\n", drive->name, 1679 + write ? "write" : "read"); 1680 ide_dma_off(drive); 1681 } 1682 } ··· 1839 if (dma) { 1840 if (dma_error) 1841 return ide_error(drive, "dma error", stat); 1842 + if (blk_fs_request(rq)) { 1843 + ide_end_request(drive, 1, rq->nr_sectors); 1844 + return ide_stopped; 1845 + } 1846 + goto end_request; 1847 } 1848 1849 + /* 1850 + * ok we fall to pio :/ 1851 + */ 1852 ireason = HWIF(drive)->INB(IDE_IREASON_REG) & 0x3; 1853 lowcyl = HWIF(drive)->INB(IDE_BCOUNTL_REG); 1854 highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG); 1855 1856 len = lowcyl + (256 * highcyl); 1857 1858 + thislen = blk_fs_request(rq) ? len : rq->data_len; 1859 + if (thislen > len) 1860 + thislen = len; 1861 1862 /* 1863 + * If DRQ is clear, the command has completed. 1864 */ 1865 + if ((stat & DRQ_STAT) == 0) { 1866 + if (blk_fs_request(rq)) { 1867 + /* 1868 + * If we're not done reading/writing, complain. 1869 + * Otherwise, complete the command normally. 1870 + */ 1871 + uptodate = 1; 1872 + if (rq->current_nr_sectors > 0) { 1873 + printk(KERN_ERR "%s: %s: data underrun " 1874 + "(%d blocks)\n", 1875 + drive->name, __FUNCTION__, 1876 + rq->current_nr_sectors); 1877 + if (!write) 1878 + rq->cmd_flags |= REQ_FAILED; 1879 + uptodate = 0; 1880 + } 1881 + cdrom_end_request(drive, uptodate); 1882 + return ide_stopped; 1883 + } else if (!blk_pc_request(rq)) { 1884 + ide_cd_request_sense_fixup(rq); 1885 + /* Complain if we still have data left to transfer. */ 1886 + uptodate = rq->data_len ? 0 : 1; 1887 + } 1888 + goto end_request; 1889 + } 1890 1891 + /* 1892 + * check which way to transfer data 1893 + */ 1894 + if (blk_fs_request(rq) || blk_pc_request(rq)) { 1895 + if (ide_cd_check_ireason(drive, len, ireason, write)) 1896 + return ide_stopped; 1897 + 1898 + if (blk_fs_request(rq) && write == 0) { 1899 + int nskip; 1900 + 1901 + if (ide_cd_check_transfer_size(drive, len)) { 1902 + cdrom_end_request(drive, 0); 1903 + return ide_stopped; 1904 + } 1905 + 1906 + /* 1907 + * First, figure out if we need to bit-bucket 1908 + * any of the leading sectors. 1909 + */ 1910 + nskip = min_t(int, rq->current_nr_sectors 1911 + - bio_cur_sectors(rq->bio), 1912 + thislen >> 9); 1913 + if (nskip > 0) { 1914 + ide_cd_drain_data(drive, nskip); 1915 + rq->current_nr_sectors -= nskip; 1916 + thislen -= (nskip << 9); 1917 + } 1918 + } 1919 + } 1920 + 1921 + if (ireason == 0) { 1922 + write = 1; 1923 + xferfunc = HWIF(drive)->atapi_output_bytes; 1924 + } else if (ireason == 2 || (ireason == 1 && 1925 + (blk_fs_request(rq) || blk_pc_request(rq)))) { 1926 + write = 0; 1927 + xferfunc = HWIF(drive)->atapi_input_bytes; 1928 + } else { 1929 + printk(KERN_ERR "%s: %s: The drive " 1930 + "appears confused (ireason = 0x%02x). " 1931 + "Trying to recover by ending request.\n", 1932 + drive->name, __FUNCTION__, ireason); 1933 + goto end_request; 1934 + } 1935 + 1936 + /* 1937 + * transfer data 1938 + */ 1939 + while (thislen > 0) { 1940 + u8 *ptr = blk_fs_request(rq) ? NULL : rq->data; 1941 + int blen = rq->data_len; 1942 + 1943 + /* 1944 + * bio backed? 1945 + */ 1946 + if (rq->bio) { 1947 + if (blk_fs_request(rq)) { 1948 + ptr = rq->buffer; 1949 + blen = rq->current_nr_sectors << 9; 1950 + } else { 1951 + ptr = bio_data(rq->bio); 1952 + blen = bio_iovec(rq->bio)->bv_len; 1953 + } 1954 + } 1955 + 1956 + if (!ptr) { 1957 + if (blk_fs_request(rq) && !write) 1958 + /* 1959 + * If the buffers are full, cache the rest 1960 + * of the data in our internal buffer. 1961 + */ 1962 + cdrom_buffer_sectors(drive, rq->sector, 1963 + thislen >> 9); 1964 + else { 1965 + printk(KERN_ERR "%s: confused, missing data\n", 1966 + drive->name); 1967 + blk_dump_rq_flags(rq, rq_data_dir(rq) 1968 + ? "cdrom_newpc_intr, write" 1969 + : "cdrom_newpc_intr, read"); 1970 + } 1971 break; 1972 } 1973 1974 + if (blen > thislen) 1975 + blen = thislen; 1976 1977 + xferfunc(drive, ptr, blen); 1978 + 1979 + thislen -= blen; 1980 + len -= blen; 1981 + 1982 + if (blk_fs_request(rq)) { 1983 + rq->buffer += blen; 1984 + rq->nr_sectors -= (blen >> 9); 1985 + rq->current_nr_sectors -= (blen >> 9); 1986 + rq->sector += (blen >> 9); 1987 + 1988 + if (rq->current_nr_sectors == 0 && rq->nr_sectors) 1989 + cdrom_end_request(drive, 1); 1990 + } else { 1991 + rq->data_len -= blen; 1992 + 1993 + /* 1994 + * The request can't be completed until DRQ is cleared. 1995 + * So complete the data, but don't complete the request 1996 + * using the dummy function for the callback feature 1997 + * of blk_end_request_callback(). 1998 + */ 1999 + if (rq->bio) 2000 + blk_end_request_callback(rq, 0, blen, 2001 + cdrom_newpc_intr_dummy_cb); 2002 + else 2003 + rq->data += blen; 2004 } 2005 } 2006 2007 + if (write && blk_sense_request(rq)) 2008 + rq->sense_len += thislen; 2009 2010 /* 2011 + * pad, if necessary 2012 + */ 2013 + if (!blk_fs_request(rq) && len > 0) 2014 + ide_cd_pad_transfer(drive, xferfunc, len); 2015 + 2016 + if (blk_pc_request(rq)) { 2017 + timeout = rq->timeout; 2018 + } else { 2019 + timeout = ATAPI_WAIT_PC; 2020 + if (!blk_fs_request(rq)) 2021 + expiry = cdrom_timer_expiry; 2022 + } 2023 + 2024 + ide_set_handler(drive, cdrom_newpc_intr, timeout, expiry); 2025 + return ide_started; 2026 + 2027 + end_request: 2028 + if (blk_pc_request(rq)) { 2029 + unsigned long flags; 2030 + 2031 + spin_lock_irqsave(&ide_lock, flags); 2032 + if (__blk_end_request(rq, 0, rq->data_len)) 2033 + BUG(); 2034 + HWGROUP(drive)->rq = NULL; 2035 + spin_unlock_irqrestore(&ide_lock, flags); 2036 + } else { 2037 + if (!uptodate) 2038 + rq->cmd_flags |= REQ_FAILED; 2039 + cdrom_end_request(drive, uptodate); 2040 + } 2041 + return ide_stopped; 2042 + } 2043 + 2044 + static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) 2045 + { 2046 + struct cdrom_info *cd = drive->driver_data; 2047 + int write = rq_data_dir(rq) == WRITE; 2048 + unsigned short sectors_per_frame = 2049 + queue_hardsect_size(drive->queue) >> SECTOR_BITS; 2050 + 2051 + if (write) { 2052 + /* 2053 + * disk has become write protected 2054 + */ 2055 + if (cd->disk->policy) { 2056 + cdrom_end_request(drive, 0); 2057 + return ide_stopped; 2058 + } 2059 + } else { 2060 + /* 2061 + * We may be retrying this request after an error. Fix up any 2062 + * weirdness which might be present in the request packet. 2063 + */ 2064 + restore_request(rq); 2065 + 2066 + /* Satisfy whatever we can of this request from our cache. */ 2067 + if (cdrom_read_from_buffer(drive)) 2068 + return ide_stopped; 2069 + } 2070 + 2071 + /* 2072 + * use DMA, if possible / writes *must* be hardware frame aligned 2073 */ 2074 if ((rq->nr_sectors & (sectors_per_frame - 1)) || 2075 (rq->sector & (sectors_per_frame - 1))) { 2076 + if (write) { 2077 + cdrom_end_request(drive, 0); 2078 + return ide_stopped; 2079 + } 2080 + cd->dma = 0; 2081 + } else 2082 + cd->dma = drive->using_dma; 2083 2084 + /* Clear the local sector buffer. */ 2085 + cd->nsectors_buffered = 0; 2086 2087 + if (write) 2088 + cd->devinfo.media_written = 1; 2089 2090 + /* Start sending the read/write request to the drive. */ 2091 + return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont); 2092 } 2093 2094 static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive) ··· 1973 { 1974 struct cdrom_info *info = drive->driver_data; 1975 1976 + if (blk_pc_request(rq)) 1977 + rq->cmd_flags |= REQ_QUIET; 1978 + else 1979 + rq->cmd_flags &= ~REQ_FAILED; 1980 1981 info->dma = 0; 1982 ··· 2010 struct cdrom_info *info = drive->driver_data; 2011 2012 if (blk_fs_request(rq)) { 2013 + if (info->cd_flags & IDE_CD_FLAG_SEEKING) { 2014 unsigned long elapsed = jiffies - info->start_seek; 2015 int stat = HWIF(drive)->INB(IDE_STATUS_REG); 2016 ··· 2021 } 2022 printk (KERN_ERR "%s: DSC timeout\n", drive->name); 2023 } 2024 + info->cd_flags &= ~IDE_CD_FLAG_SEEKING; 2025 } 2026 if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) { 2027 action = cdrom_start_seek(drive, block); 2028 + } else 2029 + action = cdrom_start_rw(drive, rq); 2030 info->last_block = block; 2031 return action; 2032 + } else if (blk_sense_request(rq) || blk_pc_request(rq) || 2033 rq->cmd_type == REQ_TYPE_ATA_PC) { 2034 return cdrom_do_block_pc(drive, rq); 2035 } else if (blk_special_request(rq)) { 2036 /* ··· 2063 * can also be NULL, in which case no sense information is returned. 2064 */ 2065 2066 static 2067 void msf_from_bcd (struct atapi_msf *msf) 2068 { 2069 + msf->minute = BCD2BIN(msf->minute); 2070 + msf->second = BCD2BIN(msf->second); 2071 + msf->frame = BCD2BIN(msf->frame); 2072 } 2073 2074 + int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) 2075 { 2076 struct request req; 2077 struct cdrom_info *info = drive->driver_data; 2078 struct cdrom_device_info *cdi = &info->devinfo; 2079 2080 + ide_cd_init_rq(drive, &req); 2081 2082 req.sense = sense; 2083 req.cmd[0] = GPCMD_TEST_UNIT_READY; 2084 req.cmd_flags |= REQ_QUIET; 2085 2086 + /* 2087 + * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to 2088 + * switch CDs instead of supporting the LOAD_UNLOAD opcode. 2089 + */ 2090 req.cmd[7] = cdi->sanyo_slot % 3; 2091 2092 + return ide_cd_queue_pc(drive, &req); 2093 } 2094 2095 static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, ··· 2212 int stat; 2213 struct request req; 2214 2215 + ide_cd_init_rq(drive, &req); 2216 2217 req.sense = sense; 2218 req.cmd[0] = GPCMD_READ_CDVD_CAPACITY; ··· 2220 req.data_len = sizeof(capbuf); 2221 req.cmd_flags |= REQ_QUIET; 2222 2223 + stat = ide_cd_queue_pc(drive, &req); 2224 if (stat == 0) { 2225 *capacity = 1 + be32_to_cpu(capbuf.lba); 2226 *sectors_per_frame = ··· 2236 { 2237 struct request req; 2238 2239 + ide_cd_init_rq(drive, &req); 2240 2241 req.sense = sense; 2242 req.data = buf; ··· 2251 if (msf_flag) 2252 req.cmd[1] = 2; 2253 2254 + return ide_cd_queue_pc(drive, &req); 2255 } 2256 2257 /* Try to read the entire TOC for the disk into our internal buffer. */ 2258 + int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) 2259 { 2260 int stat, ntracks, i; 2261 struct cdrom_info *info = drive->driver_data; ··· 2283 If it is, just return. */ 2284 (void) cdrom_check_status(drive, sense); 2285 2286 + if (info->cd_flags & IDE_CD_FLAG_TOC_VALID) 2287 return 0; 2288 2289 /* Try to get the total cdrom capacity and sector size. */ ··· 2305 if (stat) 2306 return stat; 2307 2308 + if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) { 2309 + toc->hdr.first_track = BCD2BIN(toc->hdr.first_track); 2310 + toc->hdr.last_track = BCD2BIN(toc->hdr.last_track); 2311 } 2312 2313 ntracks = toc->hdr.last_track - toc->hdr.first_track + 1; 2314 if (ntracks <= 0) ··· 2342 (ntracks + 1) * 2343 sizeof(struct atapi_toc_entry), 2344 sense); 2345 + if (stat) 2346 return stat; 2347 + 2348 + if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) { 2349 + toc->hdr.first_track = (u8)BIN2BCD(CDROM_LEADOUT); 2350 + toc->hdr.last_track = (u8)BIN2BCD(CDROM_LEADOUT); 2351 + } else { 2352 toc->hdr.first_track = CDROM_LEADOUT; 2353 toc->hdr.last_track = CDROM_LEADOUT; 2354 } ··· 2362 2363 toc->hdr.toc_length = ntohs (toc->hdr.toc_length); 2364 2365 + if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) { 2366 + toc->hdr.first_track = BCD2BIN(toc->hdr.first_track); 2367 + toc->hdr.last_track = BCD2BIN(toc->hdr.last_track); 2368 } 2369 2370 + for (i = 0; i <= ntracks; i++) { 2371 + if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) { 2372 + if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) 2373 + toc->ent[i].track = BCD2BIN(toc->ent[i].track); 2374 msf_from_bcd(&toc->ent[i].addr.msf); 2375 } 2376 toc->ent[i].addr.lba = msf_to_lba (toc->ent[i].addr.msf.minute, 2377 toc->ent[i].addr.msf.second, 2378 toc->ent[i].addr.msf.frame); ··· 2396 toc->last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */ 2397 } 2398 2399 + if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) { 2400 /* Re-read multisession information using MSF format */ 2401 stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp, 2402 sizeof(ms_tmp), sense); ··· 2409 ms_tmp.ent.addr.msf.second, 2410 ms_tmp.ent.addr.msf.frame); 2411 } 2412 2413 toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track); 2414 ··· 2422 } 2423 2424 /* Remember that we've read this stuff. */ 2425 + info->cd_flags |= IDE_CD_FLAG_TOC_VALID; 2426 2427 return 0; 2428 } 2429 2430 + int ide_cdrom_get_capabilities(ide_drive_t *drive, u8 *buf) 2431 { 2432 struct cdrom_info *info = drive->driver_data; 2433 struct cdrom_device_info *cdi = &info->devinfo; 2434 struct packet_command cgc; 2435 + int stat, attempts = 3, size = ATAPI_CAPABILITIES_PAGE_SIZE; 2436 2437 + if ((info->cd_flags & IDE_CD_FLAG_FULL_CAPS_PAGE) == 0) 2438 + size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE; 2439 2440 + init_cdrom_command(&cgc, buf, size, CGC_DATA_UNKNOWN); 2441 do { /* we seem to get stat=0x01,err=0x00 the first time (??) */ 2442 stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0); 2443 if (!stat) ··· 2702 return stat; 2703 } 2704 2705 + void ide_cdrom_update_speed(ide_drive_t *drive, u8 *buf) 2706 { 2707 + struct cdrom_info *cd = drive->driver_data; 2708 + u16 curspeed, maxspeed; 2709 + 2710 + curspeed = *(u16 *)&buf[8 + 14]; 2711 + maxspeed = *(u16 *)&buf[8 + 8]; 2712 + 2713 + if (cd->cd_flags & IDE_CD_FLAG_LE_SPEED_FIELDS) { 2714 + curspeed = le16_to_cpu(curspeed); 2715 + maxspeed = le16_to_cpu(maxspeed); 2716 } else { 2717 + curspeed = be16_to_cpu(curspeed); 2718 + maxspeed = be16_to_cpu(maxspeed); 2719 } 2720 2721 + cd->current_speed = (curspeed + (176/2)) / 176; 2722 + cd->max_speed = (maxspeed + (176/2)) / 176; 2723 } 2724 2725 + #define IDE_CD_CAPABILITIES \ 2726 + (CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | \ 2727 + CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | \ 2728 + CDC_PLAY_AUDIO | CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R | \ 2729 + CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_GENERIC_PACKET | \ 2730 + CDC_MO_DRIVE | CDC_MRW | CDC_MRW_W | CDC_RAM) 2731 2732 static struct cdrom_device_ops ide_cdrom_dops = { 2733 .open = ide_cdrom_open_real, 2734 .release = ide_cdrom_release_real, ··· 2885 .get_mcn = ide_cdrom_get_mcn, 2886 .reset = ide_cdrom_reset, 2887 .audio_ioctl = ide_cdrom_audio_ioctl, 2888 + .capability = IDE_CD_CAPABILITIES, 2889 .generic_packet = ide_cdrom_packet, 2890 }; 2891 ··· 2902 struct cdrom_device_info *devinfo = &info->devinfo; 2903 2904 devinfo->ops = &ide_cdrom_dops; 2905 + devinfo->speed = info->current_speed; 2906 devinfo->capacity = nslots; 2907 devinfo->handle = drive; 2908 strcpy(devinfo->name, drive->name); 2909 2910 + if (info->cd_flags & IDE_CD_FLAG_NO_SPEED_SELECT) 2911 devinfo->mask |= CDC_SELECT_SPEED; 2912 2913 devinfo->disk = info->disk; ··· 2940 static 2941 int ide_cdrom_probe_capabilities (ide_drive_t *drive) 2942 { 2943 + struct cdrom_info *cd = drive->driver_data; 2944 + struct cdrom_device_info *cdi = &cd->devinfo; 2945 + u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; 2946 + mechtype_t mechtype; 2947 int nslots = 1; 2948 2949 + cdi->mask = (CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | 2950 + CDC_DVD_RAM | CDC_SELECT_DISC | CDC_PLAY_AUDIO | 2951 + CDC_MO_DRIVE | CDC_RAM); 2952 + 2953 if (drive->media == ide_optical) { 2954 + cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); 2955 printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", drive->name); 2956 return nslots; 2957 } 2958 2959 + if (cd->cd_flags & IDE_CD_FLAG_PRE_ATAPI12) { 2960 + cd->cd_flags &= ~IDE_CD_FLAG_NO_EJECT; 2961 + cdi->mask &= ~CDC_PLAY_AUDIO; 2962 return nslots; 2963 } 2964 ··· 2969 cdi->handle = drive; 2970 cdi->ops = &ide_cdrom_dops; 2971 2972 + if (ide_cdrom_get_capabilities(drive, buf)) 2973 return 0; 2974 2975 + if ((buf[8 + 6] & 0x01) == 0) 2976 + cd->cd_flags |= IDE_CD_FLAG_NO_DOORLOCK; 2977 + if (buf[8 + 6] & 0x08) 2978 + cd->cd_flags &= ~IDE_CD_FLAG_NO_EJECT; 2979 + if (buf[8 + 3] & 0x01) 2980 + cdi->mask &= ~CDC_CD_R; 2981 + if (buf[8 + 3] & 0x02) 2982 + cdi->mask &= ~(CDC_CD_RW | CDC_RAM); 2983 + if (buf[8 + 2] & 0x38) 2984 + cdi->mask &= ~CDC_DVD; 2985 + if (buf[8 + 3] & 0x20) 2986 + cdi->mask &= ~(CDC_DVD_RAM | CDC_RAM); 2987 + if (buf[8 + 3] & 0x10) 2988 + cdi->mask &= ~CDC_DVD_R; 2989 + if ((buf[8 + 4] & 0x01) || (cd->cd_flags & IDE_CD_FLAG_PLAY_AUDIO_OK)) 2990 + cdi->mask &= ~CDC_PLAY_AUDIO; 2991 2992 + mechtype = buf[8 + 6] >> 5; 2993 + if (mechtype == mechtype_caddy || mechtype == mechtype_popup) 2994 + cdi->mask |= CDC_CLOSE_TRAY; 2995 2996 if (cdi->sanyo_slot > 0) { 2997 + cdi->mask &= ~CDC_SELECT_DISC; 2998 nslots = 3; 2999 + } else if (mechtype == mechtype_individual_changer || 3000 + mechtype == mechtype_cartridge_changer) { 3001 + nslots = cdrom_number_of_slots(cdi); 3002 + if (nslots > 1) 3003 + cdi->mask &= ~CDC_SELECT_DISC; 3004 } 3005 3006 + ide_cdrom_update_speed(drive, buf); 3007 3008 printk(KERN_INFO "%s: ATAPI", drive->name); 3009 3010 + /* don't print speed if the drive reported 0 */ 3011 + if (cd->max_speed) 3012 + printk(KERN_CONT " %dX", cd->max_speed); 3013 3014 + printk(KERN_CONT " %s", (cdi->mask & CDC_DVD) ? "CD-ROM" : "DVD-ROM"); 3015 3016 + if ((cdi->mask & CDC_DVD_R) == 0 || (cdi->mask & CDC_DVD_RAM) == 0) 3017 + printk(KERN_CONT " DVD%s%s", 3018 + (cdi->mask & CDC_DVD_R) ? "" : "-R", 3019 + (cdi->mask & CDC_DVD_RAM) ? "" : "-RAM"); 3020 3021 + if ((cdi->mask & CDC_CD_R) == 0 || (cdi->mask & CDC_CD_RW) == 0) 3022 + printk(KERN_CONT " CD%s%s", 3023 + (cdi->mask & CDC_CD_R) ? "" : "-R", 3024 + (cdi->mask & CDC_CD_RW) ? "" : "/RW"); 3025 + 3026 + if ((cdi->mask & CDC_SELECT_DISC) == 0) 3027 + printk(KERN_CONT " changer w/%d slots", nslots); 3028 + else 3029 + printk(KERN_CONT " drive"); 3030 + 3031 + printk(KERN_CONT ", %dkB Cache\n", be16_to_cpu(*(u16 *)&buf[8 + 12])); 3032 3033 return nslots; 3034 } ··· 3138 return 0; 3139 } 3140 3141 + struct cd_list_entry { 3142 + const char *id_model; 3143 + const char *id_firmware; 3144 + unsigned int cd_flags; 3145 + }; 3146 + 3147 + static const struct cd_list_entry ide_cd_quirks_list[] = { 3148 + /* Limit transfer size per interrupt. */ 3149 + { "SAMSUNG CD-ROM SCR-2430", NULL, IDE_CD_FLAG_LIMIT_NFRAMES }, 3150 + { "SAMSUNG CD-ROM SCR-2432", NULL, IDE_CD_FLAG_LIMIT_NFRAMES }, 3151 + /* SCR-3231 doesn't support the SET_CD_SPEED command. */ 3152 + { "SAMSUNG CD-ROM SCR-3231", NULL, IDE_CD_FLAG_NO_SPEED_SELECT }, 3153 + /* Old NEC260 (not R) was released before ATAPI 1.2 spec. */ 3154 + { "NEC CD-ROM DRIVE:260", "1.01", IDE_CD_FLAG_TOCADDR_AS_BCD | 3155 + IDE_CD_FLAG_PRE_ATAPI12, }, 3156 + /* Vertos 300, some versions of this drive like to talk BCD. */ 3157 + { "V003S0DS", NULL, IDE_CD_FLAG_VERTOS_300_SSD, }, 3158 + /* Vertos 600 ESD. */ 3159 + { "V006E0DS", NULL, IDE_CD_FLAG_VERTOS_600_ESD, }, 3160 + /* 3161 + * Sanyo 3 CD changer uses a non-standard command for CD changing 3162 + * (by default standard ATAPI support for CD changers is used). 3163 + */ 3164 + { "CD-ROM CDR-C3 G", NULL, IDE_CD_FLAG_SANYO_3CD }, 3165 + { "CD-ROM CDR-C3G", NULL, IDE_CD_FLAG_SANYO_3CD }, 3166 + { "CD-ROM CDR_C36", NULL, IDE_CD_FLAG_SANYO_3CD }, 3167 + /* Stingray 8X CD-ROM. */ 3168 + { "STINGRAY 8422 IDE 8X CD-ROM 7-27-95", NULL, IDE_CD_FLAG_PRE_ATAPI12}, 3169 + /* 3170 + * ACER 50X CD-ROM and WPI 32X CD-ROM require the full spec length 3171 + * mode sense page capabilities size, but older drives break. 3172 + */ 3173 + { "ATAPI CD ROM DRIVE 50X MAX", NULL, IDE_CD_FLAG_FULL_CAPS_PAGE }, 3174 + { "WPI CDS-32X", NULL, IDE_CD_FLAG_FULL_CAPS_PAGE }, 3175 + /* ACER/AOpen 24X CD-ROM has the speed fields byte-swapped. */ 3176 + { "", "241N", IDE_CD_FLAG_LE_SPEED_FIELDS }, 3177 + /* 3178 + * Some drives used by Apple don't advertise audio play 3179 + * but they do support reading TOC & audio datas. 3180 + */ 3181 + { "MATSHITADVD-ROM SR-8187", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, 3182 + { "MATSHITADVD-ROM SR-8186", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, 3183 + { "MATSHITADVD-ROM SR-8176", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, 3184 + { "MATSHITADVD-ROM SR-8174", NULL, IDE_CD_FLAG_PLAY_AUDIO_OK }, 3185 + { NULL, NULL, 0 } 3186 + }; 3187 + 3188 + static unsigned int ide_cd_flags(struct hd_driveid *id) 3189 + { 3190 + const struct cd_list_entry *cle = ide_cd_quirks_list; 3191 + 3192 + while (cle->id_model) { 3193 + if (strcmp(cle->id_model, id->model) == 0 && 3194 + (cle->id_firmware == NULL || 3195 + strstr(id->fw_rev, cle->id_firmware))) 3196 + return cle->cd_flags; 3197 + cle++; 3198 + } 3199 + 3200 + return 0; 3201 + } 3202 + 3203 static 3204 int ide_cdrom_setup (ide_drive_t *drive) 3205 { 3206 + struct cdrom_info *cd = drive->driver_data; 3207 + struct cdrom_device_info *cdi = &cd->devinfo; 3208 + struct hd_driveid *id = drive->id; 3209 int nslots; 3210 3211 blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn); ··· 3153 3154 drive->special.all = 0; 3155 3156 + cd->cd_flags = IDE_CD_FLAG_MEDIA_CHANGED | IDE_CD_FLAG_NO_EJECT | 3157 + ide_cd_flags(id); 3158 3159 + if ((id->config & 0x0060) == 0x20) 3160 + cd->cd_flags |= IDE_CD_FLAG_DRQ_INTERRUPT; 3161 3162 + if ((cd->cd_flags & IDE_CD_FLAG_VERTOS_300_SSD) && 3163 + id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') 3164 + cd->cd_flags |= (IDE_CD_FLAG_TOCTRACKS_AS_BCD | 3165 + IDE_CD_FLAG_TOCADDR_AS_BCD); 3166 + else if ((cd->cd_flags & IDE_CD_FLAG_VERTOS_600_ESD) && 3167 + id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') 3168 + cd->cd_flags |= IDE_CD_FLAG_TOCTRACKS_AS_BCD; 3169 + else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD) 3170 + cdi->sanyo_slot = 3; /* 3 => use CD in slot 0 */ 3171 3172 nslots = ide_cdrom_probe_capabilities (drive); 3173 ··· 3262 3263 if (ide_cdrom_register(drive, nslots)) { 3264 printk (KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name); 3265 + cd->devinfo.handle = NULL; 3266 return 1; 3267 } 3268 ide_cdrom_add_settings(drive); ··· 3302 3303 kfree(info->buffer); 3304 kfree(info->toc); 3305 if (devinfo->handle == drive && unregister_cdrom(devinfo)) 3306 printk(KERN_ERR "%s: %s failed to unregister device from the cdrom " 3307 "driver.\n", __FUNCTION__, drive->name); ··· 3458 { 3459 struct cdrom_info *info = ide_cd_g(disk); 3460 struct request_sense sense; 3461 + 3462 + ide_cd_read_toc(info->drive, &sense); 3463 + 3464 return 0; 3465 } 3466 ··· 3533 goto failed; 3534 } 3535 3536 + ide_cd_read_toc(drive, &sense); 3537 g->fops = &idecd_ops; 3538 g->flags |= GENHD_FL_REMOVABLE; 3539 add_disk(g); ··· 3556 } 3557 3558 MODULE_ALIAS("ide:*m-cdrom*"); 3559 + MODULE_ALIAS("ide-cd"); 3560 module_init(ide_cdrom_init); 3561 module_exit(ide_cdrom_exit); 3562 MODULE_LICENSE("GPL");
+64 -636
drivers/ide/ide-cd.h
··· 1 /* 2 - * linux/drivers/ide/ide_cd.h 3 - * 4 * Copyright (C) 1996-98 Erik Andersen 5 * Copyright (C) 1998-2000 Jens Axboe 6 */ ··· 7 8 #include <linux/cdrom.h> 9 #include <asm/byteorder.h> 10 - 11 - /* Turn this on to have the driver print out the meanings of the 12 - ATAPI error codes. This will use up additional kernel-space 13 - memory, though. */ 14 - 15 - #ifndef VERBOSE_IDE_CD_ERRORS 16 - #define VERBOSE_IDE_CD_ERRORS 1 17 - #endif 18 - 19 - 20 - /* Turning this on will remove code to work around various nonstandard 21 - ATAPI implementations. If you know your drive follows the standard, 22 - this will give you a slightly smaller kernel. */ 23 - 24 - #ifndef STANDARD_ATAPI 25 - #define STANDARD_ATAPI 0 26 - #endif 27 - 28 - 29 - /* Turning this on will disable the door-locking functionality. 30 - This is apparently needed for supermount. */ 31 - 32 - #ifndef NO_DOOR_LOCKING 33 - #define NO_DOOR_LOCKING 0 34 - #endif 35 36 /* 37 * typical timeout for packet command ··· 22 #endif 23 #define SECTORS_PER_FRAME (CD_FRAMESIZE >> SECTOR_BITS) 24 #define SECTOR_BUFFER_SIZE (CD_FRAMESIZE * 32) 25 - #define SECTORS_BUFFER (SECTOR_BUFFER_SIZE >> SECTOR_BITS) 26 - #define SECTORS_MAX (131072 >> SECTOR_BITS) 27 28 - #define BLOCKS_PER_FRAME (CD_FRAMESIZE / BLOCK_SIZE) 29 30 - /* special command codes for strategy routine. */ 31 - #define PACKET_COMMAND 4315 32 - #define REQUEST_SENSE_COMMAND 4316 33 - #define RESET_DRIVE_COMMAND 4317 34 - 35 - 36 - /* Configuration flags. These describe the capabilities of the drive. 37 - They generally do not change after initialization, unless we learn 38 - more about the drive from stuff failing. */ 39 - struct ide_cd_config_flags { 40 - __u8 drq_interrupt : 1; /* Device sends an interrupt when ready 41 - for a packet command. */ 42 - __u8 no_doorlock : 1; /* Drive cannot lock the door. */ 43 - __u8 no_eject : 1; /* Drive cannot eject the disc. */ 44 - __u8 nec260 : 1; /* Drive is a pre-1.2 NEC 260 drive. */ 45 - __u8 playmsf_as_bcd : 1; /* PLAYMSF command takes BCD args. */ 46 - __u8 tocaddr_as_bcd : 1; /* TOC addresses are in BCD. */ 47 - __u8 toctracks_as_bcd : 1; /* TOC track numbers are in BCD. */ 48 - __u8 subchan_as_bcd : 1; /* Subchannel info is in BCD. */ 49 - __u8 is_changer : 1; /* Drive is a changer. */ 50 - __u8 cd_r : 1; /* Drive can write to CD-R media . */ 51 - __u8 cd_rw : 1; /* Drive can write to CD-R/W media . */ 52 - __u8 dvd : 1; /* Drive is a DVD-ROM */ 53 - __u8 dvd_r : 1; /* Drive can write DVD-R */ 54 - __u8 dvd_ram : 1; /* Drive can write DVD-RAM */ 55 - __u8 ram : 1; /* generic WRITE (dvd-ram/mrw) */ 56 - __u8 test_write : 1; /* Drive can fake writes */ 57 - __u8 supp_disc_present : 1; /* Changer can report exact contents 58 - of slots. */ 59 - __u8 limit_nframes : 1; /* Drive does not provide data in 60 - multiples of SECTOR_SIZE when more 61 - than one interrupt is needed. */ 62 - __u8 seeking : 1; /* Seeking in progress */ 63 - __u8 audio_play : 1; /* can do audio related commands */ 64 - __u8 close_tray : 1; /* can close the tray */ 65 - __u8 writing : 1; /* pseudo write in progress */ 66 - __u8 mo_drive : 1; /* drive is an MO device */ 67 - __u8 no_speed_select : 1; /* SET_CD_SPEED command is unsupported. */ 68 - __u8 reserved : 1; 69 - byte max_speed; /* Max speed of the drive */ 70 }; 71 - #define CDROM_CONFIG_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->config_flags)) 72 - 73 - 74 - /* State flags. These give information about the current state of the 75 - drive, and will change during normal operation. */ 76 - struct ide_cd_state_flags { 77 - __u8 media_changed : 1; /* Driver has noticed a media change. */ 78 - __u8 toc_valid : 1; /* Saved TOC information is current. */ 79 - __u8 door_locked : 1; /* We think that the drive door is locked. */ 80 - __u8 writing : 1; /* the drive is currently writing */ 81 - __u8 reserved : 4; 82 - byte current_speed; /* Current speed of the drive */ 83 - }; 84 - 85 - #define CDROM_STATE_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->state_flags)) 86 87 /* Structure of a MSF cdrom address. */ 88 struct atapi_msf { ··· 107 /* One extra for the leadout. */ 108 }; 109 110 - 111 - /* This structure is annoyingly close to, but not identical with, 112 - the cdrom_subchnl structure from cdrom.h. */ 113 - struct atapi_cdrom_subchnl { 114 - u_char acdsc_reserved; 115 - u_char acdsc_audiostatus; 116 - u_short acdsc_length; 117 - u_char acdsc_format; 118 - 119 - #if defined(__BIG_ENDIAN_BITFIELD) 120 - u_char acdsc_ctrl: 4; 121 - u_char acdsc_adr: 4; 122 - #elif defined(__LITTLE_ENDIAN_BITFIELD) 123 - u_char acdsc_adr: 4; 124 - u_char acdsc_ctrl: 4; 125 - #else 126 - #error "Please fix <asm/byteorder.h>" 127 - #endif 128 - u_char acdsc_trk; 129 - u_char acdsc_ind; 130 - union { 131 - struct atapi_msf msf; 132 - int lba; 133 - } acdsc_absaddr; 134 - union { 135 - struct atapi_msf msf; 136 - int lba; 137 - } acdsc_reladdr; 138 - }; 139 - 140 - 141 - 142 - /* This should probably go into cdrom.h along with the other 143 - * generic stuff now in the Mt. Fuji spec. 144 - */ 145 - struct atapi_capabilities_page { 146 - struct mode_page_header header; 147 - #if defined(__BIG_ENDIAN_BITFIELD) 148 - __u8 parameters_saveable : 1; 149 - __u8 reserved1 : 1; 150 - __u8 page_code : 6; 151 - #elif defined(__LITTLE_ENDIAN_BITFIELD) 152 - __u8 page_code : 6; 153 - __u8 reserved1 : 1; 154 - __u8 parameters_saveable : 1; 155 - #else 156 - #error "Please fix <asm/byteorder.h>" 157 - #endif 158 - 159 - byte page_length; 160 - 161 - #if defined(__BIG_ENDIAN_BITFIELD) 162 - __u8 reserved2 : 2; 163 - /* Drive supports reading of DVD-RAM discs */ 164 - __u8 dvd_ram_read : 1; 165 - /* Drive supports reading of DVD-R discs */ 166 - __u8 dvd_r_read : 1; 167 - /* Drive supports reading of DVD-ROM discs */ 168 - __u8 dvd_rom : 1; 169 - /* Drive supports reading CD-R discs with addressing method 2 */ 170 - __u8 method2 : 1; /* reserved in 1.2 */ 171 - /* Drive can read from CD-R/W (CD-E) discs (orange book, part III) */ 172 - __u8 cd_rw_read : 1; /* reserved in 1.2 */ 173 - /* Drive supports read from CD-R discs (orange book, part II) */ 174 - __u8 cd_r_read : 1; /* reserved in 1.2 */ 175 - #elif defined(__LITTLE_ENDIAN_BITFIELD) 176 - /* Drive supports read from CD-R discs (orange book, part II) */ 177 - __u8 cd_r_read : 1; /* reserved in 1.2 */ 178 - /* Drive can read from CD-R/W (CD-E) discs (orange book, part III) */ 179 - __u8 cd_rw_read : 1; /* reserved in 1.2 */ 180 - /* Drive supports reading CD-R discs with addressing method 2 */ 181 - __u8 method2 : 1; 182 - /* Drive supports reading of DVD-ROM discs */ 183 - __u8 dvd_rom : 1; 184 - /* Drive supports reading of DVD-R discs */ 185 - __u8 dvd_r_read : 1; 186 - /* Drive supports reading of DVD-RAM discs */ 187 - __u8 dvd_ram_read : 1; 188 - __u8 reserved2 : 2; 189 - #else 190 - #error "Please fix <asm/byteorder.h>" 191 - #endif 192 - 193 - #if defined(__BIG_ENDIAN_BITFIELD) 194 - __u8 reserved3 : 2; 195 - /* Drive can write DVD-RAM discs */ 196 - __u8 dvd_ram_write : 1; 197 - /* Drive can write DVD-R discs */ 198 - __u8 dvd_r_write : 1; 199 - __u8 reserved3a : 1; 200 - /* Drive can fake writes */ 201 - __u8 test_write : 1; 202 - /* Drive can write to CD-R/W (CD-E) discs (orange book, part III) */ 203 - __u8 cd_rw_write : 1; /* reserved in 1.2 */ 204 - /* Drive supports write to CD-R discs (orange book, part II) */ 205 - __u8 cd_r_write : 1; /* reserved in 1.2 */ 206 - #elif defined(__LITTLE_ENDIAN_BITFIELD) 207 - /* Drive can write to CD-R discs (orange book, part II) */ 208 - __u8 cd_r_write : 1; /* reserved in 1.2 */ 209 - /* Drive can write to CD-R/W (CD-E) discs (orange book, part III) */ 210 - __u8 cd_rw_write : 1; /* reserved in 1.2 */ 211 - /* Drive can fake writes */ 212 - __u8 test_write : 1; 213 - __u8 reserved3a : 1; 214 - /* Drive can write DVD-R discs */ 215 - __u8 dvd_r_write : 1; 216 - /* Drive can write DVD-RAM discs */ 217 - __u8 dvd_ram_write : 1; 218 - __u8 reserved3 : 2; 219 - #else 220 - #error "Please fix <asm/byteorder.h>" 221 - #endif 222 - 223 - #if defined(__BIG_ENDIAN_BITFIELD) 224 - __u8 reserved4 : 1; 225 - /* Drive can read multisession discs. */ 226 - __u8 multisession : 1; 227 - /* Drive can read mode 2, form 2 data. */ 228 - __u8 mode2_form2 : 1; 229 - /* Drive can read mode 2, form 1 (XA) data. */ 230 - __u8 mode2_form1 : 1; 231 - /* Drive supports digital output on port 2. */ 232 - __u8 digport2 : 1; 233 - /* Drive supports digital output on port 1. */ 234 - __u8 digport1 : 1; 235 - /* Drive can deliver a composite audio/video data stream. */ 236 - __u8 composite : 1; 237 - /* Drive supports audio play operations. */ 238 - __u8 audio_play : 1; 239 - #elif defined(__LITTLE_ENDIAN_BITFIELD) 240 - /* Drive supports audio play operations. */ 241 - __u8 audio_play : 1; 242 - /* Drive can deliver a composite audio/video data stream. */ 243 - __u8 composite : 1; 244 - /* Drive supports digital output on port 1. */ 245 - __u8 digport1 : 1; 246 - /* Drive supports digital output on port 2. */ 247 - __u8 digport2 : 1; 248 - /* Drive can read mode 2, form 1 (XA) data. */ 249 - __u8 mode2_form1 : 1; 250 - /* Drive can read mode 2, form 2 data. */ 251 - __u8 mode2_form2 : 1; 252 - /* Drive can read multisession discs. */ 253 - __u8 multisession : 1; 254 - __u8 reserved4 : 1; 255 - #else 256 - #error "Please fix <asm/byteorder.h>" 257 - #endif 258 - 259 - #if defined(__BIG_ENDIAN_BITFIELD) 260 - __u8 reserved5 : 1; 261 - /* Drive can return Media Catalog Number (UPC) info. */ 262 - __u8 upc : 1; 263 - /* Drive can return International Standard Recording Code info. */ 264 - __u8 isrc : 1; 265 - /* Drive supports C2 error pointers. */ 266 - __u8 c2_pointers : 1; 267 - /* R-W data will be returned deinterleaved and error corrected. */ 268 - __u8 rw_corr : 1; 269 - /* Subchannel reads can return combined R-W information. */ 270 - __u8 rw_supported : 1; 271 - /* Drive can continue a read cdda operation from a loss of streaming.*/ 272 - __u8 cdda_accurate : 1; 273 - /* Drive can read Red Book audio data. */ 274 - __u8 cdda : 1; 275 - #elif defined(__LITTLE_ENDIAN_BITFIELD) 276 - /* Drive can read Red Book audio data. */ 277 - __u8 cdda : 1; 278 - /* Drive can continue a read cdda operation from a loss of streaming.*/ 279 - __u8 cdda_accurate : 1; 280 - /* Subchannel reads can return combined R-W information. */ 281 - __u8 rw_supported : 1; 282 - /* R-W data will be returned deinterleaved and error corrected. */ 283 - __u8 rw_corr : 1; 284 - /* Drive supports C2 error pointers. */ 285 - __u8 c2_pointers : 1; 286 - /* Drive can return International Standard Recording Code info. */ 287 - __u8 isrc : 1; 288 - /* Drive can return Media Catalog Number (UPC) info. */ 289 - __u8 upc : 1; 290 - __u8 reserved5 : 1; 291 - #else 292 - #error "Please fix <asm/byteorder.h>" 293 - #endif 294 - 295 - #if defined(__BIG_ENDIAN_BITFIELD) 296 - /* Drive mechanism types. */ 297 - mechtype_t mechtype : 3; 298 - __u8 reserved6 : 1; 299 - /* Drive can eject a disc or changer cartridge. */ 300 - __u8 eject : 1; 301 - /* State of prevent/allow jumper. */ 302 - __u8 prevent_jumper : 1; 303 - /* Present state of door lock. */ 304 - __u8 lock_state : 1; 305 - /* Drive can lock the door. */ 306 - __u8 lock : 1; 307 - #elif defined(__LITTLE_ENDIAN_BITFIELD) 308 - 309 - /* Drive can lock the door. */ 310 - __u8 lock : 1; 311 - /* Present state of door lock. */ 312 - __u8 lock_state : 1; 313 - /* State of prevent/allow jumper. */ 314 - __u8 prevent_jumper : 1; 315 - /* Drive can eject a disc or changer cartridge. */ 316 - __u8 eject : 1; 317 - __u8 reserved6 : 1; 318 - /* Drive mechanism types. */ 319 - mechtype_t mechtype : 3; 320 - #else 321 - #error "Please fix <asm/byteorder.h>" 322 - #endif 323 - 324 - #if defined(__BIG_ENDIAN_BITFIELD) 325 - __u8 reserved7 : 4; 326 - /* Drive supports software slot selection. */ 327 - __u8 sss : 1; /* reserved in 1.2 */ 328 - /* Changer can report exact contents of slots. */ 329 - __u8 disc_present : 1; /* reserved in 1.2 */ 330 - /* Audio for each channel can be muted independently. */ 331 - __u8 separate_mute : 1; 332 - /* Audio level for each channel can be controlled independently. */ 333 - __u8 separate_volume : 1; 334 - #elif defined(__LITTLE_ENDIAN_BITFIELD) 335 - 336 - /* Audio level for each channel can be controlled independently. */ 337 - __u8 separate_volume : 1; 338 - /* Audio for each channel can be muted independently. */ 339 - __u8 separate_mute : 1; 340 - /* Changer can report exact contents of slots. */ 341 - __u8 disc_present : 1; /* reserved in 1.2 */ 342 - /* Drive supports software slot selection. */ 343 - __u8 sss : 1; /* reserved in 1.2 */ 344 - __u8 reserved7 : 4; 345 - #else 346 - #error "Please fix <asm/byteorder.h>" 347 - #endif 348 - 349 - /* Note: the following four fields are returned in big-endian form. */ 350 - /* Maximum speed (in kB/s). */ 351 - unsigned short maxspeed; 352 - /* Number of discrete volume levels. */ 353 - unsigned short n_vol_levels; 354 - /* Size of cache in drive, in kB. */ 355 - unsigned short buffer_size; 356 - /* Current speed (in kB/s). */ 357 - unsigned short curspeed; 358 - char pad[4]; 359 - }; 360 - 361 - 362 - struct atapi_mechstat_header { 363 - #if defined(__BIG_ENDIAN_BITFIELD) 364 - __u8 fault : 1; 365 - __u8 changer_state : 2; 366 - __u8 curslot : 5; 367 - #elif defined(__LITTLE_ENDIAN_BITFIELD) 368 - __u8 curslot : 5; 369 - __u8 changer_state : 2; 370 - __u8 fault : 1; 371 - #else 372 - #error "Please fix <asm/byteorder.h>" 373 - #endif 374 - 375 - #if defined(__BIG_ENDIAN_BITFIELD) 376 - __u8 mech_state : 3; 377 - __u8 door_open : 1; 378 - __u8 reserved1 : 4; 379 - #elif defined(__LITTLE_ENDIAN_BITFIELD) 380 - __u8 reserved1 : 4; 381 - __u8 door_open : 1; 382 - __u8 mech_state : 3; 383 - #else 384 - #error "Please fix <asm/byteorder.h>" 385 - #endif 386 - 387 - byte curlba[3]; 388 - byte nslots; 389 - __u16 slot_tablelen; 390 - }; 391 - 392 - 393 - struct atapi_slot { 394 - #if defined(__BIG_ENDIAN_BITFIELD) 395 - __u8 disc_present : 1; 396 - __u8 reserved1 : 6; 397 - __u8 change : 1; 398 - #elif defined(__LITTLE_ENDIAN_BITFIELD) 399 - __u8 change : 1; 400 - __u8 reserved1 : 6; 401 - __u8 disc_present : 1; 402 - #else 403 - #error "Please fix <asm/byteorder.h>" 404 - #endif 405 - 406 - byte reserved2[3]; 407 - }; 408 - 409 - struct atapi_changer_info { 410 - struct atapi_mechstat_header hdr; 411 - struct atapi_slot slots[0]; 412 - }; 413 - 414 /* Extra per-device info for cdrom drives. */ 415 struct cdrom_info { 416 ide_drive_t *drive; ··· 131 int dma; 132 unsigned long last_block; 133 unsigned long start_seek; 134 - /* Buffer to hold mechanism status and changer slot table. */ 135 - struct atapi_changer_info *changer_info; 136 137 - struct ide_cd_config_flags config_flags; 138 - struct ide_cd_state_flags state_flags; 139 140 /* Per-device info needed by cdrom.c generic driver. */ 141 struct cdrom_device_info devinfo; ··· 143 unsigned long write_timeout; 144 }; 145 146 - /**************************************************************************** 147 - * Descriptions of ATAPI error codes. 148 - */ 149 150 - /* This stuff should be in cdrom.h, since it is now generic... */ 151 152 - /* ATAPI sense keys (from table 140 of ATAPI 2.6) */ 153 - #define NO_SENSE 0x00 154 - #define RECOVERED_ERROR 0x01 155 - #define NOT_READY 0x02 156 - #define MEDIUM_ERROR 0x03 157 - #define HARDWARE_ERROR 0x04 158 - #define ILLEGAL_REQUEST 0x05 159 - #define UNIT_ATTENTION 0x06 160 - #define DATA_PROTECT 0x07 161 - #define BLANK_CHECK 0x08 162 - #define ABORTED_COMMAND 0x0b 163 - #define MISCOMPARE 0x0e 164 - 165 - 166 - 167 - /* This stuff should be in cdrom.h, since it is now generic... */ 168 - #if VERBOSE_IDE_CD_ERRORS 169 - 170 - /* The generic packet command opcodes for CD/DVD Logical Units, 171 - * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ 172 - static const struct { 173 - unsigned short packet_command; 174 - const char * const text; 175 - } packet_command_texts[] = { 176 - { GPCMD_TEST_UNIT_READY, "Test Unit Ready" }, 177 - { GPCMD_REQUEST_SENSE, "Request Sense" }, 178 - { GPCMD_FORMAT_UNIT, "Format Unit" }, 179 - { GPCMD_INQUIRY, "Inquiry" }, 180 - { GPCMD_START_STOP_UNIT, "Start/Stop Unit" }, 181 - { GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL, "Prevent/Allow Medium Removal" }, 182 - { GPCMD_READ_FORMAT_CAPACITIES, "Read Format Capacities" }, 183 - { GPCMD_READ_CDVD_CAPACITY, "Read Cd/Dvd Capacity" }, 184 - { GPCMD_READ_10, "Read 10" }, 185 - { GPCMD_WRITE_10, "Write 10" }, 186 - { GPCMD_SEEK, "Seek" }, 187 - { GPCMD_WRITE_AND_VERIFY_10, "Write and Verify 10" }, 188 - { GPCMD_VERIFY_10, "Verify 10" }, 189 - { GPCMD_FLUSH_CACHE, "Flush Cache" }, 190 - { GPCMD_READ_SUBCHANNEL, "Read Subchannel" }, 191 - { GPCMD_READ_TOC_PMA_ATIP, "Read Table of Contents" }, 192 - { GPCMD_READ_HEADER, "Read Header" }, 193 - { GPCMD_PLAY_AUDIO_10, "Play Audio 10" }, 194 - { GPCMD_GET_CONFIGURATION, "Get Configuration" }, 195 - { GPCMD_PLAY_AUDIO_MSF, "Play Audio MSF" }, 196 - { GPCMD_PLAYAUDIO_TI, "Play Audio TrackIndex" }, 197 - { GPCMD_GET_EVENT_STATUS_NOTIFICATION, "Get Event Status Notification" }, 198 - { GPCMD_PAUSE_RESUME, "Pause/Resume" }, 199 - { GPCMD_STOP_PLAY_SCAN, "Stop Play/Scan" }, 200 - { GPCMD_READ_DISC_INFO, "Read Disc Info" }, 201 - { GPCMD_READ_TRACK_RZONE_INFO, "Read Track Rzone Info" }, 202 - { GPCMD_RESERVE_RZONE_TRACK, "Reserve Rzone Track" }, 203 - { GPCMD_SEND_OPC, "Send OPC" }, 204 - { GPCMD_MODE_SELECT_10, "Mode Select 10" }, 205 - { GPCMD_REPAIR_RZONE_TRACK, "Repair Rzone Track" }, 206 - { GPCMD_MODE_SENSE_10, "Mode Sense 10" }, 207 - { GPCMD_CLOSE_TRACK, "Close Track" }, 208 - { GPCMD_BLANK, "Blank" }, 209 - { GPCMD_SEND_EVENT, "Send Event" }, 210 - { GPCMD_SEND_KEY, "Send Key" }, 211 - { GPCMD_REPORT_KEY, "Report Key" }, 212 - { GPCMD_LOAD_UNLOAD, "Load/Unload" }, 213 - { GPCMD_SET_READ_AHEAD, "Set Read-ahead" }, 214 - { GPCMD_READ_12, "Read 12" }, 215 - { GPCMD_GET_PERFORMANCE, "Get Performance" }, 216 - { GPCMD_SEND_DVD_STRUCTURE, "Send DVD Structure" }, 217 - { GPCMD_READ_DVD_STRUCTURE, "Read DVD Structure" }, 218 - { GPCMD_SET_STREAMING, "Set Streaming" }, 219 - { GPCMD_READ_CD_MSF, "Read CD MSF" }, 220 - { GPCMD_SCAN, "Scan" }, 221 - { GPCMD_SET_SPEED, "Set Speed" }, 222 - { GPCMD_PLAY_CD, "Play CD" }, 223 - { GPCMD_MECHANISM_STATUS, "Mechanism Status" }, 224 - { GPCMD_READ_CD, "Read CD" }, 225 - }; 226 - 227 - 228 - 229 - /* From Table 303 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ 230 - static const char * const sense_key_texts[16] = { 231 - "No sense data", 232 - "Recovered error", 233 - "Not ready", 234 - "Medium error", 235 - "Hardware error", 236 - "Illegal request", 237 - "Unit attention", 238 - "Data protect", 239 - "Blank check", 240 - "(reserved)", 241 - "(reserved)", 242 - "Aborted command", 243 - "(reserved)", 244 - "(reserved)", 245 - "Miscompare", 246 - "(reserved)", 247 - }; 248 - 249 - /* From Table 304 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ 250 - static const struct { 251 - unsigned long asc_ascq; 252 - const char * const text; 253 - } sense_data_texts[] = { 254 - { 0x000000, "No additional sense information" }, 255 - { 0x000011, "Play operation in progress" }, 256 - { 0x000012, "Play operation paused" }, 257 - { 0x000013, "Play operation successfully completed" }, 258 - { 0x000014, "Play operation stopped due to error" }, 259 - { 0x000015, "No current audio status to return" }, 260 - { 0x010c0a, "Write error - padding blocks added" }, 261 - { 0x011700, "Recovered data with no error correction applied" }, 262 - { 0x011701, "Recovered data with retries" }, 263 - { 0x011702, "Recovered data with positive head offset" }, 264 - { 0x011703, "Recovered data with negative head offset" }, 265 - { 0x011704, "Recovered data with retries and/or CIRC applied" }, 266 - { 0x011705, "Recovered data using previous sector ID" }, 267 - { 0x011800, "Recovered data with error correction applied" }, 268 - { 0x011801, "Recovered data with error correction and retries applied"}, 269 - { 0x011802, "Recovered data - the data was auto-reallocated" }, 270 - { 0x011803, "Recovered data with CIRC" }, 271 - { 0x011804, "Recovered data with L-EC" }, 272 - { 0x015d00, 273 - "Failure prediction threshold exceeded - Predicted logical unit failure" }, 274 - { 0x015d01, 275 - "Failure prediction threshold exceeded - Predicted media failure" }, 276 - { 0x015dff, "Failure prediction threshold exceeded - False" }, 277 - { 0x017301, "Power calibration area almost full" }, 278 - { 0x020400, "Logical unit not ready - cause not reportable" }, 279 - /* Following is misspelled in ATAPI 2.6, _and_ in Mt. Fuji */ 280 - { 0x020401, 281 - "Logical unit not ready - in progress [sic] of becoming ready" }, 282 - { 0x020402, "Logical unit not ready - initializing command required" }, 283 - { 0x020403, "Logical unit not ready - manual intervention required" }, 284 - { 0x020404, "Logical unit not ready - format in progress" }, 285 - { 0x020407, "Logical unit not ready - operation in progress" }, 286 - { 0x020408, "Logical unit not ready - long write in progress" }, 287 - { 0x020600, "No reference position found (media may be upside down)" }, 288 - { 0x023000, "Incompatible medium installed" }, 289 - { 0x023a00, "Medium not present" }, 290 - { 0x025300, "Media load or eject failed" }, 291 - { 0x025700, "Unable to recover table of contents" }, 292 - { 0x030300, "Peripheral device write fault" }, 293 - { 0x030301, "No write current" }, 294 - { 0x030302, "Excessive write errors" }, 295 - { 0x030c00, "Write error" }, 296 - { 0x030c01, "Write error - Recovered with auto reallocation" }, 297 - { 0x030c02, "Write error - auto reallocation failed" }, 298 - { 0x030c03, "Write error - recommend reassignment" }, 299 - { 0x030c04, "Compression check miscompare error" }, 300 - { 0x030c05, "Data expansion occurred during compress" }, 301 - { 0x030c06, "Block not compressible" }, 302 - { 0x030c07, "Write error - recovery needed" }, 303 - { 0x030c08, "Write error - recovery failed" }, 304 - { 0x030c09, "Write error - loss of streaming" }, 305 - { 0x031100, "Unrecovered read error" }, 306 - { 0x031106, "CIRC unrecovered error" }, 307 - { 0x033101, "Format command failed" }, 308 - { 0x033200, "No defect spare location available" }, 309 - { 0x033201, "Defect list update failure" }, 310 - { 0x035100, "Erase failure" }, 311 - { 0x037200, "Session fixation error" }, 312 - { 0x037201, "Session fixation error writin lead-in" }, 313 - { 0x037202, "Session fixation error writin lead-out" }, 314 - { 0x037300, "CD control error" }, 315 - { 0x037302, "Power calibration area is full" }, 316 - { 0x037303, "Power calibration area error" }, 317 - { 0x037304, "Program memory area / RMA update failure" }, 318 - { 0x037305, "Program memory area / RMA is full" }, 319 - { 0x037306, "Program memory area / RMA is (almost) full" }, 320 - 321 - { 0x040200, "No seek complete" }, 322 - { 0x040300, "Write fault" }, 323 - { 0x040900, "Track following error" }, 324 - { 0x040901, "Tracking servo failure" }, 325 - { 0x040902, "Focus servo failure" }, 326 - { 0x040903, "Spindle servo failure" }, 327 - { 0x041500, "Random positioning error" }, 328 - { 0x041501, "Mechanical positioning or changer error" }, 329 - { 0x041502, "Positioning error detected by read of medium" }, 330 - { 0x043c00, "Mechanical positioning or changer error" }, 331 - { 0x044000, "Diagnostic failure on component (ASCQ)" }, 332 - { 0x044400, "Internal CD/DVD logical unit failure" }, 333 - { 0x04b600, "Media load mechanism failed" }, 334 - { 0x051a00, "Parameter list length error" }, 335 - { 0x052000, "Invalid command operation code" }, 336 - { 0x052100, "Logical block address out of range" }, 337 - { 0x052102, "Invalid address for write" }, 338 - { 0x052400, "Invalid field in command packet" }, 339 - { 0x052600, "Invalid field in parameter list" }, 340 - { 0x052601, "Parameter not supported" }, 341 - { 0x052602, "Parameter value invalid" }, 342 - { 0x052700, "Write protected media" }, 343 - { 0x052c00, "Command sequence error" }, 344 - { 0x052c03, "Current program area is not empty" }, 345 - { 0x052c04, "Current program area is empty" }, 346 - { 0x053001, "Cannot read medium - unknown format" }, 347 - { 0x053002, "Cannot read medium - incompatible format" }, 348 - { 0x053900, "Saving parameters not supported" }, 349 - { 0x054e00, "Overlapped commands attempted" }, 350 - { 0x055302, "Medium removal prevented" }, 351 - { 0x055500, "System resource failure" }, 352 - { 0x056300, "End of user area encountered on this track" }, 353 - { 0x056400, "Illegal mode for this track or incompatible medium" }, 354 - { 0x056f00, "Copy protection key exchange failure - Authentication failure" }, 355 - { 0x056f01, "Copy protection key exchange failure - Key not present" }, 356 - { 0x056f02, "Copy protection key exchange failure - Key not established" }, 357 - { 0x056f03, "Read of scrambled sector without authentication" }, 358 - { 0x056f04, "Media region code is mismatched to logical unit" }, 359 - { 0x056f05, "Drive region must be permanent / region reset count error" }, 360 - { 0x057203, "Session fixation error - incomplete track in session" }, 361 - { 0x057204, "Empty or partially written reserved track" }, 362 - { 0x057205, "No more RZONE reservations are allowed" }, 363 - { 0x05bf00, "Loss of streaming" }, 364 - { 0x062800, "Not ready to ready transition, medium may have changed" }, 365 - { 0x062900, "Power on, reset or hardware reset occurred" }, 366 - { 0x062a00, "Parameters changed" }, 367 - { 0x062a01, "Mode parameters changed" }, 368 - { 0x062e00, "Insufficient time for operation" }, 369 - { 0x063f00, "Logical unit operating conditions have changed" }, 370 - { 0x063f01, "Microcode has been changed" }, 371 - { 0x065a00, "Operator request or state change input (unspecified)" }, 372 - { 0x065a01, "Operator medium removal request" }, 373 - { 0x0bb900, "Play operation aborted" }, 374 - 375 - /* Here we use 0xff for the key (not a valid key) to signify 376 - * that these can have _any_ key value associated with them... */ 377 - { 0xff0401, "Logical unit is in process of becoming ready" }, 378 - { 0xff0400, "Logical unit not ready, cause not reportable" }, 379 - { 0xff0402, "Logical unit not ready, initializing command required" }, 380 - { 0xff0403, "Logical unit not ready, manual intervention required" }, 381 - { 0xff0500, "Logical unit does not respond to selection" }, 382 - { 0xff0800, "Logical unit communication failure" }, 383 - { 0xff0802, "Logical unit communication parity error" }, 384 - { 0xff0801, "Logical unit communication time-out" }, 385 - { 0xff2500, "Logical unit not supported" }, 386 - { 0xff4c00, "Logical unit failed self-configuration" }, 387 - { 0xff3e00, "Logical unit has not self-configured yet" }, 388 - }; 389 - #endif 390 - 391 392 #endif /* _IDE_CD_H */
··· 1 /* 2 * Copyright (C) 1996-98 Erik Andersen 3 * Copyright (C) 1998-2000 Jens Axboe 4 */ ··· 9 10 #include <linux/cdrom.h> 11 #include <asm/byteorder.h> 12 13 /* 14 * typical timeout for packet command ··· 49 #endif 50 #define SECTORS_PER_FRAME (CD_FRAMESIZE >> SECTOR_BITS) 51 #define SECTOR_BUFFER_SIZE (CD_FRAMESIZE * 32) 52 53 + /* Capabilities Page size including 8 bytes of Mode Page Header */ 54 + #define ATAPI_CAPABILITIES_PAGE_SIZE (8 + 20) 55 + #define ATAPI_CAPABILITIES_PAGE_PAD_SIZE 4 56 57 + enum { 58 + /* Device sends an interrupt when ready for a packet command. */ 59 + IDE_CD_FLAG_DRQ_INTERRUPT = (1 << 0), 60 + /* Drive cannot lock the door. */ 61 + IDE_CD_FLAG_NO_DOORLOCK = (1 << 1), 62 + /* Drive cannot eject the disc. */ 63 + IDE_CD_FLAG_NO_EJECT = (1 << 2), 64 + /* Drive is a pre ATAPI 1.2 drive. */ 65 + IDE_CD_FLAG_PRE_ATAPI12 = (1 << 3), 66 + /* TOC addresses are in BCD. */ 67 + IDE_CD_FLAG_TOCADDR_AS_BCD = (1 << 4), 68 + /* TOC track numbers are in BCD. */ 69 + IDE_CD_FLAG_TOCTRACKS_AS_BCD = (1 << 5), 70 + /* 71 + * Drive does not provide data in multiples of SECTOR_SIZE 72 + * when more than one interrupt is needed. 73 + */ 74 + IDE_CD_FLAG_LIMIT_NFRAMES = (1 << 6), 75 + /* Seeking in progress. */ 76 + IDE_CD_FLAG_SEEKING = (1 << 7), 77 + /* Driver has noticed a media change. */ 78 + IDE_CD_FLAG_MEDIA_CHANGED = (1 << 8), 79 + /* Saved TOC information is current. */ 80 + IDE_CD_FLAG_TOC_VALID = (1 << 9), 81 + /* We think that the drive door is locked. */ 82 + IDE_CD_FLAG_DOOR_LOCKED = (1 << 10), 83 + /* SET_CD_SPEED command is unsupported. */ 84 + IDE_CD_FLAG_NO_SPEED_SELECT = (1 << 11), 85 + IDE_CD_FLAG_VERTOS_300_SSD = (1 << 12), 86 + IDE_CD_FLAG_VERTOS_600_ESD = (1 << 13), 87 + IDE_CD_FLAG_SANYO_3CD = (1 << 14), 88 + IDE_CD_FLAG_FULL_CAPS_PAGE = (1 << 15), 89 + IDE_CD_FLAG_PLAY_AUDIO_OK = (1 << 16), 90 + IDE_CD_FLAG_LE_SPEED_FIELDS = (1 << 17), 91 }; 92 93 /* Structure of a MSF cdrom address. */ 94 struct atapi_msf { ··· 155 /* One extra for the leadout. */ 156 }; 157 158 /* Extra per-device info for cdrom drives. */ 159 struct cdrom_info { 160 ide_drive_t *drive; ··· 483 int dma; 484 unsigned long last_block; 485 unsigned long start_seek; 486 487 + unsigned int cd_flags; 488 + 489 + u8 max_speed; /* Max speed of the drive. */ 490 + u8 current_speed; /* Current speed of the drive. */ 491 492 /* Per-device info needed by cdrom.c generic driver. */ 493 struct cdrom_device_info devinfo; ··· 495 unsigned long write_timeout; 496 }; 497 498 + /* ide-cd_verbose.c */ 499 + void ide_cd_log_error(const char *, struct request *, struct request_sense *); 500 501 + /* ide-cd.c functions used by ide-cd_ioctl.c */ 502 + void ide_cd_init_rq(ide_drive_t *, struct request *); 503 + int ide_cd_queue_pc(ide_drive_t *, struct request *); 504 + int ide_cd_read_toc(ide_drive_t *, struct request_sense *); 505 + int ide_cdrom_get_capabilities(ide_drive_t *, u8 *); 506 + void ide_cdrom_update_speed(ide_drive_t *, u8 *); 507 + int cdrom_check_status(ide_drive_t *, struct request_sense *); 508 509 + /* ide-cd_ioctl.c */ 510 + int ide_cdrom_open_real(struct cdrom_device_info *, int); 511 + void ide_cdrom_release_real(struct cdrom_device_info *); 512 + int ide_cdrom_drive_status(struct cdrom_device_info *, int); 513 + int ide_cdrom_check_media_change_real(struct cdrom_device_info *, int); 514 + int ide_cdrom_tray_move(struct cdrom_device_info *, int); 515 + int ide_cdrom_lock_door(struct cdrom_device_info *, int); 516 + int ide_cdrom_select_speed(struct cdrom_device_info *, int); 517 + int ide_cdrom_get_last_session(struct cdrom_device_info *, 518 + struct cdrom_multisession *); 519 + int ide_cdrom_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *); 520 + int ide_cdrom_reset(struct cdrom_device_info *cdi); 521 + int ide_cdrom_audio_ioctl(struct cdrom_device_info *, unsigned int, void *); 522 + int ide_cdrom_packet(struct cdrom_device_info *, struct packet_command *); 523 524 #endif /* _IDE_CD_H */
+475
drivers/ide/ide-cd_ioctl.c
···
··· 1 + /* 2 + * cdrom.c IOCTLs handling for ide-cd driver. 3 + * 4 + * Copyright (C) 1994-1996 Scott Snyder <snyder@fnald0.fnal.gov> 5 + * Copyright (C) 1996-1998 Erik Andersen <andersee@debian.org> 6 + * Copyright (C) 1998-2000 Jens Axboe <axboe@suse.de> 7 + */ 8 + 9 + #include <linux/kernel.h> 10 + #include <linux/cdrom.h> 11 + #include <linux/ide.h> 12 + #include <scsi/scsi.h> 13 + 14 + #include "ide-cd.h" 15 + 16 + /**************************************************************************** 17 + * Other driver requests (open, close, check media change). 18 + */ 19 + int ide_cdrom_open_real(struct cdrom_device_info *cdi, int purpose) 20 + { 21 + return 0; 22 + } 23 + 24 + /* 25 + * Close down the device. Invalidate all cached blocks. 26 + */ 27 + void ide_cdrom_release_real(struct cdrom_device_info *cdi) 28 + { 29 + ide_drive_t *drive = cdi->handle; 30 + struct cdrom_info *cd = drive->driver_data; 31 + 32 + if (!cdi->use_count) 33 + cd->cd_flags &= ~IDE_CD_FLAG_TOC_VALID; 34 + } 35 + 36 + /* 37 + * add logic to try GET_EVENT command first to check for media and tray 38 + * status. this should be supported by newer cd-r/w and all DVD etc 39 + * drives 40 + */ 41 + int ide_cdrom_drive_status(struct cdrom_device_info *cdi, int slot_nr) 42 + { 43 + ide_drive_t *drive = cdi->handle; 44 + struct media_event_desc med; 45 + struct request_sense sense; 46 + int stat; 47 + 48 + if (slot_nr != CDSL_CURRENT) 49 + return -EINVAL; 50 + 51 + stat = cdrom_check_status(drive, &sense); 52 + if (!stat || sense.sense_key == UNIT_ATTENTION) 53 + return CDS_DISC_OK; 54 + 55 + if (!cdrom_get_media_event(cdi, &med)) { 56 + if (med.media_present) 57 + return CDS_DISC_OK; 58 + else if (med.door_open) 59 + return CDS_TRAY_OPEN; 60 + else 61 + return CDS_NO_DISC; 62 + } 63 + 64 + if (sense.sense_key == NOT_READY && sense.asc == 0x04 65 + && sense.ascq == 0x04) 66 + return CDS_DISC_OK; 67 + 68 + /* 69 + * If not using Mt Fuji extended media tray reports, 70 + * just return TRAY_OPEN since ATAPI doesn't provide 71 + * any other way to detect this... 72 + */ 73 + if (sense.sense_key == NOT_READY) { 74 + if (sense.asc == 0x3a && sense.ascq == 1) 75 + return CDS_NO_DISC; 76 + else 77 + return CDS_TRAY_OPEN; 78 + } 79 + return CDS_DRIVE_NOT_READY; 80 + } 81 + 82 + int ide_cdrom_check_media_change_real(struct cdrom_device_info *cdi, 83 + int slot_nr) 84 + { 85 + ide_drive_t *drive = cdi->handle; 86 + struct cdrom_info *cd = drive->driver_data; 87 + int retval; 88 + 89 + if (slot_nr == CDSL_CURRENT) { 90 + (void) cdrom_check_status(drive, NULL); 91 + retval = (cd->cd_flags & IDE_CD_FLAG_MEDIA_CHANGED) ? 1 : 0; 92 + cd->cd_flags &= ~IDE_CD_FLAG_MEDIA_CHANGED; 93 + return retval; 94 + } else { 95 + return -EINVAL; 96 + } 97 + } 98 + 99 + /* Eject the disk if EJECTFLAG is 0. 100 + If EJECTFLAG is 1, try to reload the disk. */ 101 + static 102 + int cdrom_eject(ide_drive_t *drive, int ejectflag, 103 + struct request_sense *sense) 104 + { 105 + struct cdrom_info *cd = drive->driver_data; 106 + struct cdrom_device_info *cdi = &cd->devinfo; 107 + struct request req; 108 + char loej = 0x02; 109 + 110 + if ((cd->cd_flags & IDE_CD_FLAG_NO_EJECT) && !ejectflag) 111 + return -EDRIVE_CANT_DO_THIS; 112 + 113 + /* reload fails on some drives, if the tray is locked */ 114 + if ((cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) && ejectflag) 115 + return 0; 116 + 117 + ide_cd_init_rq(drive, &req); 118 + 119 + /* only tell drive to close tray if open, if it can do that */ 120 + if (ejectflag && (cdi->mask & CDC_CLOSE_TRAY)) 121 + loej = 0; 122 + 123 + req.sense = sense; 124 + req.cmd[0] = GPCMD_START_STOP_UNIT; 125 + req.cmd[4] = loej | (ejectflag != 0); 126 + 127 + return ide_cd_queue_pc(drive, &req); 128 + } 129 + 130 + /* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */ 131 + static 132 + int ide_cd_lockdoor(ide_drive_t *drive, int lockflag, 133 + struct request_sense *sense) 134 + { 135 + struct cdrom_info *cd = drive->driver_data; 136 + struct request_sense my_sense; 137 + struct request req; 138 + int stat; 139 + 140 + if (sense == NULL) 141 + sense = &my_sense; 142 + 143 + /* If the drive cannot lock the door, just pretend. */ 144 + if (cd->cd_flags & IDE_CD_FLAG_NO_DOORLOCK) { 145 + stat = 0; 146 + } else { 147 + ide_cd_init_rq(drive, &req); 148 + req.sense = sense; 149 + req.cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; 150 + req.cmd[4] = lockflag ? 1 : 0; 151 + stat = ide_cd_queue_pc(drive, &req); 152 + } 153 + 154 + /* If we got an illegal field error, the drive 155 + probably cannot lock the door. */ 156 + if (stat != 0 && 157 + sense->sense_key == ILLEGAL_REQUEST && 158 + (sense->asc == 0x24 || sense->asc == 0x20)) { 159 + printk(KERN_ERR "%s: door locking not supported\n", 160 + drive->name); 161 + cd->cd_flags |= IDE_CD_FLAG_NO_DOORLOCK; 162 + stat = 0; 163 + } 164 + 165 + /* no medium, that's alright. */ 166 + if (stat != 0 && sense->sense_key == NOT_READY && sense->asc == 0x3a) 167 + stat = 0; 168 + 169 + if (stat == 0) { 170 + if (lockflag) 171 + cd->cd_flags |= IDE_CD_FLAG_DOOR_LOCKED; 172 + else 173 + cd->cd_flags &= ~IDE_CD_FLAG_DOOR_LOCKED; 174 + } 175 + 176 + return stat; 177 + } 178 + 179 + int ide_cdrom_tray_move(struct cdrom_device_info *cdi, int position) 180 + { 181 + ide_drive_t *drive = cdi->handle; 182 + struct request_sense sense; 183 + 184 + if (position) { 185 + int stat = ide_cd_lockdoor(drive, 0, &sense); 186 + 187 + if (stat) 188 + return stat; 189 + } 190 + 191 + return cdrom_eject(drive, !position, &sense); 192 + } 193 + 194 + int ide_cdrom_lock_door(struct cdrom_device_info *cdi, int lock) 195 + { 196 + ide_drive_t *drive = cdi->handle; 197 + 198 + return ide_cd_lockdoor(drive, lock, NULL); 199 + } 200 + 201 + /* 202 + * ATAPI devices are free to select the speed you request or any slower 203 + * rate. :-( Requesting too fast a speed will _not_ produce an error. 204 + */ 205 + int ide_cdrom_select_speed(struct cdrom_device_info *cdi, int speed) 206 + { 207 + ide_drive_t *drive = cdi->handle; 208 + struct cdrom_info *cd = drive->driver_data; 209 + struct request rq; 210 + struct request_sense sense; 211 + u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; 212 + int stat; 213 + 214 + ide_cd_init_rq(drive, &rq); 215 + 216 + rq.sense = &sense; 217 + 218 + if (speed == 0) 219 + speed = 0xffff; /* set to max */ 220 + else 221 + speed *= 177; /* Nx to kbytes/s */ 222 + 223 + rq.cmd[0] = GPCMD_SET_SPEED; 224 + /* Read Drive speed in kbytes/second MSB/LSB */ 225 + rq.cmd[2] = (speed >> 8) & 0xff; 226 + rq.cmd[3] = speed & 0xff; 227 + if ((cdi->mask & (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) != 228 + (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) { 229 + /* Write Drive speed in kbytes/second MSB/LSB */ 230 + rq.cmd[4] = (speed >> 8) & 0xff; 231 + rq.cmd[5] = speed & 0xff; 232 + } 233 + 234 + stat = ide_cd_queue_pc(drive, &rq); 235 + 236 + if (!ide_cdrom_get_capabilities(drive, buf)) { 237 + ide_cdrom_update_speed(drive, buf); 238 + cdi->speed = cd->current_speed; 239 + } 240 + 241 + return 0; 242 + } 243 + 244 + int ide_cdrom_get_last_session(struct cdrom_device_info *cdi, 245 + struct cdrom_multisession *ms_info) 246 + { 247 + struct atapi_toc *toc; 248 + ide_drive_t *drive = cdi->handle; 249 + struct cdrom_info *info = drive->driver_data; 250 + struct request_sense sense; 251 + int ret; 252 + 253 + if ((info->cd_flags & IDE_CD_FLAG_TOC_VALID) == 0 || !info->toc) { 254 + ret = ide_cd_read_toc(drive, &sense); 255 + if (ret) 256 + return ret; 257 + } 258 + 259 + toc = info->toc; 260 + ms_info->addr.lba = toc->last_session_lba; 261 + ms_info->xa_flag = toc->xa_flag; 262 + 263 + return 0; 264 + } 265 + 266 + int ide_cdrom_get_mcn(struct cdrom_device_info *cdi, 267 + struct cdrom_mcn *mcn_info) 268 + { 269 + ide_drive_t *drive = cdi->handle; 270 + int stat, mcnlen; 271 + struct request rq; 272 + char buf[24]; 273 + 274 + ide_cd_init_rq(drive, &rq); 275 + 276 + rq.data = buf; 277 + rq.data_len = sizeof(buf); 278 + 279 + rq.cmd[0] = GPCMD_READ_SUBCHANNEL; 280 + rq.cmd[1] = 2; /* MSF addressing */ 281 + rq.cmd[2] = 0x40; /* request subQ data */ 282 + rq.cmd[3] = 2; /* format */ 283 + rq.cmd[8] = sizeof(buf); 284 + 285 + stat = ide_cd_queue_pc(drive, &rq); 286 + if (stat) 287 + return stat; 288 + 289 + mcnlen = sizeof(mcn_info->medium_catalog_number) - 1; 290 + memcpy(mcn_info->medium_catalog_number, buf + 9, mcnlen); 291 + mcn_info->medium_catalog_number[mcnlen] = '\0'; 292 + 293 + return 0; 294 + } 295 + 296 + int ide_cdrom_reset(struct cdrom_device_info *cdi) 297 + { 298 + ide_drive_t *drive = cdi->handle; 299 + struct cdrom_info *cd = drive->driver_data; 300 + struct request_sense sense; 301 + struct request req; 302 + int ret; 303 + 304 + ide_cd_init_rq(drive, &req); 305 + req.cmd_type = REQ_TYPE_SPECIAL; 306 + req.cmd_flags = REQ_QUIET; 307 + ret = ide_do_drive_cmd(drive, &req, ide_wait); 308 + 309 + /* 310 + * A reset will unlock the door. If it was previously locked, 311 + * lock it again. 312 + */ 313 + if (cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) 314 + (void)ide_cd_lockdoor(drive, 1, &sense); 315 + 316 + return ret; 317 + } 318 + 319 + static int ide_cd_get_toc_entry(ide_drive_t *drive, int track, 320 + struct atapi_toc_entry **ent) 321 + { 322 + struct cdrom_info *info = drive->driver_data; 323 + struct atapi_toc *toc = info->toc; 324 + int ntracks; 325 + 326 + /* 327 + * don't serve cached data, if the toc isn't valid 328 + */ 329 + if ((info->cd_flags & IDE_CD_FLAG_TOC_VALID) == 0) 330 + return -EINVAL; 331 + 332 + /* Check validity of requested track number. */ 333 + ntracks = toc->hdr.last_track - toc->hdr.first_track + 1; 334 + 335 + if (toc->hdr.first_track == CDROM_LEADOUT) 336 + ntracks = 0; 337 + 338 + if (track == CDROM_LEADOUT) 339 + *ent = &toc->ent[ntracks]; 340 + else if (track < toc->hdr.first_track || track > toc->hdr.last_track) 341 + return -EINVAL; 342 + else 343 + *ent = &toc->ent[track - toc->hdr.first_track]; 344 + 345 + return 0; 346 + } 347 + 348 + static int ide_cd_fake_play_trkind(ide_drive_t *drive, void *arg) 349 + { 350 + struct cdrom_ti *ti = arg; 351 + struct atapi_toc_entry *first_toc, *last_toc; 352 + unsigned long lba_start, lba_end; 353 + int stat; 354 + struct request rq; 355 + struct request_sense sense; 356 + 357 + stat = ide_cd_get_toc_entry(drive, ti->cdti_trk0, &first_toc); 358 + if (stat) 359 + return stat; 360 + 361 + stat = ide_cd_get_toc_entry(drive, ti->cdti_trk1, &last_toc); 362 + if (stat) 363 + return stat; 364 + 365 + if (ti->cdti_trk1 != CDROM_LEADOUT) 366 + ++last_toc; 367 + lba_start = first_toc->addr.lba; 368 + lba_end = last_toc->addr.lba; 369 + 370 + if (lba_end <= lba_start) 371 + return -EINVAL; 372 + 373 + ide_cd_init_rq(drive, &rq); 374 + 375 + rq.sense = &sense; 376 + rq.cmd[0] = GPCMD_PLAY_AUDIO_MSF; 377 + lba_to_msf(lba_start, &rq.cmd[3], &rq.cmd[4], &rq.cmd[5]); 378 + lba_to_msf(lba_end - 1, &rq.cmd[6], &rq.cmd[7], &rq.cmd[8]); 379 + 380 + return ide_cd_queue_pc(drive, &rq); 381 + } 382 + 383 + static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg) 384 + { 385 + struct cdrom_info *cd = drive->driver_data; 386 + struct cdrom_tochdr *tochdr = arg; 387 + struct atapi_toc *toc; 388 + int stat; 389 + 390 + /* Make sure our saved TOC is valid. */ 391 + stat = ide_cd_read_toc(drive, NULL); 392 + if (stat) 393 + return stat; 394 + 395 + toc = cd->toc; 396 + tochdr->cdth_trk0 = toc->hdr.first_track; 397 + tochdr->cdth_trk1 = toc->hdr.last_track; 398 + 399 + return 0; 400 + } 401 + 402 + static int ide_cd_read_tocentry(ide_drive_t *drive, void *arg) 403 + { 404 + struct cdrom_tocentry *tocentry = arg; 405 + struct atapi_toc_entry *toce; 406 + int stat; 407 + 408 + stat = ide_cd_get_toc_entry(drive, tocentry->cdte_track, &toce); 409 + if (stat) 410 + return stat; 411 + 412 + tocentry->cdte_ctrl = toce->control; 413 + tocentry->cdte_adr = toce->adr; 414 + if (tocentry->cdte_format == CDROM_MSF) { 415 + lba_to_msf(toce->addr.lba, 416 + &tocentry->cdte_addr.msf.minute, 417 + &tocentry->cdte_addr.msf.second, 418 + &tocentry->cdte_addr.msf.frame); 419 + } else 420 + tocentry->cdte_addr.lba = toce->addr.lba; 421 + 422 + return 0; 423 + } 424 + 425 + int ide_cdrom_audio_ioctl(struct cdrom_device_info *cdi, 426 + unsigned int cmd, void *arg) 427 + { 428 + ide_drive_t *drive = cdi->handle; 429 + 430 + switch (cmd) { 431 + /* 432 + * emulate PLAY_AUDIO_TI command with PLAY_AUDIO_10, since 433 + * atapi doesn't support it 434 + */ 435 + case CDROMPLAYTRKIND: 436 + return ide_cd_fake_play_trkind(drive, arg); 437 + case CDROMREADTOCHDR: 438 + return ide_cd_read_tochdr(drive, arg); 439 + case CDROMREADTOCENTRY: 440 + return ide_cd_read_tocentry(drive, arg); 441 + default: 442 + return -EINVAL; 443 + } 444 + } 445 + 446 + /* the generic packet interface to cdrom.c */ 447 + int ide_cdrom_packet(struct cdrom_device_info *cdi, 448 + struct packet_command *cgc) 449 + { 450 + struct request req; 451 + ide_drive_t *drive = cdi->handle; 452 + 453 + if (cgc->timeout <= 0) 454 + cgc->timeout = ATAPI_WAIT_PC; 455 + 456 + /* here we queue the commands from the uniform CD-ROM 457 + layer. the packet must be complete, as we do not 458 + touch it at all. */ 459 + ide_cd_init_rq(drive, &req); 460 + memcpy(req.cmd, cgc->cmd, CDROM_PACKET_SIZE); 461 + if (cgc->sense) 462 + memset(cgc->sense, 0, sizeof(struct request_sense)); 463 + req.data = cgc->buffer; 464 + req.data_len = cgc->buflen; 465 + req.timeout = cgc->timeout; 466 + 467 + if (cgc->quiet) 468 + req.cmd_flags |= REQ_QUIET; 469 + 470 + req.sense = cgc->sense; 471 + cgc->stat = ide_cd_queue_pc(drive, &req); 472 + if (!cgc->stat) 473 + cgc->buflen -= req.data_len; 474 + return cgc->stat; 475 + }
+359
drivers/ide/ide-cd_verbose.c
···
··· 1 + /* 2 + * Verbose error logging for ATAPI CD/DVD devices. 3 + * 4 + * Copyright (C) 1994-1996 Scott Snyder <snyder@fnald0.fnal.gov> 5 + * Copyright (C) 1996-1998 Erik Andersen <andersee@debian.org> 6 + * Copyright (C) 1998-2000 Jens Axboe <axboe@suse.de> 7 + */ 8 + 9 + #include <linux/kernel.h> 10 + #include <linux/blkdev.h> 11 + #include <linux/cdrom.h> 12 + #include <scsi/scsi.h> 13 + 14 + #ifndef CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS 15 + void ide_cd_log_error(const char *name, struct request *failed_command, 16 + struct request_sense *sense) 17 + { 18 + /* Suppress printing unit attention and `in progress of becoming ready' 19 + errors when we're not being verbose. */ 20 + if (sense->sense_key == UNIT_ATTENTION || 21 + (sense->sense_key == NOT_READY && (sense->asc == 4 || 22 + sense->asc == 0x3a))) 23 + return; 24 + 25 + printk(KERN_ERR "%s: error code: 0x%02x sense_key: 0x%02x " 26 + "asc: 0x%02x ascq: 0x%02x\n", 27 + name, sense->error_code, sense->sense_key, 28 + sense->asc, sense->ascq); 29 + } 30 + #else 31 + /* The generic packet command opcodes for CD/DVD Logical Units, 32 + * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ 33 + static const struct { 34 + unsigned short packet_command; 35 + const char * const text; 36 + } packet_command_texts[] = { 37 + { GPCMD_TEST_UNIT_READY, "Test Unit Ready" }, 38 + { GPCMD_REQUEST_SENSE, "Request Sense" }, 39 + { GPCMD_FORMAT_UNIT, "Format Unit" }, 40 + { GPCMD_INQUIRY, "Inquiry" }, 41 + { GPCMD_START_STOP_UNIT, "Start/Stop Unit" }, 42 + { GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL, "Prevent/Allow Medium Removal" }, 43 + { GPCMD_READ_FORMAT_CAPACITIES, "Read Format Capacities" }, 44 + { GPCMD_READ_CDVD_CAPACITY, "Read Cd/Dvd Capacity" }, 45 + { GPCMD_READ_10, "Read 10" }, 46 + { GPCMD_WRITE_10, "Write 10" }, 47 + { GPCMD_SEEK, "Seek" }, 48 + { GPCMD_WRITE_AND_VERIFY_10, "Write and Verify 10" }, 49 + { GPCMD_VERIFY_10, "Verify 10" }, 50 + { GPCMD_FLUSH_CACHE, "Flush Cache" }, 51 + { GPCMD_READ_SUBCHANNEL, "Read Subchannel" }, 52 + { GPCMD_READ_TOC_PMA_ATIP, "Read Table of Contents" }, 53 + { GPCMD_READ_HEADER, "Read Header" }, 54 + { GPCMD_PLAY_AUDIO_10, "Play Audio 10" }, 55 + { GPCMD_GET_CONFIGURATION, "Get Configuration" }, 56 + { GPCMD_PLAY_AUDIO_MSF, "Play Audio MSF" }, 57 + { GPCMD_PLAYAUDIO_TI, "Play Audio TrackIndex" }, 58 + { GPCMD_GET_EVENT_STATUS_NOTIFICATION, 59 + "Get Event Status Notification" }, 60 + { GPCMD_PAUSE_RESUME, "Pause/Resume" }, 61 + { GPCMD_STOP_PLAY_SCAN, "Stop Play/Scan" }, 62 + { GPCMD_READ_DISC_INFO, "Read Disc Info" }, 63 + { GPCMD_READ_TRACK_RZONE_INFO, "Read Track Rzone Info" }, 64 + { GPCMD_RESERVE_RZONE_TRACK, "Reserve Rzone Track" }, 65 + { GPCMD_SEND_OPC, "Send OPC" }, 66 + { GPCMD_MODE_SELECT_10, "Mode Select 10" }, 67 + { GPCMD_REPAIR_RZONE_TRACK, "Repair Rzone Track" }, 68 + { GPCMD_MODE_SENSE_10, "Mode Sense 10" }, 69 + { GPCMD_CLOSE_TRACK, "Close Track" }, 70 + { GPCMD_BLANK, "Blank" }, 71 + { GPCMD_SEND_EVENT, "Send Event" }, 72 + { GPCMD_SEND_KEY, "Send Key" }, 73 + { GPCMD_REPORT_KEY, "Report Key" }, 74 + { GPCMD_LOAD_UNLOAD, "Load/Unload" }, 75 + { GPCMD_SET_READ_AHEAD, "Set Read-ahead" }, 76 + { GPCMD_READ_12, "Read 12" }, 77 + { GPCMD_GET_PERFORMANCE, "Get Performance" }, 78 + { GPCMD_SEND_DVD_STRUCTURE, "Send DVD Structure" }, 79 + { GPCMD_READ_DVD_STRUCTURE, "Read DVD Structure" }, 80 + { GPCMD_SET_STREAMING, "Set Streaming" }, 81 + { GPCMD_READ_CD_MSF, "Read CD MSF" }, 82 + { GPCMD_SCAN, "Scan" }, 83 + { GPCMD_SET_SPEED, "Set Speed" }, 84 + { GPCMD_PLAY_CD, "Play CD" }, 85 + { GPCMD_MECHANISM_STATUS, "Mechanism Status" }, 86 + { GPCMD_READ_CD, "Read CD" }, 87 + }; 88 + 89 + /* From Table 303 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ 90 + static const char * const sense_key_texts[16] = { 91 + "No sense data", 92 + "Recovered error", 93 + "Not ready", 94 + "Medium error", 95 + "Hardware error", 96 + "Illegal request", 97 + "Unit attention", 98 + "Data protect", 99 + "Blank check", 100 + "(reserved)", 101 + "(reserved)", 102 + "Aborted command", 103 + "(reserved)", 104 + "(reserved)", 105 + "Miscompare", 106 + "(reserved)", 107 + }; 108 + 109 + /* From Table 304 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ 110 + static const struct { 111 + unsigned long asc_ascq; 112 + const char * const text; 113 + } sense_data_texts[] = { 114 + { 0x000000, "No additional sense information" }, 115 + { 0x000011, "Play operation in progress" }, 116 + { 0x000012, "Play operation paused" }, 117 + { 0x000013, "Play operation successfully completed" }, 118 + { 0x000014, "Play operation stopped due to error" }, 119 + { 0x000015, "No current audio status to return" }, 120 + { 0x010c0a, "Write error - padding blocks added" }, 121 + { 0x011700, "Recovered data with no error correction applied" }, 122 + { 0x011701, "Recovered data with retries" }, 123 + { 0x011702, "Recovered data with positive head offset" }, 124 + { 0x011703, "Recovered data with negative head offset" }, 125 + { 0x011704, "Recovered data with retries and/or CIRC applied" }, 126 + { 0x011705, "Recovered data using previous sector ID" }, 127 + { 0x011800, "Recovered data with error correction applied" }, 128 + { 0x011801, "Recovered data with error correction and retries applied"}, 129 + { 0x011802, "Recovered data - the data was auto-reallocated" }, 130 + { 0x011803, "Recovered data with CIRC" }, 131 + { 0x011804, "Recovered data with L-EC" }, 132 + { 0x015d00, "Failure prediction threshold exceeded" 133 + " - Predicted logical unit failure" }, 134 + { 0x015d01, "Failure prediction threshold exceeded" 135 + " - Predicted media failure" }, 136 + { 0x015dff, "Failure prediction threshold exceeded - False" }, 137 + { 0x017301, "Power calibration area almost full" }, 138 + { 0x020400, "Logical unit not ready - cause not reportable" }, 139 + /* Following is misspelled in ATAPI 2.6, _and_ in Mt. Fuji */ 140 + { 0x020401, "Logical unit not ready" 141 + " - in progress [sic] of becoming ready" }, 142 + { 0x020402, "Logical unit not ready - initializing command required" }, 143 + { 0x020403, "Logical unit not ready - manual intervention required" }, 144 + { 0x020404, "Logical unit not ready - format in progress" }, 145 + { 0x020407, "Logical unit not ready - operation in progress" }, 146 + { 0x020408, "Logical unit not ready - long write in progress" }, 147 + { 0x020600, "No reference position found (media may be upside down)" }, 148 + { 0x023000, "Incompatible medium installed" }, 149 + { 0x023a00, "Medium not present" }, 150 + { 0x025300, "Media load or eject failed" }, 151 + { 0x025700, "Unable to recover table of contents" }, 152 + { 0x030300, "Peripheral device write fault" }, 153 + { 0x030301, "No write current" }, 154 + { 0x030302, "Excessive write errors" }, 155 + { 0x030c00, "Write error" }, 156 + { 0x030c01, "Write error - Recovered with auto reallocation" }, 157 + { 0x030c02, "Write error - auto reallocation failed" }, 158 + { 0x030c03, "Write error - recommend reassignment" }, 159 + { 0x030c04, "Compression check miscompare error" }, 160 + { 0x030c05, "Data expansion occurred during compress" }, 161 + { 0x030c06, "Block not compressible" }, 162 + { 0x030c07, "Write error - recovery needed" }, 163 + { 0x030c08, "Write error - recovery failed" }, 164 + { 0x030c09, "Write error - loss of streaming" }, 165 + { 0x031100, "Unrecovered read error" }, 166 + { 0x031106, "CIRC unrecovered error" }, 167 + { 0x033101, "Format command failed" }, 168 + { 0x033200, "No defect spare location available" }, 169 + { 0x033201, "Defect list update failure" }, 170 + { 0x035100, "Erase failure" }, 171 + { 0x037200, "Session fixation error" }, 172 + { 0x037201, "Session fixation error writin lead-in" }, 173 + { 0x037202, "Session fixation error writin lead-out" }, 174 + { 0x037300, "CD control error" }, 175 + { 0x037302, "Power calibration area is full" }, 176 + { 0x037303, "Power calibration area error" }, 177 + { 0x037304, "Program memory area / RMA update failure" }, 178 + { 0x037305, "Program memory area / RMA is full" }, 179 + { 0x037306, "Program memory area / RMA is (almost) full" }, 180 + { 0x040200, "No seek complete" }, 181 + { 0x040300, "Write fault" }, 182 + { 0x040900, "Track following error" }, 183 + { 0x040901, "Tracking servo failure" }, 184 + { 0x040902, "Focus servo failure" }, 185 + { 0x040903, "Spindle servo failure" }, 186 + { 0x041500, "Random positioning error" }, 187 + { 0x041501, "Mechanical positioning or changer error" }, 188 + { 0x041502, "Positioning error detected by read of medium" }, 189 + { 0x043c00, "Mechanical positioning or changer error" }, 190 + { 0x044000, "Diagnostic failure on component (ASCQ)" }, 191 + { 0x044400, "Internal CD/DVD logical unit failure" }, 192 + { 0x04b600, "Media load mechanism failed" }, 193 + { 0x051a00, "Parameter list length error" }, 194 + { 0x052000, "Invalid command operation code" }, 195 + { 0x052100, "Logical block address out of range" }, 196 + { 0x052102, "Invalid address for write" }, 197 + { 0x052400, "Invalid field in command packet" }, 198 + { 0x052600, "Invalid field in parameter list" }, 199 + { 0x052601, "Parameter not supported" }, 200 + { 0x052602, "Parameter value invalid" }, 201 + { 0x052700, "Write protected media" }, 202 + { 0x052c00, "Command sequence error" }, 203 + { 0x052c03, "Current program area is not empty" }, 204 + { 0x052c04, "Current program area is empty" }, 205 + { 0x053001, "Cannot read medium - unknown format" }, 206 + { 0x053002, "Cannot read medium - incompatible format" }, 207 + { 0x053900, "Saving parameters not supported" }, 208 + { 0x054e00, "Overlapped commands attempted" }, 209 + { 0x055302, "Medium removal prevented" }, 210 + { 0x055500, "System resource failure" }, 211 + { 0x056300, "End of user area encountered on this track" }, 212 + { 0x056400, "Illegal mode for this track or incompatible medium" }, 213 + { 0x056f00, "Copy protection key exchange failure" 214 + " - Authentication failure" }, 215 + { 0x056f01, "Copy protection key exchange failure - Key not present" }, 216 + { 0x056f02, "Copy protection key exchange failure" 217 + " - Key not established" }, 218 + { 0x056f03, "Read of scrambled sector without authentication" }, 219 + { 0x056f04, "Media region code is mismatched to logical unit" }, 220 + { 0x056f05, "Drive region must be permanent" 221 + " / region reset count error" }, 222 + { 0x057203, "Session fixation error - incomplete track in session" }, 223 + { 0x057204, "Empty or partially written reserved track" }, 224 + { 0x057205, "No more RZONE reservations are allowed" }, 225 + { 0x05bf00, "Loss of streaming" }, 226 + { 0x062800, "Not ready to ready transition, medium may have changed" }, 227 + { 0x062900, "Power on, reset or hardware reset occurred" }, 228 + { 0x062a00, "Parameters changed" }, 229 + { 0x062a01, "Mode parameters changed" }, 230 + { 0x062e00, "Insufficient time for operation" }, 231 + { 0x063f00, "Logical unit operating conditions have changed" }, 232 + { 0x063f01, "Microcode has been changed" }, 233 + { 0x065a00, "Operator request or state change input (unspecified)" }, 234 + { 0x065a01, "Operator medium removal request" }, 235 + { 0x0bb900, "Play operation aborted" }, 236 + /* Here we use 0xff for the key (not a valid key) to signify 237 + * that these can have _any_ key value associated with them... */ 238 + { 0xff0401, "Logical unit is in process of becoming ready" }, 239 + { 0xff0400, "Logical unit not ready, cause not reportable" }, 240 + { 0xff0402, "Logical unit not ready, initializing command required" }, 241 + { 0xff0403, "Logical unit not ready, manual intervention required" }, 242 + { 0xff0500, "Logical unit does not respond to selection" }, 243 + { 0xff0800, "Logical unit communication failure" }, 244 + { 0xff0802, "Logical unit communication parity error" }, 245 + { 0xff0801, "Logical unit communication time-out" }, 246 + { 0xff2500, "Logical unit not supported" }, 247 + { 0xff4c00, "Logical unit failed self-configuration" }, 248 + { 0xff3e00, "Logical unit has not self-configured yet" }, 249 + }; 250 + 251 + void ide_cd_log_error(const char *name, struct request *failed_command, 252 + struct request_sense *sense) 253 + { 254 + int i; 255 + const char *s = "bad sense key!"; 256 + char buf[80]; 257 + 258 + printk(KERN_ERR "ATAPI device %s:\n", name); 259 + if (sense->error_code == 0x70) 260 + printk(KERN_CONT " Error: "); 261 + else if (sense->error_code == 0x71) 262 + printk(" Deferred Error: "); 263 + else if (sense->error_code == 0x7f) 264 + printk(KERN_CONT " Vendor-specific Error: "); 265 + else 266 + printk(KERN_CONT " Unknown Error Type: "); 267 + 268 + if (sense->sense_key < ARRAY_SIZE(sense_key_texts)) 269 + s = sense_key_texts[sense->sense_key]; 270 + 271 + printk(KERN_CONT "%s -- (Sense key=0x%02x)\n", s, sense->sense_key); 272 + 273 + if (sense->asc == 0x40) { 274 + sprintf(buf, "Diagnostic failure on component 0x%02x", 275 + sense->ascq); 276 + s = buf; 277 + } else { 278 + int lo = 0, mid, hi = ARRAY_SIZE(sense_data_texts); 279 + unsigned long key = (sense->sense_key << 16); 280 + 281 + key |= (sense->asc << 8); 282 + if (!(sense->ascq >= 0x80 && sense->ascq <= 0xdd)) 283 + key |= sense->ascq; 284 + s = NULL; 285 + 286 + while (hi > lo) { 287 + mid = (lo + hi) / 2; 288 + if (sense_data_texts[mid].asc_ascq == key || 289 + sense_data_texts[mid].asc_ascq == (0xff0000|key)) { 290 + s = sense_data_texts[mid].text; 291 + break; 292 + } else if (sense_data_texts[mid].asc_ascq > key) 293 + hi = mid; 294 + else 295 + lo = mid + 1; 296 + } 297 + } 298 + 299 + if (s == NULL) { 300 + if (sense->asc > 0x80) 301 + s = "(vendor-specific error)"; 302 + else 303 + s = "(reserved error code)"; 304 + } 305 + 306 + printk(KERN_ERR " %s -- (asc=0x%02x, ascq=0x%02x)\n", 307 + s, sense->asc, sense->ascq); 308 + 309 + if (failed_command != NULL) { 310 + int lo = 0, mid, hi = ARRAY_SIZE(packet_command_texts); 311 + s = NULL; 312 + 313 + while (hi > lo) { 314 + mid = (lo + hi) / 2; 315 + if (packet_command_texts[mid].packet_command == 316 + failed_command->cmd[0]) { 317 + s = packet_command_texts[mid].text; 318 + break; 319 + } 320 + if (packet_command_texts[mid].packet_command > 321 + failed_command->cmd[0]) 322 + hi = mid; 323 + else 324 + lo = mid + 1; 325 + } 326 + 327 + printk(KERN_ERR " The failed \"%s\" packet command " 328 + "was: \n \"", s); 329 + for (i = 0; i < sizeof(failed_command->cmd); i++) 330 + printk(KERN_CONT "%02x ", failed_command->cmd[i]); 331 + printk(KERN_CONT "\"\n"); 332 + } 333 + 334 + /* The SKSV bit specifies validity of the sense_key_specific 335 + * in the next two commands. It is bit 7 of the first byte. 336 + * In the case of NOT_READY, if SKSV is set the drive can 337 + * give us nice ETA readings. 338 + */ 339 + if (sense->sense_key == NOT_READY && (sense->sks[0] & 0x80)) { 340 + int progress = (sense->sks[1] << 8 | sense->sks[2]) * 100; 341 + 342 + printk(KERN_ERR " Command is %02d%% complete\n", 343 + progress / 0xffff); 344 + } 345 + 346 + if (sense->sense_key == ILLEGAL_REQUEST && 347 + (sense->sks[0] & 0x80) != 0) { 348 + printk(KERN_ERR " Error in %s byte %d", 349 + (sense->sks[0] & 0x40) != 0 ? 350 + "command packet" : "command data", 351 + (sense->sks[1] << 8) + sense->sks[2]); 352 + 353 + if ((sense->sks[0] & 0x40) != 0) 354 + printk(KERN_CONT " bit %d", sense->sks[0] & 0x07); 355 + 356 + printk(KERN_CONT "\n"); 357 + } 358 + } 359 + #endif
+5 -6
drivers/ide/ide-disk.c
··· 1 /* 2 - * linux/drivers/ide/ide-disk.c Version 1.18 Mar 05, 2003 3 - * 4 - * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) 5 - * Copyright (C) 1998-2002 Linux ATA Development 6 - * Andre Hedrick <andre@linux-ide.org> 7 - * Copyright (C) 2003 Red Hat <alan@redhat.com> 8 */ 9 10 /*
··· 1 /* 2 + * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) 3 + * Copyright (C) 1998-2002 Linux ATA Development 4 + * Andre Hedrick <andre@linux-ide.org> 5 + * Copyright (C) 2003 Red Hat <alan@redhat.com> 6 + * Copyright (C) 2003-2005, 2007 Bartlomiej Zolnierkiewicz 7 */ 8 9 /*
+54 -56
drivers/ide/ide-dma.c
··· 1 /* 2 - * linux/drivers/ide/ide-dma.c Version 4.10 June 9, 2000 3 * 4 - * Copyright (c) 1999-2000 Andre Hedrick <andre@linux-ide.org> 5 * May be copied or modified under the terms of the GNU General Public License 6 */ 7 8 /* 9 * Special Thanks to Mark for his Six years of work. 10 - * 11 - * Copyright (c) 1995-1998 Mark Lord 12 - * May be copied or modified under the terms of the GNU General Public License 13 */ 14 15 /* ··· 83 #include <linux/ide.h> 84 #include <linux/delay.h> 85 #include <linux/scatterlist.h> 86 87 #include <asm/io.h> 88 #include <asm/irq.h> ··· 168 return ide_in_drive_list(drive->id, drive_whitelist); 169 } 170 171 - #ifdef CONFIG_BLK_DEV_IDEDMA_PCI 172 /** 173 * ide_build_sglist - map IDE scatter gather for DMA I/O 174 * @drive: the drive to build the DMA table for 175 * @rq: the request holding the sg list 176 * 177 - * Perform the PCI mapping magic necessary to access the source or 178 - * target buffers of a request via PCI DMA. The lower layers of the 179 * kernel provide the necessary cache management so that we can 180 - * operate in a portable fashion 181 */ 182 183 int ide_build_sglist(ide_drive_t *drive, struct request *rq) ··· 184 ide_hwif_t *hwif = HWIF(drive); 185 struct scatterlist *sg = hwif->sg_table; 186 187 - BUG_ON((rq->cmd_type == REQ_TYPE_ATA_TASKFILE) && rq->nr_sectors > 256); 188 - 189 ide_map_sg(drive, rq); 190 191 if (rq_data_dir(rq) == READ) 192 - hwif->sg_dma_direction = PCI_DMA_FROMDEVICE; 193 else 194 - hwif->sg_dma_direction = PCI_DMA_TODEVICE; 195 196 - return pci_map_sg(hwif->pci_dev, sg, hwif->sg_nents, hwif->sg_dma_direction); 197 } 198 199 EXPORT_SYMBOL_GPL(ide_build_sglist); 200 201 /** 202 * ide_build_dmatable - build IDE DMA table 203 * ··· 282 *--table |= cpu_to_le32(0x80000000); 283 return count; 284 } 285 printk(KERN_ERR "%s: empty DMA table?\n", drive->name); 286 use_pio_instead: 287 - pci_unmap_sg(hwif->pci_dev, 288 - hwif->sg_table, 289 - hwif->sg_nents, 290 - hwif->sg_dma_direction); 291 return 0; /* revert to PIO for this request */ 292 } 293 294 EXPORT_SYMBOL_GPL(ide_build_dmatable); 295 296 /** 297 * ide_destroy_dmatable - clean up DMA mapping ··· 307 308 void ide_destroy_dmatable (ide_drive_t *drive) 309 { 310 - struct pci_dev *dev = HWIF(drive)->pci_dev; 311 - struct scatterlist *sg = HWIF(drive)->sg_table; 312 - int nents = HWIF(drive)->sg_nents; 313 314 - pci_unmap_sg(dev, sg, nents, HWIF(drive)->sg_dma_direction); 315 } 316 317 EXPORT_SYMBOL_GPL(ide_destroy_dmatable); 318 319 /** 320 * config_drive_for_dma - attempt to activate IDE DMA 321 * @drive: the drive to place in DMA mode ··· 472 473 drive->hwif->dma_host_set(drive, 1); 474 } 475 - 476 - EXPORT_SYMBOL(ide_dma_on); 477 478 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI 479 /** ··· 844 static void ide_release_dma_engine(ide_hwif_t *hwif) 845 { 846 if (hwif->dmatable_cpu) { 847 - pci_free_consistent(hwif->pci_dev, 848 - PRD_ENTRIES * PRD_BYTES, 849 - hwif->dmatable_cpu, 850 - hwif->dmatable_dma); 851 hwif->dmatable_cpu = NULL; 852 } 853 } ··· 875 876 static int ide_allocate_dma_engine(ide_hwif_t *hwif) 877 { 878 - hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev, 879 PRD_ENTRIES * PRD_BYTES, 880 &hwif->dmatable_dma); 881 ··· 890 return 1; 891 } 892 893 - static int ide_mapped_mmio_dma(ide_hwif_t *hwif, unsigned long base, unsigned int ports) 894 { 895 printk(KERN_INFO " %s: MMIO-DMA ", hwif->name); 896 897 return 0; 898 } 899 900 - static int ide_iomio_dma(ide_hwif_t *hwif, unsigned long base, unsigned int ports) 901 { 902 printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx", 903 - hwif->name, base, base + ports - 1); 904 905 - if (!request_region(base, ports, hwif->name)) { 906 printk(" -- Error, ports in use.\n"); 907 return 1; 908 } ··· 914 if (!request_region(hwif->extra_base, 915 hwif->cds->extra, hwif->cds->name)) { 916 printk(" -- Error, extra ports in use.\n"); 917 - release_region(base, ports); 918 return 1; 919 } 920 hwif->extra_ports = hwif->cds->extra; ··· 924 return 0; 925 } 926 927 - static int ide_dma_iobase(ide_hwif_t *hwif, unsigned long base, unsigned int ports) 928 { 929 if (hwif->mmio) 930 - return ide_mapped_mmio_dma(hwif, base,ports); 931 932 - return ide_iomio_dma(hwif, base, ports); 933 } 934 935 - void ide_setup_dma(ide_hwif_t *hwif, unsigned long base, unsigned num_ports) 936 { 937 - if (ide_dma_iobase(hwif, base, num_ports)) 938 return; 939 940 if (ide_allocate_dma_engine(hwif)) { ··· 946 947 hwif->dma_base = base; 948 949 - if (!(hwif->dma_command)) 950 - hwif->dma_command = hwif->dma_base; 951 - if (!(hwif->dma_vendor1)) 952 - hwif->dma_vendor1 = (hwif->dma_base + 1); 953 - if (!(hwif->dma_status)) 954 - hwif->dma_status = (hwif->dma_base + 2); 955 - if (!(hwif->dma_vendor3)) 956 - hwif->dma_vendor3 = (hwif->dma_base + 3); 957 - if (!(hwif->dma_prdtable)) 958 - hwif->dma_prdtable = (hwif->dma_base + 4); 959 960 if (!hwif->dma_host_set) 961 hwif->dma_host_set = &ide_dma_host_set; ··· 974 if (!hwif->dma_lost_irq) 975 hwif->dma_lost_irq = &ide_dma_lost_irq; 976 977 - if (hwif->chipset != ide_trm290) { 978 - u8 dma_stat = hwif->INB(hwif->dma_status); 979 - printk(", BIOS settings: %s:%s, %s:%s", 980 - hwif->drives[0].name, (dma_stat & 0x20) ? "DMA" : "pio", 981 - hwif->drives[1].name, (dma_stat & 0x40) ? "DMA" : "pio"); 982 - } 983 - printk("\n"); 984 } 985 986 EXPORT_SYMBOL_GPL(ide_setup_dma);
··· 1 /* 2 + * Copyright (C) 1995-1998 Mark Lord 3 + * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> 4 + * Copyright (C) 2004, 2007 Bartlomiej Zolnierkiewicz 5 * 6 * May be copied or modified under the terms of the GNU General Public License 7 */ 8 9 /* 10 * Special Thanks to Mark for his Six years of work. 11 */ 12 13 /* ··· 85 #include <linux/ide.h> 86 #include <linux/delay.h> 87 #include <linux/scatterlist.h> 88 + #include <linux/dma-mapping.h> 89 90 #include <asm/io.h> 91 #include <asm/irq.h> ··· 169 return ide_in_drive_list(drive->id, drive_whitelist); 170 } 171 172 /** 173 * ide_build_sglist - map IDE scatter gather for DMA I/O 174 * @drive: the drive to build the DMA table for 175 * @rq: the request holding the sg list 176 * 177 + * Perform the DMA mapping magic necessary to access the source or 178 + * target buffers of a request via DMA. The lower layers of the 179 * kernel provide the necessary cache management so that we can 180 + * operate in a portable fashion. 181 */ 182 183 int ide_build_sglist(ide_drive_t *drive, struct request *rq) ··· 186 ide_hwif_t *hwif = HWIF(drive); 187 struct scatterlist *sg = hwif->sg_table; 188 189 ide_map_sg(drive, rq); 190 191 if (rq_data_dir(rq) == READ) 192 + hwif->sg_dma_direction = DMA_FROM_DEVICE; 193 else 194 + hwif->sg_dma_direction = DMA_TO_DEVICE; 195 196 + return dma_map_sg(hwif->dev, sg, hwif->sg_nents, 197 + hwif->sg_dma_direction); 198 } 199 200 EXPORT_SYMBOL_GPL(ide_build_sglist); 201 202 + #ifdef CONFIG_BLK_DEV_IDEDMA_PCI 203 /** 204 * ide_build_dmatable - build IDE DMA table 205 * ··· 284 *--table |= cpu_to_le32(0x80000000); 285 return count; 286 } 287 + 288 printk(KERN_ERR "%s: empty DMA table?\n", drive->name); 289 + 290 use_pio_instead: 291 + ide_destroy_dmatable(drive); 292 + 293 return 0; /* revert to PIO for this request */ 294 } 295 296 EXPORT_SYMBOL_GPL(ide_build_dmatable); 297 + #endif 298 299 /** 300 * ide_destroy_dmatable - clean up DMA mapping ··· 308 309 void ide_destroy_dmatable (ide_drive_t *drive) 310 { 311 + ide_hwif_t *hwif = drive->hwif; 312 313 + dma_unmap_sg(hwif->dev, hwif->sg_table, hwif->sg_nents, 314 + hwif->sg_dma_direction); 315 } 316 317 EXPORT_SYMBOL_GPL(ide_destroy_dmatable); 318 319 + #ifdef CONFIG_BLK_DEV_IDEDMA_PCI 320 /** 321 * config_drive_for_dma - attempt to activate IDE DMA 322 * @drive: the drive to place in DMA mode ··· 473 474 drive->hwif->dma_host_set(drive, 1); 475 } 476 477 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI 478 /** ··· 847 static void ide_release_dma_engine(ide_hwif_t *hwif) 848 { 849 if (hwif->dmatable_cpu) { 850 + struct pci_dev *pdev = to_pci_dev(hwif->dev); 851 + 852 + pci_free_consistent(pdev, PRD_ENTRIES * PRD_BYTES, 853 + hwif->dmatable_cpu, hwif->dmatable_dma); 854 hwif->dmatable_cpu = NULL; 855 } 856 } ··· 878 879 static int ide_allocate_dma_engine(ide_hwif_t *hwif) 880 { 881 + struct pci_dev *pdev = to_pci_dev(hwif->dev); 882 + 883 + hwif->dmatable_cpu = pci_alloc_consistent(pdev, 884 PRD_ENTRIES * PRD_BYTES, 885 &hwif->dmatable_dma); 886 ··· 891 return 1; 892 } 893 894 + static int ide_mapped_mmio_dma(ide_hwif_t *hwif, unsigned long base) 895 { 896 printk(KERN_INFO " %s: MMIO-DMA ", hwif->name); 897 898 return 0; 899 } 900 901 + static int ide_iomio_dma(ide_hwif_t *hwif, unsigned long base) 902 { 903 printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx", 904 + hwif->name, base, base + 7); 905 906 + if (!request_region(base, 8, hwif->name)) { 907 printk(" -- Error, ports in use.\n"); 908 return 1; 909 } ··· 915 if (!request_region(hwif->extra_base, 916 hwif->cds->extra, hwif->cds->name)) { 917 printk(" -- Error, extra ports in use.\n"); 918 + release_region(base, 8); 919 return 1; 920 } 921 hwif->extra_ports = hwif->cds->extra; ··· 925 return 0; 926 } 927 928 + static int ide_dma_iobase(ide_hwif_t *hwif, unsigned long base) 929 { 930 if (hwif->mmio) 931 + return ide_mapped_mmio_dma(hwif, base); 932 933 + return ide_iomio_dma(hwif, base); 934 } 935 936 + void ide_setup_dma(ide_hwif_t *hwif, unsigned long base) 937 { 938 + u8 dma_stat; 939 + 940 + if (ide_dma_iobase(hwif, base)) 941 return; 942 943 if (ide_allocate_dma_engine(hwif)) { ··· 945 946 hwif->dma_base = base; 947 948 + if (!hwif->dma_command) 949 + hwif->dma_command = hwif->dma_base + 0; 950 + if (!hwif->dma_vendor1) 951 + hwif->dma_vendor1 = hwif->dma_base + 1; 952 + if (!hwif->dma_status) 953 + hwif->dma_status = hwif->dma_base + 2; 954 + if (!hwif->dma_vendor3) 955 + hwif->dma_vendor3 = hwif->dma_base + 3; 956 + if (!hwif->dma_prdtable) 957 + hwif->dma_prdtable = hwif->dma_base + 4; 958 959 if (!hwif->dma_host_set) 960 hwif->dma_host_set = &ide_dma_host_set; ··· 973 if (!hwif->dma_lost_irq) 974 hwif->dma_lost_irq = &ide_dma_lost_irq; 975 976 + dma_stat = hwif->INB(hwif->dma_status); 977 + printk(KERN_CONT ", BIOS settings: %s:%s, %s:%s\n", 978 + hwif->drives[0].name, (dma_stat & 0x20) ? "DMA" : "PIO", 979 + hwif->drives[1].name, (dma_stat & 0x40) ? "DMA" : "PIO"); 980 } 981 982 EXPORT_SYMBOL_GPL(ide_setup_dma);
+6 -116
drivers/ide/ide-floppy.c
··· 1 /* 2 - * linux/drivers/ide/ide-floppy.c Version 0.99 Feb 24 2002 3 * 4 - * Copyright (C) 1996 - 1999 Gadi Oxman <gadio@netvision.net.il> 5 - * Copyright (C) 2000 - 2002 Paul Bristow <paul@paulbristow.net> 6 */ 7 8 /* 9 - * IDE ATAPI floppy driver. 10 - * 11 * The driver currently doesn't have any fancy features, just the bare 12 * minimum read/write support. 13 * ··· 16 * Iomega Zip 100/250 17 * Iomega PC Card Clik!/PocketZip 18 * 19 - * Many thanks to Lode Leroy <Lode.Leroy@www.ibase.be>, who tested so many 20 - * ALPHA patches to this driver on an EASYSTOR LS-120 ATAPI floppy drive. 21 - * 22 - * Ver 0.1 Oct 17 96 Initial test version, mostly based on ide-tape.c. 23 - * Ver 0.2 Oct 31 96 Minor changes. 24 - * Ver 0.3 Dec 2 96 Fixed error recovery bug. 25 - * Ver 0.4 Jan 26 97 Add support for the HDIO_GETGEO ioctl. 26 - * Ver 0.5 Feb 21 97 Add partitions support. 27 - * Use the minimum of the LBA and CHS capacities. 28 - * Avoid hwgroup->rq == NULL on the last irq. 29 - * Fix potential null dereferencing with DEBUG_LOG. 30 - * Ver 0.8 Dec 7 97 Increase irq timeout from 10 to 50 seconds. 31 - * Add media write-protect detection. 32 - * Issue START command only if TEST UNIT READY fails. 33 - * Add work-around for IOMEGA ZIP revision 21.D. 34 - * Remove idefloppy_get_capabilities(). 35 - * Ver 0.9 Jul 4 99 Fix a bug which might have caused the number of 36 - * bytes requested on each interrupt to be zero. 37 - * Thanks to <shanos@es.co.nz> for pointing this out. 38 - * Ver 0.9.sv Jan 6 01 Sam Varshavchik <mrsam@courier-mta.com> 39 - * Implement low level formatting. Reimplemented 40 - * IDEFLOPPY_CAPABILITIES_PAGE, since we need the srfp 41 - * bit. My LS-120 drive barfs on 42 - * IDEFLOPPY_CAPABILITIES_PAGE, but maybe it's just me. 43 - * Compromise by not reporting a failure to get this 44 - * mode page. Implemented four IOCTLs in order to 45 - * implement formatting. IOCTls begin with 0x4600, 46 - * 0x46 is 'F' as in Format. 47 - * Jan 9 01 Userland option to select format verify. 48 - * Added PC_SUPPRESS_ERROR flag - some idefloppy drives 49 - * do not implement IDEFLOPPY_CAPABILITIES_PAGE, and 50 - * return a sense error. Suppress error reporting in 51 - * this particular case in order to avoid spurious 52 - * errors in syslog. The culprit is 53 - * idefloppy_get_capability_page(), so move it to 54 - * idefloppy_begin_format() so that it's not used 55 - * unless absolutely necessary. 56 - * If drive does not support format progress indication 57 - * monitor the dsc bit in the status register. 58 - * Also, O_NDELAY on open will allow the device to be 59 - * opened without a disk available. This can be used to 60 - * open an unformatted disk, or get the device capacity. 61 - * Ver 0.91 Dec 11 99 Added IOMEGA Clik! drive support by 62 - * <paul@paulbristow.net> 63 - * Ver 0.92 Oct 22 00 Paul Bristow became official maintainer for this 64 - * driver. Included Powerbook internal zip kludge. 65 - * Ver 0.93 Oct 24 00 Fixed bugs for Clik! drive 66 - * no disk on insert and disk change now works 67 - * Ver 0.94 Oct 27 00 Tidied up to remove strstr(Clik) everywhere 68 - * Ver 0.95 Nov 7 00 Brought across to kernel 2.4 69 - * Ver 0.96 Jan 7 01 Actually in line with release version of 2.4.0 70 - * including set_bit patch from Rusty Russell 71 - * Ver 0.97 Jul 22 01 Merge 0.91-0.96 onto 0.9.sv for ac series 72 - * Ver 0.97.sv Aug 3 01 Backported from 2.4.7-ac3 73 - * Ver 0.98 Oct 26 01 Split idefloppy_transfer_pc into two pieces to 74 - * fix a lost interrupt problem. It appears the busy 75 - * bit was being deasserted by my IOMEGA ATAPI ZIP 100 76 - * drive before the drive was actually ready. 77 - * Ver 0.98a Oct 29 01 Expose delay value so we can play. 78 - * Ver 0.99 Feb 24 02 Remove duplicate code, modify clik! detection code 79 - * to support new PocketZip drives 80 */ 81 82 #define IDEFLOPPY_VERSION "0.99.newide" ··· 1598 { 1599 struct idefloppy_id_gcw gcw; 1600 #if IDEFLOPPY_DEBUG_INFO 1601 - u16 mask,i; 1602 char buffer[80]; 1603 #endif /* IDEFLOPPY_DEBUG_INFO */ 1604 ··· 1644 default: sprintf(buffer, "Reserved");break; 1645 } 1646 printk(KERN_INFO "Command Packet Size: %s\n", buffer); 1647 - printk(KERN_INFO "Model: %.40s\n",id->model); 1648 - printk(KERN_INFO "Firmware Revision: %.8s\n",id->fw_rev); 1649 - printk(KERN_INFO "Serial Number: %.20s\n",id->serial_no); 1650 - printk(KERN_INFO "Write buffer size(?): %d bytes\n",id->buf_size*512); 1651 - printk(KERN_INFO "DMA: %s",id->capability & 0x01 ? "Yes\n":"No\n"); 1652 - printk(KERN_INFO "LBA: %s",id->capability & 0x02 ? "Yes\n":"No\n"); 1653 - printk(KERN_INFO "IORDY can be disabled: %s",id->capability & 0x04 ? "Yes\n":"No\n"); 1654 - printk(KERN_INFO "IORDY supported: %s",id->capability & 0x08 ? "Yes\n":"Unknown\n"); 1655 - printk(KERN_INFO "ATAPI overlap supported: %s",id->capability & 0x20 ? "Yes\n":"No\n"); 1656 - printk(KERN_INFO "PIO Cycle Timing Category: %d\n",id->tPIO); 1657 - printk(KERN_INFO "DMA Cycle Timing Category: %d\n",id->tDMA); 1658 - printk(KERN_INFO "Single Word DMA supported modes:\n"); 1659 - for (i=0,mask=1;i<8;i++,mask=mask << 1) { 1660 - if (id->dma_1word & mask) 1661 - printk(KERN_INFO " Mode %d%s\n", i, 1662 - (id->dma_1word & (mask << 8)) ? " (active)" : ""); 1663 - } 1664 - printk(KERN_INFO "Multi Word DMA supported modes:\n"); 1665 - for (i=0,mask=1;i<8;i++,mask=mask << 1) { 1666 - if (id->dma_mword & mask) 1667 - printk(KERN_INFO " Mode %d%s\n", i, 1668 - (id->dma_mword & (mask << 8)) ? " (active)" : ""); 1669 - } 1670 - if (id->field_valid & 0x0002) { 1671 - printk(KERN_INFO "Enhanced PIO Modes: %s\n", 1672 - id->eide_pio_modes & 1 ? "Mode 3":"None"); 1673 - if (id->eide_dma_min == 0) 1674 - sprintf(buffer, "Not supported"); 1675 - else 1676 - sprintf(buffer, "%d ns",id->eide_dma_min); 1677 - printk(KERN_INFO "Minimum Multi-word DMA cycle per word: %s\n", buffer); 1678 - if (id->eide_dma_time == 0) 1679 - sprintf(buffer, "Not supported"); 1680 - else 1681 - sprintf(buffer, "%d ns",id->eide_dma_time); 1682 - printk(KERN_INFO "Manufacturer\'s Recommended Multi-word cycle: %s\n", buffer); 1683 - if (id->eide_pio == 0) 1684 - sprintf(buffer, "Not supported"); 1685 - else 1686 - sprintf(buffer, "%d ns",id->eide_pio); 1687 - printk(KERN_INFO "Minimum PIO cycle without IORDY: %s\n", 1688 - buffer); 1689 - if (id->eide_pio_iordy == 0) 1690 - sprintf(buffer, "Not supported"); 1691 - else 1692 - sprintf(buffer, "%d ns",id->eide_pio_iordy); 1693 - printk(KERN_INFO "Minimum PIO cycle with IORDY: %s\n", buffer); 1694 - } else 1695 - printk(KERN_INFO "According to the device, fields 64-70 are not valid.\n"); 1696 #endif /* IDEFLOPPY_DEBUG_INFO */ 1697 1698 if (gcw.protocol != 2)
··· 1 /* 2 + * IDE ATAPI floppy driver. 3 * 4 + * Copyright (C) 1996-1999 Gadi Oxman <gadio@netvision.net.il> 5 + * Copyright (C) 2000-2002 Paul Bristow <paul@paulbristow.net> 6 + * Copyright (C) 2005 Bartlomiej Zolnierkiewicz 7 */ 8 9 /* 10 * The driver currently doesn't have any fancy features, just the bare 11 * minimum read/write support. 12 * ··· 17 * Iomega Zip 100/250 18 * Iomega PC Card Clik!/PocketZip 19 * 20 + * For a historical changelog see 21 + * Documentation/ide/ChangeLog.ide-floppy.1996-2002 22 */ 23 24 #define IDEFLOPPY_VERSION "0.99.newide" ··· 1658 { 1659 struct idefloppy_id_gcw gcw; 1660 #if IDEFLOPPY_DEBUG_INFO 1661 char buffer[80]; 1662 #endif /* IDEFLOPPY_DEBUG_INFO */ 1663 ··· 1705 default: sprintf(buffer, "Reserved");break; 1706 } 1707 printk(KERN_INFO "Command Packet Size: %s\n", buffer); 1708 #endif /* IDEFLOPPY_DEBUG_INFO */ 1709 1710 if (gcw.protocol != 2)
+1 -1
drivers/ide/ide-io.c
··· 1487 * remove all the ifdef PCI crap 1488 */ 1489 #ifdef CONFIG_BLK_DEV_IDEPCI 1490 - if (hwif->pci_dev && !hwif->pci_dev->vendor) 1491 #endif /* CONFIG_BLK_DEV_IDEPCI */ 1492 { 1493 /*
··· 1487 * remove all the ifdef PCI crap 1488 */ 1489 #ifdef CONFIG_BLK_DEV_IDEPCI 1490 + if (hwif->chipset != ide_pci) 1491 #endif /* CONFIG_BLK_DEV_IDEPCI */ 1492 { 1493 /*
+1 -3
drivers/ide/ide-iops.c
··· 1 /* 2 - * linux/drivers/ide/ide-iops.c Version 0.37 Mar 05, 2003 3 - * 4 * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> 5 * Copyright (C) 2003 Red Hat <alan@redhat.com> 6 * ··· 1166 1167 /* 1168 * ide_wait_not_busy() waits for the currently selected device on the hwif 1169 - * to report a non-busy status, see comments in probe_hwif(). 1170 */ 1171 int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout) 1172 {
··· 1 /* 2 * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> 3 * Copyright (C) 2003 Red Hat <alan@redhat.com> 4 * ··· 1168 1169 /* 1170 * ide_wait_not_busy() waits for the currently selected device on the hwif 1171 + * to report a non-busy status, see comments in ide_probe_port(). 1172 */ 1173 int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout) 1174 {
+4 -2
drivers/ide/ide-lib.c
··· 358 if (!PCI_DMA_BUS_IS_PHYS) { 359 addr = BLK_BOUNCE_ANY; 360 } else if (on && drive->media == ide_disk) { 361 - if (HWIF(drive)->pci_dev) 362 - addr = HWIF(drive)->pci_dev->dma_mask; 363 } 364 365 if (drive->queue)
··· 358 if (!PCI_DMA_BUS_IS_PHYS) { 359 addr = BLK_BOUNCE_ANY; 360 } else if (on && drive->media == ide_disk) { 361 + struct device *dev = drive->hwif->dev; 362 + 363 + if (dev && dev->dma_mask) 364 + addr = *dev->dma_mask; 365 } 366 367 if (drive->queue)
-2
drivers/ide/ide-pnp.c
··· 1 /* 2 - * linux/drivers/ide/ide-pnp.c 3 - * 4 * This file provides autodetection for ISA PnP IDE interfaces. 5 * It was tested with "ESS ES1868 Plug and Play AudioDrive" IDE interface. 6 *
··· 1 /* 2 * This file provides autodetection for ISA PnP IDE interfaces. 3 * It was tested with "ESS ES1868 Plug and Play AudioDrive" IDE interface. 4 *
+84 -106
drivers/ide/ide-probe.c
··· 1 /* 2 - * linux/drivers/ide/ide-probe.c Version 1.11 Mar 05, 2003 3 - * 4 - * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) 5 */ 6 7 /* ··· 128 129 drive->id_read = 1; 130 local_irq_enable(); 131 ide_fix_driveid(id); 132 133 #if defined (CONFIG_SCSI_EATA_PIO) || defined (CONFIG_SCSI_EATA) ··· 613 complete(&hwif->gendev_rel_comp); 614 } 615 616 - static void hwif_register (ide_hwif_t *hwif) 617 { 618 int ret; 619 ··· 621 strlcpy(hwif->gendev.bus_id,hwif->name,BUS_ID_SIZE); 622 hwif->gendev.driver_data = hwif; 623 if (hwif->gendev.parent == NULL) { 624 - if (hwif->pci_dev) 625 - hwif->gendev.parent = &hwif->pci_dev->dev; 626 else 627 /* Would like to do = &device_legacy */ 628 hwif->gendev.parent = NULL; ··· 634 __FUNCTION__, ret); 635 } 636 637 - static int wait_hwif_ready(ide_hwif_t *hwif) 638 { 639 int unit, rc; 640 ··· 738 739 EXPORT_SYMBOL_GPL(ide_undecoded_slave); 740 741 - /* 742 - * This routine only knows how to look for drive units 0 and 1 743 - * on an interface, so any setting of MAX_DRIVES > 2 won't work here. 744 - */ 745 - static void probe_hwif(ide_hwif_t *hwif) 746 { 747 unsigned long flags; 748 unsigned int irqd; 749 - int unit; 750 751 if (hwif->noprobe) 752 - return; 753 - 754 - if ((hwif->chipset != ide_4drives || !hwif->mate || !hwif->mate->present) && 755 - (ide_hwif_request_regions(hwif))) { 756 - u16 msgout = 0; 757 - for (unit = 0; unit < MAX_DRIVES; ++unit) { 758 - ide_drive_t *drive = &hwif->drives[unit]; 759 - if (drive->present) { 760 - drive->present = 0; 761 - printk(KERN_ERR "%s: ERROR, PORTS ALREADY IN USE\n", 762 - drive->name); 763 - msgout = 1; 764 - } 765 - } 766 - if (!msgout) 767 - printk(KERN_ERR "%s: ports already in use, skipping probe\n", 768 - hwif->name); 769 - return; 770 - } 771 772 /* 773 * We must always disable IRQ, as probe_for_drive will assert IRQ, but ··· 759 760 local_irq_set(flags); 761 762 - /* This is needed on some PPCs and a bunch of BIOS-less embedded 763 - * platforms. Typical cases are: 764 - * 765 - * - The firmware hard reset the disk before booting the kernel, 766 - * the drive is still doing it's poweron-reset sequence, that 767 - * can take up to 30 seconds 768 - * - The firmware does nothing (or no firmware), the device is 769 - * still in POST state (same as above actually). 770 - * - Some CD/DVD/Writer combo drives tend to drive the bus during 771 - * their reset sequence even when they are non-selected slave 772 - * devices, thus preventing discovery of the main HD 773 - * 774 - * Doing this wait-for-busy should not harm any existing configuration 775 - * (at least things won't be worse than what current code does, that 776 - * is blindly go & talk to the drive) and fix some issues like the 777 - * above. 778 - * 779 - * BenH. 780 - */ 781 - if (wait_hwif_ready(hwif) == -EBUSY) 782 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); 783 784 /* ··· 769 ide_drive_t *drive = &hwif->drives[unit]; 770 drive->dn = (hwif->channel ? 2 : 0) + unit; 771 (void) probe_for_drive(drive); 772 - if (drive->present && !hwif->present) { 773 - hwif->present = 1; 774 - if (hwif->chipset != ide_4drives || 775 - !hwif->mate || 776 - !hwif->mate->present) { 777 - hwif_register(hwif); 778 - } 779 - } 780 } 781 if (hwif->io_ports[IDE_CONTROL_OFFSET] && hwif->reset) { 782 printk(KERN_WARNING "%s: reset\n", hwif->name); ··· 787 if (irqd) 788 enable_irq(irqd); 789 790 - if (!hwif->present) { 791 - ide_hwif_release_regions(hwif); 792 - return; 793 - } 794 795 for (unit = 0; unit < MAX_DRIVES; unit++) { 796 ide_drive_t *drive = &hwif->drives[unit]; ··· 983 spin_lock_irq(&ide_lock); 984 hwif->next = hwgroup->hwif->next; 985 hwgroup->hwif->next = hwif; 986 spin_unlock_irq(&ide_lock); 987 } else { 988 - hwgroup = kmalloc_node(sizeof(ide_hwgroup_t), 989 - GFP_KERNEL | __GFP_ZERO, 990 - hwif_to_node(hwif->drives[0].hwif)); 991 - if (!hwgroup) 992 - goto out_up; 993 994 hwif->hwgroup = hwgroup; 995 996 - hwgroup->hwif = hwif->next = hwif; 997 - hwgroup->rq = NULL; 998 - hwgroup->handler = NULL; 999 - hwgroup->drive = NULL; 1000 - hwgroup->busy = 0; 1001 init_timer(&hwgroup->timer); 1002 hwgroup->timer.function = &ide_timer_expiry; 1003 hwgroup->timer.data = (unsigned long) hwgroup; ··· 1061 mutex_unlock(&ide_cfg_mtx); 1062 return 0; 1063 out_unlink: 1064 - spin_lock_irq(&ide_lock); 1065 - if (hwif->next == hwif) { 1066 - BUG_ON(match); 1067 - BUG_ON(hwgroup->hwif != hwif); 1068 - kfree(hwgroup); 1069 - } else { 1070 - ide_hwif_t *g; 1071 - g = hwgroup->hwif; 1072 - while (g->next != hwif) 1073 - g = g->next; 1074 - g->next = hwif->next; 1075 - if (hwgroup->hwif == hwif) { 1076 - /* Impossible. */ 1077 - printk(KERN_ERR "Duh. Uninitialized hwif listed as active hwif.\n"); 1078 - hwgroup->hwif = g; 1079 - } 1080 - BUG_ON(hwgroup->hwif == hwif); 1081 - } 1082 - spin_unlock_irq(&ide_lock); 1083 out_up: 1084 mutex_unlock(&ide_cfg_mtx); 1085 return 1; ··· 1210 { 1211 int old_irq; 1212 1213 - /* Return success if no device is connected */ 1214 - if (!hwif->present) 1215 - return 1; 1216 - 1217 if (!hwif->irq) { 1218 if (!(hwif->irq = ide_default_irq(hwif->io_ports[IDE_DATA_OFFSET]))) 1219 { 1220 printk("%s: DISABLED, NO IRQ\n", hwif->name); 1221 - return (hwif->present = 0); 1222 } 1223 } 1224 #ifdef CONFIG_BLK_DEV_HD 1225 if (hwif->irq == HD_IRQ && hwif->io_ports[IDE_DATA_OFFSET] != HD_DATA) { 1226 printk("%s: CANNOT SHARE IRQ WITH OLD " 1227 "HARDDISK DRIVER (hd.c)\n", hwif->name); 1228 - return (hwif->present = 0); 1229 } 1230 #endif /* CONFIG_BLK_DEV_HD */ 1231 - 1232 - /* we set it back to 1 if all is ok below */ 1233 - hwif->present = 0; 1234 1235 if (register_blkdev(hwif->major, hwif->name)) 1236 return 0; ··· 1263 1264 done: 1265 init_gendisk(hwif); 1266 - 1267 ide_acpi_init(hwif); 1268 - 1269 - hwif->present = 1; /* success */ 1270 return 1; 1271 1272 out: ··· 1298 if (idx[i] == 0xff) 1299 continue; 1300 1301 - probe_hwif(&ide_hwifs[idx[i]]); 1302 } 1303 1304 for (i = 0; i < MAX_HWIFS; i++) { ··· 1327 1328 hwif = &ide_hwifs[idx[i]]; 1329 1330 if (hwif_init(hwif) == 0) { 1331 printk(KERN_INFO "%s: failed to initialize IDE " 1332 "interface\n", hwif->name); 1333 rc = -1; 1334 continue; 1335 }
··· 1 /* 2 + * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) 3 + * Copyright (C) 2005, 2007 Bartlomiej Zolnierkiewicz 4 */ 5 6 /* ··· 129 130 drive->id_read = 1; 131 local_irq_enable(); 132 + #ifdef DEBUG 133 + printk(KERN_INFO "%s: dumping identify data\n", drive->name); 134 + ide_dump_identify((u8 *)id); 135 + #endif 136 ide_fix_driveid(id); 137 138 #if defined (CONFIG_SCSI_EATA_PIO) || defined (CONFIG_SCSI_EATA) ··· 610 complete(&hwif->gendev_rel_comp); 611 } 612 613 + static void ide_register_port(ide_hwif_t *hwif) 614 { 615 int ret; 616 ··· 618 strlcpy(hwif->gendev.bus_id,hwif->name,BUS_ID_SIZE); 619 hwif->gendev.driver_data = hwif; 620 if (hwif->gendev.parent == NULL) { 621 + if (hwif->dev) 622 + hwif->gendev.parent = hwif->dev; 623 else 624 /* Would like to do = &device_legacy */ 625 hwif->gendev.parent = NULL; ··· 631 __FUNCTION__, ret); 632 } 633 634 + /** 635 + * ide_port_wait_ready - wait for port to become ready 636 + * @hwif: IDE port 637 + * 638 + * This is needed on some PPCs and a bunch of BIOS-less embedded 639 + * platforms. Typical cases are: 640 + * 641 + * - The firmware hard reset the disk before booting the kernel, 642 + * the drive is still doing it's poweron-reset sequence, that 643 + * can take up to 30 seconds. 644 + * 645 + * - The firmware does nothing (or no firmware), the device is 646 + * still in POST state (same as above actually). 647 + * 648 + * - Some CD/DVD/Writer combo drives tend to drive the bus during 649 + * their reset sequence even when they are non-selected slave 650 + * devices, thus preventing discovery of the main HD. 651 + * 652 + * Doing this wait-for-non-busy should not harm any existing 653 + * configuration and fix some issues like the above. 654 + * 655 + * BenH. 656 + * 657 + * Returns 0 on success, error code (< 0) otherwise. 658 + */ 659 + 660 + static int ide_port_wait_ready(ide_hwif_t *hwif) 661 { 662 int unit, rc; 663 ··· 709 710 EXPORT_SYMBOL_GPL(ide_undecoded_slave); 711 712 + static int ide_probe_port(ide_hwif_t *hwif) 713 { 714 unsigned long flags; 715 unsigned int irqd; 716 + int unit, rc = -ENODEV; 717 + 718 + BUG_ON(hwif->present); 719 720 if (hwif->noprobe) 721 + return -EACCES; 722 723 /* 724 * We must always disable IRQ, as probe_for_drive will assert IRQ, but ··· 750 751 local_irq_set(flags); 752 753 + if (ide_port_wait_ready(hwif) == -EBUSY) 754 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); 755 756 /* ··· 779 ide_drive_t *drive = &hwif->drives[unit]; 780 drive->dn = (hwif->channel ? 2 : 0) + unit; 781 (void) probe_for_drive(drive); 782 + if (drive->present) 783 + rc = 0; 784 } 785 if (hwif->io_ports[IDE_CONTROL_OFFSET] && hwif->reset) { 786 printk(KERN_WARNING "%s: reset\n", hwif->name); ··· 803 if (irqd) 804 enable_irq(irqd); 805 806 + return rc; 807 + } 808 + 809 + static void ide_port_tune_devices(ide_hwif_t *hwif) 810 + { 811 + int unit; 812 813 for (unit = 0; unit < MAX_DRIVES; unit++) { 814 ide_drive_t *drive = &hwif->drives[unit]; ··· 997 spin_lock_irq(&ide_lock); 998 hwif->next = hwgroup->hwif->next; 999 hwgroup->hwif->next = hwif; 1000 + BUG_ON(hwif->next == hwif); 1001 spin_unlock_irq(&ide_lock); 1002 } else { 1003 + hwgroup = kmalloc_node(sizeof(*hwgroup), GFP_KERNEL|__GFP_ZERO, 1004 + hwif_to_node(hwif)); 1005 + if (hwgroup == NULL) 1006 + goto out_up; 1007 1008 hwif->hwgroup = hwgroup; 1009 + hwgroup->hwif = hwif->next = hwif; 1010 1011 init_timer(&hwgroup->timer); 1012 hwgroup->timer.function = &ide_timer_expiry; 1013 hwgroup->timer.data = (unsigned long) hwgroup; ··· 1079 mutex_unlock(&ide_cfg_mtx); 1080 return 0; 1081 out_unlink: 1082 + ide_remove_port_from_hwgroup(hwif); 1083 out_up: 1084 mutex_unlock(&ide_cfg_mtx); 1085 return 1; ··· 1246 { 1247 int old_irq; 1248 1249 if (!hwif->irq) { 1250 if (!(hwif->irq = ide_default_irq(hwif->io_ports[IDE_DATA_OFFSET]))) 1251 { 1252 printk("%s: DISABLED, NO IRQ\n", hwif->name); 1253 + return 0; 1254 } 1255 } 1256 #ifdef CONFIG_BLK_DEV_HD 1257 if (hwif->irq == HD_IRQ && hwif->io_ports[IDE_DATA_OFFSET] != HD_DATA) { 1258 printk("%s: CANNOT SHARE IRQ WITH OLD " 1259 "HARDDISK DRIVER (hd.c)\n", hwif->name); 1260 + return 0; 1261 } 1262 #endif /* CONFIG_BLK_DEV_HD */ 1263 1264 if (register_blkdev(hwif->major, hwif->name)) 1265 return 0; ··· 1306 1307 done: 1308 init_gendisk(hwif); 1309 ide_acpi_init(hwif); 1310 return 1; 1311 1312 out: ··· 1344 if (idx[i] == 0xff) 1345 continue; 1346 1347 + hwif = &ide_hwifs[idx[i]]; 1348 + 1349 + if ((hwif->chipset != ide_4drives || !hwif->mate || 1350 + !hwif->mate->present) && ide_hwif_request_regions(hwif)) { 1351 + printk(KERN_ERR "%s: ports already in use, " 1352 + "skipping probe\n", hwif->name); 1353 + continue; 1354 + } 1355 + 1356 + if (ide_probe_port(hwif) < 0) { 1357 + ide_hwif_release_regions(hwif); 1358 + continue; 1359 + } 1360 + 1361 + hwif->present = 1; 1362 + 1363 + if (hwif->chipset != ide_4drives || !hwif->mate || 1364 + !hwif->mate->present) 1365 + ide_register_port(hwif); 1366 + 1367 + ide_port_tune_devices(hwif); 1368 } 1369 1370 for (i = 0; i < MAX_HWIFS; i++) { ··· 1353 1354 hwif = &ide_hwifs[idx[i]]; 1355 1356 + if (!hwif->present) 1357 + continue; 1358 + 1359 if (hwif_init(hwif) == 0) { 1360 printk(KERN_INFO "%s: failed to initialize IDE " 1361 "interface\n", hwif->name); 1362 + hwif->present = 0; 1363 rc = -1; 1364 continue; 1365 }
-2
drivers/ide/ide-proc.c
··· 1 /* 2 - * linux/drivers/ide/ide-proc.c Version 1.05 Mar 05, 2003 3 - * 4 * Copyright (C) 1997-1998 Mark Lord 5 * Copyright (C) 2003 Red Hat <alan@redhat.com> 6 *
··· 1 /* 2 * Copyright (C) 1997-1998 Mark Lord 3 * Copyright (C) 2003 Red Hat <alan@redhat.com> 4 *
+2 -7
drivers/ide/ide-scan-pci.c
··· 81 * module ordering not traditionally ordered. 82 */ 83 84 - int __init ide_scan_pcibus(void) 85 { 86 struct pci_dev *dev = NULL; 87 struct pci_driver *d; ··· 113 return 0; 114 } 115 116 - static int __init ide_scan_pci(void) 117 - { 118 - return ide_scan_pcibus(); 119 - } 120 - 121 - module_init(ide_scan_pci);
··· 81 * module ordering not traditionally ordered. 82 */ 83 84 + static int __init ide_scan_pcibus(void) 85 { 86 struct pci_dev *dev = NULL; 87 struct pci_driver *d; ··· 113 return 0; 114 } 115 116 + module_init(ide_scan_pcibus);
+6 -74
drivers/ide/ide-tape.c
··· 1 /* 2 - * linux/drivers/ide/ide-tape.c Version 1.19 Nov, 2003 3 - * 4 - * Copyright (C) 1995 - 1999 Gadi Oxman <gadio@netvision.net.il> 5 * 6 * $Header$ 7 * ··· 4290 { 4291 struct idetape_id_gcw gcw; 4292 struct hd_driveid *id = drive->id; 4293 - #if IDETAPE_DEBUG_INFO 4294 - unsigned short mask,i; 4295 - #endif /* IDETAPE_DEBUG_INFO */ 4296 4297 if (drive->id_read == 0) 4298 return 1; ··· 4329 case 1: printk("16 bytes\n");break; 4330 default: printk("Reserved\n");break; 4331 } 4332 - printk(KERN_INFO "ide-tape: Model: %.40s\n",id->model); 4333 - printk(KERN_INFO "ide-tape: Firmware Revision: %.8s\n",id->fw_rev); 4334 - printk(KERN_INFO "ide-tape: Serial Number: %.20s\n",id->serial_no); 4335 - printk(KERN_INFO "ide-tape: Write buffer size: %d bytes\n",id->buf_size*512); 4336 - printk(KERN_INFO "ide-tape: DMA: %s",id->capability & 0x01 ? "Yes\n":"No\n"); 4337 - printk(KERN_INFO "ide-tape: LBA: %s",id->capability & 0x02 ? "Yes\n":"No\n"); 4338 - printk(KERN_INFO "ide-tape: IORDY can be disabled: %s",id->capability & 0x04 ? "Yes\n":"No\n"); 4339 - printk(KERN_INFO "ide-tape: IORDY supported: %s",id->capability & 0x08 ? "Yes\n":"Unknown\n"); 4340 - printk(KERN_INFO "ide-tape: ATAPI overlap supported: %s",id->capability & 0x20 ? "Yes\n":"No\n"); 4341 - printk(KERN_INFO "ide-tape: PIO Cycle Timing Category: %d\n",id->tPIO); 4342 - printk(KERN_INFO "ide-tape: DMA Cycle Timing Category: %d\n",id->tDMA); 4343 - printk(KERN_INFO "ide-tape: Single Word DMA supported modes: "); 4344 - for (i=0,mask=1;i<8;i++,mask=mask << 1) { 4345 - if (id->dma_1word & mask) 4346 - printk("%d ",i); 4347 - if (id->dma_1word & (mask << 8)) 4348 - printk("(active) "); 4349 - } 4350 - printk("\n"); 4351 - printk(KERN_INFO "ide-tape: Multi Word DMA supported modes: "); 4352 - for (i=0,mask=1;i<8;i++,mask=mask << 1) { 4353 - if (id->dma_mword & mask) 4354 - printk("%d ",i); 4355 - if (id->dma_mword & (mask << 8)) 4356 - printk("(active) "); 4357 - } 4358 - printk("\n"); 4359 - if (id->field_valid & 0x0002) { 4360 - printk(KERN_INFO "ide-tape: Enhanced PIO Modes: %s\n", 4361 - id->eide_pio_modes & 1 ? "Mode 3":"None"); 4362 - printk(KERN_INFO "ide-tape: Minimum Multi-word DMA cycle per word: "); 4363 - if (id->eide_dma_min == 0) 4364 - printk("Not supported\n"); 4365 - else 4366 - printk("%d ns\n",id->eide_dma_min); 4367 - 4368 - printk(KERN_INFO "ide-tape: Manufacturer\'s Recommended Multi-word cycle: "); 4369 - if (id->eide_dma_time == 0) 4370 - printk("Not supported\n"); 4371 - else 4372 - printk("%d ns\n",id->eide_dma_time); 4373 - 4374 - printk(KERN_INFO "ide-tape: Minimum PIO cycle without IORDY: "); 4375 - if (id->eide_pio == 0) 4376 - printk("Not supported\n"); 4377 - else 4378 - printk("%d ns\n",id->eide_pio); 4379 - 4380 - printk(KERN_INFO "ide-tape: Minimum PIO cycle with IORDY: "); 4381 - if (id->eide_pio_iordy == 0) 4382 - printk("Not supported\n"); 4383 - else 4384 - printk("%d ns\n",id->eide_pio_iordy); 4385 - 4386 - } else 4387 - printk(KERN_INFO "ide-tape: According to the device, fields 64-70 are not valid.\n"); 4388 #endif /* IDETAPE_DEBUG_INFO */ 4389 4390 /* Check that we can support this device */ ··· 4531 4532 spin_lock_init(&tape->spinlock); 4533 drive->dsc_overlap = 1; 4534 - #ifdef CONFIG_BLK_DEV_IDEPCI 4535 - if (HWIF(drive)->pci_dev != NULL) { 4536 - /* 4537 - * These two ide-pci host adapters appear to need DSC overlap disabled. 4538 - * This probably needs further analysis. 4539 - */ 4540 - if ((HWIF(drive)->pci_dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) || 4541 - (HWIF(drive)->pci_dev->device == PCI_DEVICE_ID_TTI_HPT343)) { 4542 - printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n", tape->name); 4543 - drive->dsc_overlap = 0; 4544 - } 4545 } 4546 - #endif /* CONFIG_BLK_DEV_IDEPCI */ 4547 /* Seagate Travan drives do not support DSC overlap. */ 4548 if (strstr(drive->id->model, "Seagate STT3401")) 4549 drive->dsc_overlap = 0;
··· 1 /* 2 + * Copyright (C) 1995-1999 Gadi Oxman <gadio@netvision.net.il> 3 + * Copyright (C) 2003-2005 Bartlomiej Zolnierkiewicz 4 * 5 * $Header$ 6 * ··· 4291 { 4292 struct idetape_id_gcw gcw; 4293 struct hd_driveid *id = drive->id; 4294 4295 if (drive->id_read == 0) 4296 return 1; ··· 4333 case 1: printk("16 bytes\n");break; 4334 default: printk("Reserved\n");break; 4335 } 4336 #endif /* IDETAPE_DEBUG_INFO */ 4337 4338 /* Check that we can support this device */ ··· 4591 4592 spin_lock_init(&tape->spinlock); 4593 drive->dsc_overlap = 1; 4594 + if (drive->hwif->host_flags & IDE_HFLAG_NO_DSC) { 4595 + printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n", 4596 + tape->name); 4597 + drive->dsc_overlap = 0; 4598 } 4599 /* Seagate Travan drives do not support DSC overlap. */ 4600 if (strstr(drive->id->model, "Seagate STT3401")) 4601 drive->dsc_overlap = 0;
+5 -7
drivers/ide/ide-taskfile.c
··· 1 /* 2 - * linux/drivers/ide/ide-taskfile.c Version 0.38 March 05, 2003 3 - * 4 - * Copyright (C) 2000-2002 Michael Cornwell <cornwell@acm.org> 5 - * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> 6 - * Copyright (C) 2001-2002 Klaus Smolin 7 * IBM Storage Technology Division 8 - * Copyright (C) 2003-2004 Bartlomiej Zolnierkiewicz 9 * 10 * The big the bad and the ugly. 11 */ ··· 258 return ide_stopped; 259 } 260 261 - u8 wait_drive_not_busy(ide_drive_t *drive) 262 { 263 ide_hwif_t *hwif = HWIF(drive); 264 int retries;
··· 1 /* 2 + * Copyright (C) 2000-2002 Michael Cornwell <cornwell@acm.org> 3 + * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> 4 + * Copyright (C) 2001-2002 Klaus Smolin 5 * IBM Storage Technology Division 6 + * Copyright (C) 2003-2004, 2007 Bartlomiej Zolnierkiewicz 7 * 8 * The big the bad and the ugly. 9 */ ··· 260 return ide_stopped; 261 } 262 263 + static u8 wait_drive_not_busy(ide_drive_t *drive) 264 { 265 ide_hwif_t *hwif = HWIF(drive); 266 int retries;
-2
drivers/ide/ide-timing.h
··· 2 #define _IDE_TIMING_H 3 4 /* 5 - * $Id: ide-timing.h,v 1.6 2001/12/23 22:47:56 vojtech Exp $ 6 - * 7 * Copyright (c) 1999-2001 Vojtech Pavlik 8 */ 9
··· 2 #define _IDE_TIMING_H 3 4 /* 5 * Copyright (c) 1999-2001 Vojtech Pavlik 6 */ 7
+58 -58
drivers/ide/ide.c
··· 1 /* 2 - * linux/drivers/ide/ide.c Version 7.00beta2 Mar 05 2003 3 - * 4 - * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) 5 */ 6 7 /* ··· 45 */ 46 47 #define REVISION "Revision: 7.00alpha2" 48 - #define VERSION "Id: ide.c 7.00a2 20020906" 49 50 #define _IDE_C /* Tell ide.h it's really us */ 51 ··· 240 #define pci_default 0 241 #endif /* CONFIG_PCI */ 242 243 - if (!system_bus_speed) { 244 - if (idebus_parameter) { 245 - /* user supplied value */ 246 - system_bus_speed = idebus_parameter; 247 - } else if (pci_dev_present(pci_default)) { 248 - /* safe default value for PCI */ 249 - system_bus_speed = 33; 250 - } else { 251 - /* safe default value for VESA and PCI */ 252 - system_bus_speed = 50; 253 - } 254 - printk(KERN_INFO "ide: Assuming %dMHz system bus speed " 255 - "for PIO modes%s\n", system_bus_speed, 256 - idebus_parameter ? "" : "; override with idebus=xx"); 257 - } 258 - return system_bus_speed; 259 } 260 261 ide_hwif_t * ide_find_port(unsigned long base) ··· 393 hwif->chipset = tmp_hwif->chipset; 394 hwif->hold = tmp_hwif->hold; 395 396 #ifdef CONFIG_BLK_DEV_IDEPCI 397 - hwif->pci_dev = tmp_hwif->pci_dev; 398 hwif->cds = tmp_hwif->cds; 399 #endif 400 ··· 459 hwif->extra_ports = tmp_hwif->extra_ports; 460 461 hwif->hwif_data = tmp_hwif->hwif_data; 462 } 463 464 /** ··· 563 if (irq_count == 1) 564 free_irq(hwif->irq, hwgroup); 565 566 - spin_lock_irq(&ide_lock); 567 - /* 568 - * Note that we only release the standard ports, 569 - * and do not even try to handle any extra ports 570 - * allocated for weird IDE interface chipsets. 571 - */ 572 - ide_hwif_release_regions(hwif); 573 574 - /* 575 - * Remove us from the hwgroup, and free 576 - * the hwgroup if we were the only member 577 - */ 578 - if (hwif->next == hwif) { 579 - BUG_ON(hwgroup->hwif != hwif); 580 - kfree(hwgroup); 581 - } else { 582 - /* There is another interface in hwgroup. 583 - * Unlink us, and set hwgroup->drive and ->hwif to 584 - * something sane. 585 - */ 586 - g = hwgroup->hwif; 587 - while (g->next != hwif) 588 - g = g->next; 589 - g->next = hwif->next; 590 - if (hwgroup->hwif == hwif) { 591 - /* Chose a random hwif for hwgroup->hwif. 592 - * It's guaranteed that there are no drives 593 - * left in the hwgroup. 594 - */ 595 - BUG_ON(hwgroup->drive != NULL); 596 - hwgroup->hwif = g; 597 - } 598 - BUG_ON(hwgroup->hwif == hwif); 599 - } 600 - 601 - /* More messed up locking ... */ 602 - spin_unlock_irq(&ide_lock); 603 device_unregister(&hwif->gendev); 604 wait_for_completion(&hwif->gendev_rel_comp); 605 ··· 589 hwif->extra_base = 0; 590 hwif->extra_ports = 0; 591 } 592 593 /* copy original settings */ 594 tmp_hwif = *hwif; ··· 909 910 int system_bus_clock (void) 911 { 912 - return((int) ((!system_bus_speed) ? ide_system_bus_speed() : system_bus_speed )); 913 } 914 915 EXPORT_SYMBOL(system_bus_clock); ··· 1663 1664 printk(KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n"); 1665 system_bus_speed = ide_system_bus_speed(); 1666 1667 ret = bus_register(&ide_bus_type); 1668 if (ret < 0) {
··· 1 /* 2 + * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) 3 + * Copyrifht (C) 2003-2005, 2007 Bartlomiej Zolnierkiewicz 4 */ 5 6 /* ··· 46 */ 47 48 #define REVISION "Revision: 7.00alpha2" 49 50 #define _IDE_C /* Tell ide.h it's really us */ 51 ··· 242 #define pci_default 0 243 #endif /* CONFIG_PCI */ 244 245 + /* user supplied value */ 246 + if (idebus_parameter) 247 + return idebus_parameter; 248 + 249 + /* safe default value for PCI or VESA and PCI*/ 250 + return pci_dev_present(pci_default) ? 33 : 50; 251 } 252 253 ide_hwif_t * ide_find_port(unsigned long base) ··· 405 hwif->chipset = tmp_hwif->chipset; 406 hwif->hold = tmp_hwif->hold; 407 408 + hwif->dev = tmp_hwif->dev; 409 + 410 #ifdef CONFIG_BLK_DEV_IDEPCI 411 hwif->cds = tmp_hwif->cds; 412 #endif 413 ··· 470 hwif->extra_ports = tmp_hwif->extra_ports; 471 472 hwif->hwif_data = tmp_hwif->hwif_data; 473 + } 474 + 475 + void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) 476 + { 477 + ide_hwgroup_t *hwgroup = hwif->hwgroup; 478 + 479 + spin_lock_irq(&ide_lock); 480 + /* 481 + * Remove us from the hwgroup, and free 482 + * the hwgroup if we were the only member 483 + */ 484 + if (hwif->next == hwif) { 485 + BUG_ON(hwgroup->hwif != hwif); 486 + kfree(hwgroup); 487 + } else { 488 + /* There is another interface in hwgroup. 489 + * Unlink us, and set hwgroup->drive and ->hwif to 490 + * something sane. 491 + */ 492 + ide_hwif_t *g = hwgroup->hwif; 493 + 494 + while (g->next != hwif) 495 + g = g->next; 496 + g->next = hwif->next; 497 + if (hwgroup->hwif == hwif) { 498 + /* Chose a random hwif for hwgroup->hwif. 499 + * It's guaranteed that there are no drives 500 + * left in the hwgroup. 501 + */ 502 + BUG_ON(hwgroup->drive != NULL); 503 + hwgroup->hwif = g; 504 + } 505 + BUG_ON(hwgroup->hwif == hwif); 506 + } 507 + spin_unlock_irq(&ide_lock); 508 } 509 510 /** ··· 539 if (irq_count == 1) 540 free_irq(hwif->irq, hwgroup); 541 542 + ide_remove_port_from_hwgroup(hwif); 543 544 device_unregister(&hwif->gendev); 545 wait_for_completion(&hwif->gendev_rel_comp); 546 ··· 600 hwif->extra_base = 0; 601 hwif->extra_ports = 0; 602 } 603 + 604 + /* 605 + * Note that we only release the standard ports, 606 + * and do not even try to handle any extra ports 607 + * allocated for weird IDE interface chipsets. 608 + */ 609 + ide_hwif_release_regions(hwif); 610 611 /* copy original settings */ 612 tmp_hwif = *hwif; ··· 913 914 int system_bus_clock (void) 915 { 916 + return system_bus_speed; 917 } 918 919 EXPORT_SYMBOL(system_bus_clock); ··· 1667 1668 printk(KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n"); 1669 system_bus_speed = ide_system_bus_speed(); 1670 + 1671 + printk(KERN_INFO "ide: Assuming %dMHz system bus speed " 1672 + "for PIO modes%s\n", system_bus_speed, 1673 + idebus_parameter ? "" : "; override with idebus=xx"); 1674 1675 ret = bus_register(&ide_bus_type); 1676 if (ret < 0) {
-2
drivers/ide/legacy/ali14xx.c
··· 1 /* 2 - * linux/drivers/ide/legacy/ali14xx.c Version 0.03 Feb 09, 1996 3 - * 4 * Copyright (C) 1996 Linus Torvalds & author (see below) 5 */ 6
··· 1 /* 2 * Copyright (C) 1996 Linus Torvalds & author (see below) 3 */ 4
+1 -1
drivers/ide/legacy/buddha.c
··· 1 /* 2 - * linux/drivers/ide/legacy/buddha.c -- Amiga Buddha, Catweasel and X-Surf IDE Driver 3 * 4 * Copyright (C) 1997, 2001 by Geert Uytterhoeven and others 5 *
··· 1 /* 2 + * Amiga Buddha, Catweasel and X-Surf IDE Driver 3 * 4 * Copyright (C) 1997, 2001 by Geert Uytterhoeven and others 5 *
-2
drivers/ide/legacy/dtc2278.c
··· 1 /* 2 - * linux/drivers/ide/legacy/dtc2278.c Version 0.02 Feb 10, 1996 3 - * 4 * Copyright (C) 1996 Linus Torvalds & author (see below) 5 */ 6
··· 1 /* 2 * Copyright (C) 1996 Linus Torvalds & author (see below) 3 */ 4
+2 -1
drivers/ide/legacy/falconide.c
··· 1 /* 2 - * linux/drivers/ide/legacy/falconide.c -- Atari Falcon IDE Driver 3 * 4 * Created 12 Jul 1997 by Geert Uytterhoeven 5 * ··· 66 { 67 if (MACH_IS_ATARI && ATARIHW_PRESENT(IDE)) { 68 hw_regs_t hw; 69 70 printk(KERN_INFO "ide: Falcon IDE controller\n"); 71
··· 1 /* 2 + * Atari Falcon IDE Driver 3 * 4 * Created 12 Jul 1997 by Geert Uytterhoeven 5 * ··· 66 { 67 if (MACH_IS_ATARI && ATARIHW_PRESENT(IDE)) { 68 hw_regs_t hw; 69 + ide_hwif_t *hwif; 70 71 printk(KERN_INFO "ide: Falcon IDE controller\n"); 72
+1 -1
drivers/ide/legacy/gayle.c
··· 1 /* 2 - * linux/drivers/ide/legacy/gayle.c -- Amiga Gayle IDE Driver 3 * 4 * Created 9 Jul 1997 by Geert Uytterhoeven 5 *
··· 1 /* 2 + * Amiga Gayle IDE Driver 3 * 4 * Created 9 Jul 1997 by Geert Uytterhoeven 5 *
-2
drivers/ide/legacy/ht6560b.c
··· 1 /* 2 - * linux/drivers/ide/legacy/ht6560b.c Version 0.07 Feb 1, 2000 3 - * 4 * Copyright (C) 1995-2000 Linus Torvalds & author (see below) 5 */ 6
··· 1 /* 2 * Copyright (C) 1995-2000 Linus Torvalds & author (see below) 3 */ 4
-2
drivers/ide/legacy/ide-cs.c
··· 2 3 A driver for PCMCIA IDE/ATA disk cards 4 5 - ide-cs.c 1.3 2002/10/26 05:45:31 6 - 7 The contents of this file are subject to the Mozilla Public 8 License Version 1.1 (the "License"); you may not use this file 9 except in compliance with the License. You may obtain a copy of
··· 2 3 A driver for PCMCIA IDE/ATA disk cards 4 5 The contents of this file are subject to the Mozilla Public 6 License Version 1.1 (the "License"); you may not use this file 7 except in compliance with the License. You may obtain a copy of
+8 -26
drivers/ide/legacy/ide_platform.c
··· 21 #include <linux/platform_device.h> 22 #include <linux/io.h> 23 24 - static struct { 25 - void __iomem *plat_ide_mapbase; 26 - void __iomem *plat_ide_alt_mapbase; 27 - ide_hwif_t *hwif; 28 - int index; 29 - } hwif_prop; 30 - 31 static void __devinit plat_ide_setup_ports(hw_regs_t *hw, 32 void __iomem *base, 33 void __iomem *ctrl, ··· 47 static int __devinit plat_ide_probe(struct platform_device *pdev) 48 { 49 struct resource *res_base, *res_alt, *res_irq; 50 ide_hwif_t *hwif; 51 struct pata_platform_info *pdata; 52 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; ··· 78 } 79 80 if (mmio) { 81 - hwif_prop.plat_ide_mapbase = devm_ioremap(&pdev->dev, 82 res_base->start, res_base->end - res_base->start + 1); 83 - hwif_prop.plat_ide_alt_mapbase = devm_ioremap(&pdev->dev, 84 res_alt->start, res_alt->end - res_alt->start + 1); 85 } else { 86 - hwif_prop.plat_ide_mapbase = devm_ioport_map(&pdev->dev, 87 res_base->start, res_base->end - res_base->start + 1); 88 - hwif_prop.plat_ide_alt_mapbase = devm_ioport_map(&pdev->dev, 89 res_alt->start, res_alt->end - res_alt->start + 1); 90 } 91 92 - hwif = ide_find_port((unsigned long)hwif_prop.plat_ide_mapbase); 93 if (!hwif) { 94 ret = -ENODEV; 95 goto out; 96 } 97 98 memset(&hw, 0, sizeof(hw)); 99 - plat_ide_setup_ports(&hw, hwif_prop.plat_ide_mapbase, 100 - hwif_prop.plat_ide_alt_mapbase, 101 - pdata, res_irq->start); 102 hw.dev = &pdev->dev; 103 104 ide_init_port_hw(hwif, &hw); ··· 105 hwif->mmio = 1; 106 default_hwif_mmiops(hwif); 107 } 108 - 109 - hwif_prop.hwif = hwif; 110 - hwif_prop.index = hwif->index; 111 112 idx[0] = hwif->index; 113 ··· 122 { 123 ide_hwif_t *hwif = pdev->dev.driver_data; 124 125 - if (hwif != hwif_prop.hwif) { 126 - dev_printk(KERN_DEBUG, &pdev->dev, "%s: hwif value error", 127 - pdev->name); 128 - } else { 129 - ide_unregister(hwif_prop.index); 130 - hwif_prop.index = 0; 131 - hwif_prop.hwif = NULL; 132 - } 133 134 return 0; 135 }
··· 21 #include <linux/platform_device.h> 22 #include <linux/io.h> 23 24 static void __devinit plat_ide_setup_ports(hw_regs_t *hw, 25 void __iomem *base, 26 void __iomem *ctrl, ··· 54 static int __devinit plat_ide_probe(struct platform_device *pdev) 55 { 56 struct resource *res_base, *res_alt, *res_irq; 57 + void __iomem *base, *alt_base; 58 ide_hwif_t *hwif; 59 struct pata_platform_info *pdata; 60 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; ··· 84 } 85 86 if (mmio) { 87 + base = devm_ioremap(&pdev->dev, 88 res_base->start, res_base->end - res_base->start + 1); 89 + alt_base = devm_ioremap(&pdev->dev, 90 res_alt->start, res_alt->end - res_alt->start + 1); 91 } else { 92 + base = devm_ioport_map(&pdev->dev, 93 res_base->start, res_base->end - res_base->start + 1); 94 + alt_base = devm_ioport_map(&pdev->dev, 95 res_alt->start, res_alt->end - res_alt->start + 1); 96 } 97 98 + hwif = ide_find_port((unsigned long)base); 99 if (!hwif) { 100 ret = -ENODEV; 101 goto out; 102 } 103 104 memset(&hw, 0, sizeof(hw)); 105 + plat_ide_setup_ports(&hw, base, alt_base, pdata, res_irq->start); 106 hw.dev = &pdev->dev; 107 108 ide_init_port_hw(hwif, &hw); ··· 113 hwif->mmio = 1; 114 default_hwif_mmiops(hwif); 115 } 116 117 idx[0] = hwif->index; 118 ··· 133 { 134 ide_hwif_t *hwif = pdev->dev.driver_data; 135 136 + ide_unregister(hwif->index); 137 138 return 0; 139 }
+1 -1
drivers/ide/legacy/macide.c
··· 1 /* 2 - * linux/drivers/ide/legacy/macide.c -- Macintosh IDE Driver 3 * 4 * Copyright (C) 1998 by Michael Schmitz 5 *
··· 1 /* 2 + * Macintosh IDE Driver 3 * 4 * Copyright (C) 1998 by Michael Schmitz 5 *
+1 -1
drivers/ide/legacy/q40ide.c
··· 1 /* 2 - * linux/drivers/ide/legacy/q40ide.c -- Q40 I/O port IDE Driver 3 * 4 * (c) Richard Zidlicky 5 *
··· 1 /* 2 + * Q40 I/O port IDE Driver 3 * 4 * (c) Richard Zidlicky 5 *
-2
drivers/ide/legacy/qd65xx.c
··· 1 /* 2 - * linux/drivers/ide/legacy/qd65xx.c Version 0.07 Sep 30, 2001 3 - * 4 * Copyright (C) 1996-2001 Linus Torvalds & author (see below) 5 */ 6
··· 1 /* 2 * Copyright (C) 1996-2001 Linus Torvalds & author (see below) 3 */ 4
-2
drivers/ide/legacy/qd65xx.h
··· 1 /* 2 - * linux/drivers/ide/legacy/qd65xx.h 3 - * 4 * Copyright (c) 2000 Linus Torvalds & authors 5 */ 6
··· 1 /* 2 * Copyright (c) 2000 Linus Torvalds & authors 3 */ 4
-2
drivers/ide/legacy/umc8672.c
··· 1 /* 2 - * linux/drivers/ide/legacy/umc8672.c Version 0.05 Jul 31, 1996 3 - * 4 * Copyright (C) 1995-1996 Linus Torvalds & author (see below) 5 */ 6
··· 1 /* 2 * Copyright (C) 1995-1996 Linus Torvalds & author (see below) 3 */ 4
+8 -35
drivers/ide/mips/au1xxx-ide.c
··· 1 /* 2 - * linux/drivers/ide/mips/au1xxx-ide.c version 01.30.00 Aug. 02 2005 3 - * 4 * BRIEF MODULE DESCRIPTION 5 * AMD Alchemy Au1xxx IDE interface routines over the Static Bus 6 * ··· 48 #include <asm/mach-au1x00/au1xxx_ide.h> 49 50 #define DRV_NAME "au1200-ide" 51 - #define DRV_VERSION "1.0" 52 #define DRV_AUTHOR "Enrico Walther <enrico.walther@amd.com> / Pete Popov <ppopov@embeddedalley.com>" 53 54 /* enable the burstmode in the dbdma */ ··· 206 */ 207 208 #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 209 - 210 - static int auide_build_sglist(ide_drive_t *drive, struct request *rq) 211 - { 212 - ide_hwif_t *hwif = drive->hwif; 213 - _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data; 214 - struct scatterlist *sg = hwif->sg_table; 215 - 216 - ide_map_sg(drive, rq); 217 - 218 - if (rq_data_dir(rq) == READ) 219 - hwif->sg_dma_direction = DMA_FROM_DEVICE; 220 - else 221 - hwif->sg_dma_direction = DMA_TO_DEVICE; 222 - 223 - return dma_map_sg(ahwif->dev, sg, hwif->sg_nents, 224 - hwif->sg_dma_direction); 225 - } 226 - 227 static int auide_build_dmatable(ide_drive_t *drive) 228 { 229 int i, iswrite, count = 0; ··· 220 /* Save for interrupt context */ 221 ahwif->drive = drive; 222 223 - /* Build sglist */ 224 - hwif->sg_nents = i = auide_build_sglist(drive, rq); 225 226 if (!i) 227 return 0; ··· 278 return 1; 279 280 use_pio_instead: 281 - dma_unmap_sg(ahwif->dev, 282 - hwif->sg_table, 283 - hwif->sg_nents, 284 - hwif->sg_dma_direction); 285 286 return 0; /* revert to PIO for this request */ 287 } ··· 286 static int auide_dma_end(ide_drive_t *drive) 287 { 288 ide_hwif_t *hwif = HWIF(drive); 289 - _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data; 290 291 if (hwif->sg_nents) { 292 - dma_unmap_sg(ahwif->dev, hwif->sg_table, hwif->sg_nents, 293 - hwif->sg_dma_direction); 294 hwif->sg_nents = 0; 295 } 296 ··· 477 auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan, 478 NUM_DESCRIPTORS); 479 480 - hwif->dmatable_cpu = dma_alloc_coherent(auide->dev, 481 PRD_ENTRIES * PRD_BYTES, /* 1 Page */ 482 &hwif->dmatable_dma, GFP_KERNEL); 483 ··· 565 #endif 566 567 memset(&auide_hwif, 0, sizeof(_auide_hwif)); 568 - auide_hwif.dev = 0; 569 - 570 - ahwif->dev = dev; 571 ahwif->irq = platform_get_irq(pdev, 0); 572 573 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ··· 599 memset(&hw, 0, sizeof(hw)); 600 auide_setup_ports(&hw, ahwif); 601 hw.irq = ahwif->irq; 602 hw.chipset = ide_au1xxx; 603 604 ide_init_port_hw(hwif, &hw); 605 606 hwif->ultra_mask = 0x0; /* Disable Ultra DMA */ 607 #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA ··· 688 ide_hwif_t *hwif = dev_get_drvdata(dev); 689 _auide_hwif *ahwif = &auide_hwif; 690 691 - ide_unregister(hwif - ide_hwifs); 692 693 iounmap((void *)ahwif->regbase); 694
··· 1 /* 2 * BRIEF MODULE DESCRIPTION 3 * AMD Alchemy Au1xxx IDE interface routines over the Static Bus 4 * ··· 50 #include <asm/mach-au1x00/au1xxx_ide.h> 51 52 #define DRV_NAME "au1200-ide" 53 #define DRV_AUTHOR "Enrico Walther <enrico.walther@amd.com> / Pete Popov <ppopov@embeddedalley.com>" 54 55 /* enable the burstmode in the dbdma */ ··· 209 */ 210 211 #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 212 static int auide_build_dmatable(ide_drive_t *drive) 213 { 214 int i, iswrite, count = 0; ··· 241 /* Save for interrupt context */ 242 ahwif->drive = drive; 243 244 + hwif->sg_nents = i = ide_build_sglist(drive, rq); 245 246 if (!i) 247 return 0; ··· 300 return 1; 301 302 use_pio_instead: 303 + ide_destroy_dmatable(drive); 304 305 return 0; /* revert to PIO for this request */ 306 } ··· 311 static int auide_dma_end(ide_drive_t *drive) 312 { 313 ide_hwif_t *hwif = HWIF(drive); 314 315 if (hwif->sg_nents) { 316 + ide_destroy_dmatable(drive); 317 hwif->sg_nents = 0; 318 } 319 ··· 504 auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan, 505 NUM_DESCRIPTORS); 506 507 + hwif->dmatable_cpu = dma_alloc_coherent(hwif->dev, 508 PRD_ENTRIES * PRD_BYTES, /* 1 Page */ 509 &hwif->dmatable_dma, GFP_KERNEL); 510 ··· 592 #endif 593 594 memset(&auide_hwif, 0, sizeof(_auide_hwif)); 595 ahwif->irq = platform_get_irq(pdev, 0); 596 597 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ··· 629 memset(&hw, 0, sizeof(hw)); 630 auide_setup_ports(&hw, ahwif); 631 hw.irq = ahwif->irq; 632 + hw.dev = dev; 633 hw.chipset = ide_au1xxx; 634 635 ide_init_port_hw(hwif, &hw); 636 + 637 + hwif->dev = dev; 638 639 hwif->ultra_mask = 0x0; /* Disable Ultra DMA */ 640 #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA ··· 715 ide_hwif_t *hwif = dev_get_drvdata(dev); 716 _auide_hwif *ahwif = &auide_hwif; 717 718 + ide_unregister(hwif->index); 719 720 iounmap((void *)ahwif->regbase); 721
+5 -6
drivers/ide/pci/aec62xx.c
··· 1 /* 2 - * linux/drivers/ide/pci/aec62xx.c Version 0.27 Sep 16, 2007 3 - * 4 * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org> 5 * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com> 6 * ··· 88 static void aec6210_set_mode(ide_drive_t *drive, const u8 speed) 89 { 90 ide_hwif_t *hwif = HWIF(drive); 91 - struct pci_dev *dev = hwif->pci_dev; 92 u16 d_conf = 0; 93 u8 ultra = 0, ultra_conf = 0; 94 u8 tmp0 = 0, tmp1 = 0, tmp2 = 0; ··· 114 static void aec6260_set_mode(ide_drive_t *drive, const u8 speed) 115 { 116 ide_hwif_t *hwif = HWIF(drive); 117 - struct pci_dev *dev = hwif->pci_dev; 118 u8 unit = (drive->select.b.unit & 0x01); 119 u8 tmp1 = 0, tmp2 = 0; 120 u8 ultra = 0, drive_conf = 0, ultra_conf = 0; ··· 168 169 static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) 170 { 171 - struct pci_dev *dev = hwif->pci_dev; 172 173 hwif->set_pio_mode = &aec_set_pio_mode; 174 ··· 186 if (hwif->cbl != ATA_CBL_PATA40_SHORT) { 187 u8 ata66 = 0, mask = hwif->channel ? 0x02 : 0x01; 188 189 - pci_read_config_byte(hwif->pci_dev, 0x49, &ata66); 190 191 hwif->cbl = (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 192 } ··· 200 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, 201 .host_flags = IDE_HFLAG_SERIALIZE | 202 IDE_HFLAG_NO_ATAPI_DMA | 203 IDE_HFLAG_ABUSE_SET_DMA_MODE | 204 IDE_HFLAG_OFF_BOARD, 205 .pio_mask = ATA_PIO4,
··· 1 /* 2 * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org> 3 * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com> 4 * ··· 90 static void aec6210_set_mode(ide_drive_t *drive, const u8 speed) 91 { 92 ide_hwif_t *hwif = HWIF(drive); 93 + struct pci_dev *dev = to_pci_dev(hwif->dev); 94 u16 d_conf = 0; 95 u8 ultra = 0, ultra_conf = 0; 96 u8 tmp0 = 0, tmp1 = 0, tmp2 = 0; ··· 116 static void aec6260_set_mode(ide_drive_t *drive, const u8 speed) 117 { 118 ide_hwif_t *hwif = HWIF(drive); 119 + struct pci_dev *dev = to_pci_dev(hwif->dev); 120 u8 unit = (drive->select.b.unit & 0x01); 121 u8 tmp1 = 0, tmp2 = 0; 122 u8 ultra = 0, drive_conf = 0, ultra_conf = 0; ··· 170 171 static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) 172 { 173 + struct pci_dev *dev = to_pci_dev(hwif->dev); 174 175 hwif->set_pio_mode = &aec_set_pio_mode; 176 ··· 188 if (hwif->cbl != ATA_CBL_PATA40_SHORT) { 189 u8 ata66 = 0, mask = hwif->channel ? 0x02 : 0x01; 190 191 + pci_read_config_byte(dev, 0x49, &ata66); 192 193 hwif->cbl = (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 194 } ··· 202 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, 203 .host_flags = IDE_HFLAG_SERIALIZE | 204 IDE_HFLAG_NO_ATAPI_DMA | 205 + IDE_HFLAG_NO_DSC | 206 IDE_HFLAG_ABUSE_SET_DMA_MODE | 207 IDE_HFLAG_OFF_BOARD, 208 .pio_mask = ATA_PIO4,
+11 -9
drivers/ide/pci/alim15x3.c
··· 1 /* 2 - * linux/drivers/ide/pci/alim15x3.c Version 0.29 Sep 16 2007 3 - * 4 * Copyright (C) 1998-2000 Michel Aubry, Maintainer 5 * Copyright (C) 1998-2000 Andrzej Krzysztofowicz, Maintainer 6 * Copyright (C) 1999-2000 CJ, cjtsai@ali.com.tw, Maintainer ··· 291 static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio) 292 { 293 ide_hwif_t *hwif = HWIF(drive); 294 - struct pci_dev *dev = hwif->pci_dev; 295 int s_time, a_time, c_time; 296 u8 s_clc, a_clc, r_clc; 297 unsigned long flags; ··· 394 static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed) 395 { 396 ide_hwif_t *hwif = HWIF(drive); 397 - struct pci_dev *dev = hwif->pci_dev; 398 u8 speed1 = speed; 399 u8 unit = (drive->select.b.unit & 0x01); 400 u8 tmpbyte = 0x00; ··· 623 624 static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif) 625 { 626 - struct pci_dev *dev = hwif->pci_dev; 627 unsigned long flags; 628 u8 cbl = ATA_CBL_PATA40, tmpbyte; 629 ··· 686 687 static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif) 688 { 689 u8 ideic, inmir; 690 s8 irq_routing_table[] = { -1, 9, 3, 10, 4, 5, 7, 6, 691 1, 11, 0, 12, 0, 14, 0, 15 }; 692 int irq = -1; 693 694 - if (hwif->pci_dev->device == PCI_DEVICE_ID_AL_M5229) 695 hwif->irq = hwif->channel ? 15 : 14; 696 697 if (isa_dev) { ··· 744 return; 745 if (!hwif->channel) 746 outb(inb(dmabase + 2) & 0x60, dmabase + 2); 747 - ide_setup_dma(hwif, dmabase, 8); 748 } 749 750 static const struct ide_port_info ali15x3_chipset __devinitdata = { ··· 774 }; 775 776 struct ide_port_info d = ali15x3_chipset; 777 - u8 rev = dev->revision; 778 779 if (pci_dev_present(ati_rs100)) 780 printk(KERN_WARNING "alim15x3: ATI Radeon IGP Northbridge is not yet fully tested.\n"); ··· 797 d.udma_mask = ATA_UDMA6; 798 } 799 800 #if defined(CONFIG_SPARC64) 801 d.init_hwif = init_hwif_common_ali15x3; 802 #endif /* CONFIG_SPARC64 */ ··· 809 810 static const struct pci_device_id alim15x3_pci_tbl[] = { 811 { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5229), 0 }, 812 - { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), 0 }, 813 { 0, }, 814 }; 815 MODULE_DEVICE_TABLE(pci, alim15x3_pci_tbl);
··· 1 /* 2 * Copyright (C) 1998-2000 Michel Aubry, Maintainer 3 * Copyright (C) 1998-2000 Andrzej Krzysztofowicz, Maintainer 4 * Copyright (C) 1999-2000 CJ, cjtsai@ali.com.tw, Maintainer ··· 293 static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio) 294 { 295 ide_hwif_t *hwif = HWIF(drive); 296 + struct pci_dev *dev = to_pci_dev(hwif->dev); 297 int s_time, a_time, c_time; 298 u8 s_clc, a_clc, r_clc; 299 unsigned long flags; ··· 396 static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed) 397 { 398 ide_hwif_t *hwif = HWIF(drive); 399 + struct pci_dev *dev = to_pci_dev(hwif->dev); 400 u8 speed1 = speed; 401 u8 unit = (drive->select.b.unit & 0x01); 402 u8 tmpbyte = 0x00; ··· 625 626 static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif) 627 { 628 + struct pci_dev *dev = to_pci_dev(hwif->dev); 629 unsigned long flags; 630 u8 cbl = ATA_CBL_PATA40, tmpbyte; 631 ··· 688 689 static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif) 690 { 691 + struct pci_dev *dev = to_pci_dev(hwif->dev); 692 u8 ideic, inmir; 693 s8 irq_routing_table[] = { -1, 9, 3, 10, 4, 5, 7, 6, 694 1, 11, 0, 12, 0, 14, 0, 15 }; 695 int irq = -1; 696 697 + if (dev->device == PCI_DEVICE_ID_AL_M5229) 698 hwif->irq = hwif->channel ? 15 : 14; 699 700 if (isa_dev) { ··· 745 return; 746 if (!hwif->channel) 747 outb(inb(dmabase + 2) & 0x60, dmabase + 2); 748 + ide_setup_dma(hwif, dmabase); 749 } 750 751 static const struct ide_port_info ali15x3_chipset __devinitdata = { ··· 775 }; 776 777 struct ide_port_info d = ali15x3_chipset; 778 + u8 rev = dev->revision, idx = id->driver_data; 779 780 if (pci_dev_present(ati_rs100)) 781 printk(KERN_WARNING "alim15x3: ATI Radeon IGP Northbridge is not yet fully tested.\n"); ··· 798 d.udma_mask = ATA_UDMA6; 799 } 800 801 + if (idx == 0) 802 + d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; 803 + 804 #if defined(CONFIG_SPARC64) 805 d.init_hwif = init_hwif_common_ali15x3; 806 #endif /* CONFIG_SPARC64 */ ··· 807 808 static const struct pci_device_id alim15x3_pci_tbl[] = { 809 { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5229), 0 }, 810 + { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), 1 }, 811 { 0, }, 812 }; 813 MODULE_DEVICE_TABLE(pci, alim15x3_pci_tbl);
+128 -153
drivers/ide/pci/amd74xx.c
··· 1 /* 2 - * Version 2.24 3 - * 4 * AMD 755/756/766/8111 and nVidia nForce/2/2s/3/3s/CK804/MCP04 5 * IDE driver for Linux. 6 * ··· 26 27 #include "ide-timing.h" 28 29 - #define AMD_IDE_CONFIG (0x01 + amd_config->base) 30 - #define AMD_CABLE_DETECT (0x02 + amd_config->base) 31 - #define AMD_DRIVE_TIMING (0x08 + amd_config->base) 32 - #define AMD_8BIT_TIMING (0x0e + amd_config->base) 33 - #define AMD_ADDRESS_SETUP (0x0c + amd_config->base) 34 - #define AMD_UDMA_TIMING (0x10 + amd_config->base) 35 - 36 - #define AMD_CHECK_SWDMA 0x08 37 - #define AMD_BAD_SWDMA 0x10 38 - #define AMD_BAD_FIFO 0x20 39 - #define AMD_CHECK_SERENADE 0x40 40 - 41 - /* 42 - * AMD SouthBridge chips. 43 - */ 44 - 45 - static struct amd_ide_chip { 46 - unsigned short id; 47 - u8 base; 48 - u8 udma_mask; 49 - u8 flags; 50 - } amd_ide_chips[] = { 51 - { PCI_DEVICE_ID_AMD_COBRA_7401, 0x40, ATA_UDMA2, AMD_BAD_SWDMA }, 52 - { PCI_DEVICE_ID_AMD_VIPER_7409, 0x40, ATA_UDMA4, AMD_CHECK_SWDMA }, 53 - { PCI_DEVICE_ID_AMD_VIPER_7411, 0x40, ATA_UDMA5, AMD_BAD_FIFO }, 54 - { PCI_DEVICE_ID_AMD_OPUS_7441, 0x40, ATA_UDMA5, }, 55 - { PCI_DEVICE_ID_AMD_8111_IDE, 0x40, ATA_UDMA6, AMD_CHECK_SERENADE }, 56 - { PCI_DEVICE_ID_NVIDIA_NFORCE_IDE, 0x50, ATA_UDMA5, }, 57 - { PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE, 0x50, ATA_UDMA6, }, 58 - { PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE, 0x50, ATA_UDMA6, }, 59 - { PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA, 0x50, ATA_UDMA6, }, 60 - { PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE, 0x50, ATA_UDMA6, }, 61 - { PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE, 0x50, ATA_UDMA6, }, 62 - { PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA, 0x50, ATA_UDMA6, }, 63 - { PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2, 0x50, ATA_UDMA6, }, 64 - { PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, 0x50, ATA_UDMA6, }, 65 - { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, 0x50, ATA_UDMA6, }, 66 - { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, 0x50, ATA_UDMA6, }, 67 - { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, 0x50, ATA_UDMA6, }, 68 - { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, ATA_UDMA6, }, 69 - { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, 0x50, ATA_UDMA6, }, 70 - { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, 0x50, ATA_UDMA6, }, 71 - { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE, 0x50, ATA_UDMA6, }, 72 - { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE, 0x50, ATA_UDMA6, }, 73 - { PCI_DEVICE_ID_AMD_CS5536_IDE, 0x40, ATA_UDMA5, }, 74 - { 0 } 75 }; 76 77 - static struct amd_ide_chip *amd_config; 78 - static const struct ide_port_info *amd_chipset; 79 static unsigned int amd_80w; 80 static unsigned int amd_clock; 81 82 static char *amd_dma[] = { "16", "25", "33", "44", "66", "100", "133" }; 83 static unsigned char amd_cyc2udma[] = { 6, 6, 5, 4, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 7 }; 84 85 /* 86 * amd_set_speed() writes timing values to the chipset registers 87 */ 88 89 - static void amd_set_speed(struct pci_dev *dev, unsigned char dn, struct ide_timing *timing) 90 { 91 - unsigned char t; 92 93 - pci_read_config_byte(dev, AMD_ADDRESS_SETUP, &t); 94 t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); 95 - pci_write_config_byte(dev, AMD_ADDRESS_SETUP, t); 96 97 - pci_write_config_byte(dev, AMD_8BIT_TIMING + (1 - (dn >> 1)), 98 ((FIT(timing->act8b, 1, 16) - 1) << 4) | (FIT(timing->rec8b, 1, 16) - 1)); 99 100 - pci_write_config_byte(dev, AMD_DRIVE_TIMING + (3 - dn), 101 ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); 102 103 - switch (amd_config->udma_mask) { 104 case ATA_UDMA2: t = timing->udma ? (0xc0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; 105 case ATA_UDMA4: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 2, 10)]) : 0x03; break; 106 case ATA_UDMA5: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 1, 10)]) : 0x03; break; ··· 73 default: return; 74 } 75 76 - pci_write_config_byte(dev, AMD_UDMA_TIMING + (3 - dn), t); 77 } 78 79 /* ··· 83 84 static void amd_set_drive(ide_drive_t *drive, const u8 speed) 85 { 86 - ide_drive_t *peer = HWIF(drive)->drives + (~drive->dn & 1); 87 struct ide_timing t, p; 88 int T, UT; 89 90 T = 1000000000 / amd_clock; 91 - UT = (amd_config->udma_mask == ATA_UDMA2) ? T : (T / 2); 92 93 ide_timing_compute(drive, speed, &t, T, UT); 94 ··· 103 if (speed == XFER_UDMA_5 && amd_clock <= 33333) t.udma = 1; 104 if (speed == XFER_UDMA_6 && amd_clock <= 33333) t.udma = 15; 105 106 - amd_set_speed(HWIF(drive)->pci_dev, drive->dn, &t); 107 } 108 109 /* ··· 115 amd_set_drive(drive, XFER_PIO_0 + pio); 116 } 117 118 - /* 119 - * The initialization callback. Here we determine the IDE chip type 120 - * and initialize its drive independent registers. 121 - */ 122 - 123 - static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, const char *name) 124 { 125 - unsigned char t; 126 - unsigned int u; 127 int i; 128 129 /* 130 - * Check for bad SWDMA. 131 */ 132 133 - if (amd_config->flags & AMD_CHECK_SWDMA) { 134 - if (dev->revision <= 7) 135 - amd_config->flags |= AMD_BAD_SWDMA; 136 - } 137 138 /* 139 * Check 80-wire cable presence. 140 */ 141 142 - switch (amd_config->udma_mask) { 143 - 144 - case ATA_UDMA6: 145 - case ATA_UDMA5: 146 - pci_read_config_byte(dev, AMD_CABLE_DETECT, &t); 147 - pci_read_config_dword(dev, AMD_UDMA_TIMING, &u); 148 - amd_80w = ((t & 0x3) ? 1 : 0) | ((t & 0xc) ? 2 : 0); 149 - for (i = 24; i >= 0; i -= 8) 150 - if (((u >> i) & 4) && !(amd_80w & (1 << (1 - (i >> 4))))) { 151 - printk(KERN_WARNING "%s: BIOS didn't set cable bits correctly. Enabling workaround.\n", 152 - amd_chipset->name); 153 - amd_80w |= (1 << (1 - (i >> 4))); 154 - } 155 - break; 156 - 157 - case ATA_UDMA4: 158 - /* no host side cable detection */ 159 - amd_80w = 0x03; 160 - break; 161 - } 162 163 /* 164 * Take care of prefetch & postwrite. 165 */ 166 167 - pci_read_config_byte(dev, AMD_IDE_CONFIG, &t); 168 - pci_write_config_byte(dev, AMD_IDE_CONFIG, 169 - (amd_config->flags & AMD_BAD_FIFO) ? (t & 0x0f) : (t | 0xf0)); 170 - 171 - /* 172 - * Take care of incorrectly wired Serenade mainboards. 173 - */ 174 - 175 - if ((amd_config->flags & AMD_CHECK_SERENADE) && 176 - dev->subsystem_vendor == PCI_VENDOR_ID_AMD && 177 - dev->subsystem_device == PCI_DEVICE_ID_AMD_SERENADE) 178 - amd_config->udma_mask = ATA_UDMA5; 179 180 /* 181 * Determine the system bus clock. ··· 192 193 if (amd_clock < 20000 || amd_clock > 50000) { 194 printk(KERN_WARNING "%s: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", 195 - amd_chipset->name, amd_clock); 196 amd_clock = 33333; 197 } 198 - 199 - /* 200 - * Print the boot message. 201 - */ 202 - 203 - printk(KERN_INFO "%s: %s (rev %02x) UDMA%s controller\n", 204 - amd_chipset->name, pci_name(dev), dev->revision, 205 - amd_dma[fls(amd_config->udma_mask) - 1]); 206 207 return dev->irq; 208 } 209 210 static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) 211 { 212 if (hwif->irq == 0) /* 0 is bogus but will do for now */ 213 - hwif->irq = pci_get_legacy_ide_irq(hwif->pci_dev, hwif->channel); 214 215 hwif->set_pio_mode = &amd_set_pio_mode; 216 hwif->set_dma_mode = &amd_set_drive; 217 218 if (!hwif->dma_base) 219 return; 220 - 221 - hwif->ultra_mask = amd_config->udma_mask; 222 - if (amd_config->flags & AMD_BAD_SWDMA) 223 - hwif->swdma_mask = 0x00; 224 225 if (hwif->cbl != ATA_CBL_PATA40_SHORT) { 226 if ((amd_80w >> hwif->channel) & 1) ··· 229 IDE_HFLAG_UNMASK_IRQS | \ 230 IDE_HFLAG_BOOTABLE) 231 232 - #define DECLARE_AMD_DEV(name_str) \ 233 { \ 234 .name = name_str, \ 235 .init_chipset = init_chipset_amd74xx, \ ··· 237 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ 238 .host_flags = IDE_HFLAGS_AMD, \ 239 .pio_mask = ATA_PIO5, \ 240 - .swdma_mask = ATA_SWDMA2, \ 241 .mwdma_mask = ATA_MWDMA2, \ 242 } 243 244 - #define DECLARE_NV_DEV(name_str) \ 245 { \ 246 .name = name_str, \ 247 .init_chipset = init_chipset_amd74xx, \ ··· 252 .pio_mask = ATA_PIO5, \ 253 .swdma_mask = ATA_SWDMA2, \ 254 .mwdma_mask = ATA_MWDMA2, \ 255 } 256 257 static const struct ide_port_info amd74xx_chipsets[] __devinitdata = { 258 - /* 0 */ DECLARE_AMD_DEV("AMD7401"), 259 - /* 1 */ DECLARE_AMD_DEV("AMD7409"), 260 - /* 2 */ DECLARE_AMD_DEV("AMD7411"), 261 - /* 3 */ DECLARE_AMD_DEV("AMD7441"), 262 - /* 4 */ DECLARE_AMD_DEV("AMD8111"), 263 264 - /* 5 */ DECLARE_NV_DEV("NFORCE"), 265 - /* 6 */ DECLARE_NV_DEV("NFORCE2"), 266 - /* 7 */ DECLARE_NV_DEV("NFORCE2-U400R"), 267 - /* 8 */ DECLARE_NV_DEV("NFORCE2-U400R-SATA"), 268 - /* 9 */ DECLARE_NV_DEV("NFORCE3-150"), 269 - /* 10 */ DECLARE_NV_DEV("NFORCE3-250"), 270 - /* 11 */ DECLARE_NV_DEV("NFORCE3-250-SATA"), 271 - /* 12 */ DECLARE_NV_DEV("NFORCE3-250-SATA2"), 272 - /* 13 */ DECLARE_NV_DEV("NFORCE-CK804"), 273 - /* 14 */ DECLARE_NV_DEV("NFORCE-MCP04"), 274 - /* 15 */ DECLARE_NV_DEV("NFORCE-MCP51"), 275 - /* 16 */ DECLARE_NV_DEV("NFORCE-MCP55"), 276 - /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61"), 277 - /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65"), 278 - /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67"), 279 - /* 20 */ DECLARE_NV_DEV("NFORCE-MCP73"), 280 - /* 21 */ DECLARE_NV_DEV("NFORCE-MCP77"), 281 - /* 22 */ DECLARE_AMD_DEV("AMD5536"), 282 }; 283 284 static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) 285 { 286 - amd_chipset = amd74xx_chipsets + id->driver_data; 287 - amd_config = amd_ide_chips + id->driver_data; 288 - if (dev->device != amd_config->id) { 289 - printk(KERN_ERR "%s: assertion 0x%02x == 0x%02x failed !\n", 290 - pci_name(dev), dev->device, amd_config->id); 291 - return -ENODEV; 292 } 293 - return ide_setup_pci_device(dev, amd_chipset); 294 } 295 296 static const struct pci_device_id amd74xx_pci_tbl[] = {
··· 1 /* 2 * AMD 755/756/766/8111 and nVidia nForce/2/2s/3/3s/CK804/MCP04 3 * IDE driver for Linux. 4 * ··· 28 29 #include "ide-timing.h" 30 31 + enum { 32 + AMD_IDE_CONFIG = 0x41, 33 + AMD_CABLE_DETECT = 0x42, 34 + AMD_DRIVE_TIMING = 0x48, 35 + AMD_8BIT_TIMING = 0x4e, 36 + AMD_ADDRESS_SETUP = 0x4c, 37 + AMD_UDMA_TIMING = 0x50, 38 }; 39 40 static unsigned int amd_80w; 41 static unsigned int amd_clock; 42 43 static char *amd_dma[] = { "16", "25", "33", "44", "66", "100", "133" }; 44 static unsigned char amd_cyc2udma[] = { 6, 6, 5, 4, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 7 }; 45 46 + static inline u8 amd_offset(struct pci_dev *dev) 47 + { 48 + return (dev->vendor == PCI_VENDOR_ID_NVIDIA) ? 0x10 : 0; 49 + } 50 + 51 /* 52 * amd_set_speed() writes timing values to the chipset registers 53 */ 54 55 + static void amd_set_speed(struct pci_dev *dev, u8 dn, u8 udma_mask, 56 + struct ide_timing *timing) 57 { 58 + u8 t = 0, offset = amd_offset(dev); 59 60 + pci_read_config_byte(dev, AMD_ADDRESS_SETUP + offset, &t); 61 t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); 62 + pci_write_config_byte(dev, AMD_ADDRESS_SETUP + offset, t); 63 64 + pci_write_config_byte(dev, AMD_8BIT_TIMING + offset + (1 - (dn >> 1)), 65 ((FIT(timing->act8b, 1, 16) - 1) << 4) | (FIT(timing->rec8b, 1, 16) - 1)); 66 67 + pci_write_config_byte(dev, AMD_DRIVE_TIMING + offset + (3 - dn), 68 ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); 69 70 + switch (udma_mask) { 71 case ATA_UDMA2: t = timing->udma ? (0xc0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; 72 case ATA_UDMA4: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 2, 10)]) : 0x03; break; 73 case ATA_UDMA5: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 1, 10)]) : 0x03; break; ··· 110 default: return; 111 } 112 113 + pci_write_config_byte(dev, AMD_UDMA_TIMING + offset + (3 - dn), t); 114 } 115 116 /* ··· 120 121 static void amd_set_drive(ide_drive_t *drive, const u8 speed) 122 { 123 + ide_hwif_t *hwif = drive->hwif; 124 + struct pci_dev *dev = to_pci_dev(hwif->dev); 125 + ide_drive_t *peer = hwif->drives + (~drive->dn & 1); 126 struct ide_timing t, p; 127 int T, UT; 128 + u8 udma_mask = hwif->ultra_mask; 129 130 T = 1000000000 / amd_clock; 131 + UT = (udma_mask == ATA_UDMA2) ? T : (T / 2); 132 133 ide_timing_compute(drive, speed, &t, T, UT); 134 ··· 137 if (speed == XFER_UDMA_5 && amd_clock <= 33333) t.udma = 1; 138 if (speed == XFER_UDMA_6 && amd_clock <= 33333) t.udma = 15; 139 140 + amd_set_speed(dev, drive->dn, udma_mask, &t); 141 } 142 143 /* ··· 149 amd_set_drive(drive, XFER_PIO_0 + pio); 150 } 151 152 + static void __devinit amd7409_cable_detect(struct pci_dev *dev, 153 + const char *name) 154 { 155 + /* no host side cable detection */ 156 + amd_80w = 0x03; 157 + } 158 + 159 + static void __devinit amd7411_cable_detect(struct pci_dev *dev, 160 + const char *name) 161 + { 162 int i; 163 + u32 u = 0; 164 + u8 t = 0, offset = amd_offset(dev); 165 + 166 + pci_read_config_byte(dev, AMD_CABLE_DETECT + offset, &t); 167 + pci_read_config_dword(dev, AMD_UDMA_TIMING + offset, &u); 168 + amd_80w = ((t & 0x3) ? 1 : 0) | ((t & 0xc) ? 2 : 0); 169 + for (i = 24; i >= 0; i -= 8) 170 + if (((u >> i) & 4) && !(amd_80w & (1 << (1 - (i >> 4))))) { 171 + printk(KERN_WARNING "%s: BIOS didn't set cable bits " 172 + "correctly. Enabling workaround.\n", 173 + name); 174 + amd_80w |= (1 << (1 - (i >> 4))); 175 + } 176 + } 177 178 /* 179 + * The initialization callback. Initialize drive independent registers. 180 */ 181 182 + static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, 183 + const char *name) 184 + { 185 + u8 t = 0, offset = amd_offset(dev); 186 187 /* 188 * Check 80-wire cable presence. 189 */ 190 191 + if (dev->vendor == PCI_VENDOR_ID_AMD && 192 + dev->device == PCI_DEVICE_ID_AMD_COBRA_7401) 193 + ; /* no UDMA > 2 */ 194 + else if (dev->vendor == PCI_VENDOR_ID_AMD && 195 + dev->device == PCI_DEVICE_ID_AMD_VIPER_7409) 196 + amd7409_cable_detect(dev, name); 197 + else 198 + amd7411_cable_detect(dev, name); 199 200 /* 201 * Take care of prefetch & postwrite. 202 */ 203 204 + pci_read_config_byte(dev, AMD_IDE_CONFIG + offset, &t); 205 + /* 206 + * Check for broken FIFO support. 207 + */ 208 + if (dev->vendor == PCI_VENDOR_ID_AMD && 209 + dev->vendor == PCI_DEVICE_ID_AMD_VIPER_7411) 210 + t &= 0x0f; 211 + else 212 + t |= 0xf0; 213 + pci_write_config_byte(dev, AMD_IDE_CONFIG + offset, t); 214 215 /* 216 * Determine the system bus clock. ··· 225 226 if (amd_clock < 20000 || amd_clock > 50000) { 227 printk(KERN_WARNING "%s: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", 228 + name, amd_clock); 229 amd_clock = 33333; 230 } 231 232 return dev->irq; 233 } 234 235 static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif) 236 { 237 + struct pci_dev *dev = to_pci_dev(hwif->dev); 238 + 239 if (hwif->irq == 0) /* 0 is bogus but will do for now */ 240 + hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel); 241 242 hwif->set_pio_mode = &amd_set_pio_mode; 243 hwif->set_dma_mode = &amd_set_drive; 244 245 if (!hwif->dma_base) 246 return; 247 248 if (hwif->cbl != ATA_CBL_PATA40_SHORT) { 249 if ((amd_80w >> hwif->channel) & 1) ··· 272 IDE_HFLAG_UNMASK_IRQS | \ 273 IDE_HFLAG_BOOTABLE) 274 275 + #define DECLARE_AMD_DEV(name_str, swdma, udma) \ 276 { \ 277 .name = name_str, \ 278 .init_chipset = init_chipset_amd74xx, \ ··· 280 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ 281 .host_flags = IDE_HFLAGS_AMD, \ 282 .pio_mask = ATA_PIO5, \ 283 + .swdma_mask = swdma, \ 284 .mwdma_mask = ATA_MWDMA2, \ 285 + .udma_mask = udma, \ 286 } 287 288 + #define DECLARE_NV_DEV(name_str, udma) \ 289 { \ 290 .name = name_str, \ 291 .init_chipset = init_chipset_amd74xx, \ ··· 294 .pio_mask = ATA_PIO5, \ 295 .swdma_mask = ATA_SWDMA2, \ 296 .mwdma_mask = ATA_MWDMA2, \ 297 + .udma_mask = udma, \ 298 } 299 300 static const struct ide_port_info amd74xx_chipsets[] __devinitdata = { 301 + /* 0 */ DECLARE_AMD_DEV("AMD7401", 0x00, ATA_UDMA2), 302 + /* 1 */ DECLARE_AMD_DEV("AMD7409", ATA_SWDMA2, ATA_UDMA4), 303 + /* 2 */ DECLARE_AMD_DEV("AMD7411", ATA_SWDMA2, ATA_UDMA5), 304 + /* 3 */ DECLARE_AMD_DEV("AMD7441", ATA_SWDMA2, ATA_UDMA5), 305 + /* 4 */ DECLARE_AMD_DEV("AMD8111", ATA_SWDMA2, ATA_UDMA6), 306 307 + /* 5 */ DECLARE_NV_DEV("NFORCE", ATA_UDMA5), 308 + /* 6 */ DECLARE_NV_DEV("NFORCE2", ATA_UDMA6), 309 + /* 7 */ DECLARE_NV_DEV("NFORCE2-U400R", ATA_UDMA6), 310 + /* 8 */ DECLARE_NV_DEV("NFORCE2-U400R-SATA", ATA_UDMA6), 311 + /* 9 */ DECLARE_NV_DEV("NFORCE3-150", ATA_UDMA6), 312 + /* 10 */ DECLARE_NV_DEV("NFORCE3-250", ATA_UDMA6), 313 + /* 11 */ DECLARE_NV_DEV("NFORCE3-250-SATA", ATA_UDMA6), 314 + /* 12 */ DECLARE_NV_DEV("NFORCE3-250-SATA2", ATA_UDMA6), 315 + /* 13 */ DECLARE_NV_DEV("NFORCE-CK804", ATA_UDMA6), 316 + /* 14 */ DECLARE_NV_DEV("NFORCE-MCP04", ATA_UDMA6), 317 + /* 15 */ DECLARE_NV_DEV("NFORCE-MCP51", ATA_UDMA6), 318 + /* 16 */ DECLARE_NV_DEV("NFORCE-MCP55", ATA_UDMA6), 319 + /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61", ATA_UDMA6), 320 + /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65", ATA_UDMA6), 321 + /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67", ATA_UDMA6), 322 + /* 20 */ DECLARE_NV_DEV("NFORCE-MCP73", ATA_UDMA6), 323 + /* 21 */ DECLARE_NV_DEV("NFORCE-MCP77", ATA_UDMA6), 324 + 325 + /* 22 */ DECLARE_AMD_DEV("AMD5536", ATA_SWDMA2, ATA_UDMA5), 326 }; 327 328 static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) 329 { 330 + struct ide_port_info d; 331 + u8 idx = id->driver_data; 332 + 333 + d = amd74xx_chipsets[idx]; 334 + 335 + /* 336 + * Check for bad SWDMA and incorrectly wired Serenade mainboards. 337 + */ 338 + if (idx == 1) { 339 + if (dev->revision <= 7) 340 + d.swdma_mask = 0; 341 + d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; 342 + } else if (idx == 4) { 343 + if (dev->subsystem_vendor == PCI_VENDOR_ID_AMD && 344 + dev->subsystem_device == PCI_DEVICE_ID_AMD_SERENADE) 345 + d.udma_mask = ATA_UDMA5; 346 } 347 + 348 + printk(KERN_INFO "%s: %s (rev %02x) UDMA%s controller\n", 349 + d.name, pci_name(dev), dev->revision, 350 + amd_dma[fls(d.udma_mask) - 1]); 351 + 352 + return ide_setup_pci_device(dev, &d); 353 } 354 355 static const struct pci_device_id amd74xx_pci_tbl[] = {
+4 -7
drivers/ide/pci/atiixp.c
··· 1 /* 2 - * linux/drivers/ide/pci/atiixp.c Version 0.05 Nov 9 2007 3 - * 4 * Copyright (C) 2003 ATI Inc. <hyu@ati.com> 5 * Copyright (C) 2004,2007 Bartlomiej Zolnierkiewicz 6 */ ··· 53 54 static void atiixp_set_pio_mode(ide_drive_t *drive, const u8 pio) 55 { 56 - struct pci_dev *dev = drive->hwif->pci_dev; 57 unsigned long flags; 58 int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8; 59 u32 pio_timing_data; ··· 86 87 static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed) 88 { 89 - struct pci_dev *dev = drive->hwif->pci_dev; 90 unsigned long flags; 91 int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8; 92 u32 tmp32; ··· 131 132 static void __devinit init_hwif_atiixp(ide_hwif_t *hwif) 133 { 134 - u8 udma_mode = 0; 135 - u8 ch = hwif->channel; 136 - struct pci_dev *pdev = hwif->pci_dev; 137 138 hwif->set_pio_mode = &atiixp_set_pio_mode; 139 hwif->set_dma_mode = &atiixp_set_dma_mode;
··· 1 /* 2 * Copyright (C) 2003 ATI Inc. <hyu@ati.com> 3 * Copyright (C) 2004,2007 Bartlomiej Zolnierkiewicz 4 */ ··· 55 56 static void atiixp_set_pio_mode(ide_drive_t *drive, const u8 pio) 57 { 58 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 59 unsigned long flags; 60 int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8; 61 u32 pio_timing_data; ··· 88 89 static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed) 90 { 91 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 92 unsigned long flags; 93 int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8; 94 u32 tmp32; ··· 133 134 static void __devinit init_hwif_atiixp(ide_hwif_t *hwif) 135 { 136 + struct pci_dev *pdev = to_pci_dev(hwif->dev); 137 + u8 udma_mode = 0, ch = hwif->channel; 138 139 hwif->set_pio_mode = &atiixp_set_pio_mode; 140 hwif->set_dma_mode = &atiixp_set_dma_mode;
-2
drivers/ide/pci/cmd640.c
··· 1 /* 2 - * linux/drivers/ide/pci/cmd640.c Version 1.02 Sep 01, 1996 3 - * 4 * Copyright (C) 1995-1996 Linus Torvalds & authors (see below) 5 */ 6
··· 1 /* 2 * Copyright (C) 1995-1996 Linus Torvalds & authors (see below) 3 */ 4
+10 -10
drivers/ide/pci/cmd64x.c
··· 1 /* 2 - * linux/drivers/ide/pci/cmd64x.c Version 1.53 Dec 24, 2007 3 - * 4 * cmd64x.c: Enable interrupts at initialization time on Ultra/PCI machines. 5 * Due to massive hardware bugs, UltraDMA is only supported 6 * on the 646U2 and not on the 646U. ··· 69 */ 70 static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time) 71 { 72 - struct pci_dev *dev = HWIF(drive)->pci_dev; 73 int clock_time = 1000 / system_bus_clock(); 74 u8 cycle_count, active_count, recovery_count, drwtim; 75 static const u8 recovery_values[] = ··· 116 static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio) 117 { 118 ide_hwif_t *hwif = HWIF(drive); 119 - struct pci_dev *dev = hwif->pci_dev; 120 unsigned int cycle_time; 121 u8 setup_count, arttim = 0; 122 ··· 181 static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed) 182 { 183 ide_hwif_t *hwif = HWIF(drive); 184 - struct pci_dev *dev = hwif->pci_dev; 185 u8 unit = drive->dn & 0x01; 186 u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0; 187 ··· 243 static int cmd64x_ide_dma_end (ide_drive_t *drive) 244 { 245 ide_hwif_t *hwif = HWIF(drive); 246 - struct pci_dev *dev = hwif->pci_dev; 247 int irq_reg = hwif->channel ? ARTTIM23 : CFR; 248 u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : 249 CFR_INTR_CH0; ··· 283 static int cmd64x_ide_dma_test_irq (ide_drive_t *drive) 284 { 285 ide_hwif_t *hwif = HWIF(drive); 286 - struct pci_dev *dev = hwif->pci_dev; 287 int irq_reg = hwif->channel ? ARTTIM23 : CFR; 288 u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : 289 CFR_INTR_CH0; ··· 373 374 static u8 __devinit ata66_cmd64x(ide_hwif_t *hwif) 375 { 376 - struct pci_dev *dev = hwif->pci_dev; 377 u8 bmidecsr = 0, mask = hwif->channel ? 0x02 : 0x01; 378 379 switch (dev->device) { ··· 388 389 static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif) 390 { 391 - struct pci_dev *dev = hwif->pci_dev; 392 393 hwif->set_pio_mode = &cmd64x_set_pio_mode; 394 hwif->set_dma_mode = &cmd64x_set_dma_mode; ··· 441 .init_chipset = init_chipset_cmd64x, 442 .init_hwif = init_hwif_cmd64x, 443 .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, 444 - .host_flags = IDE_HFLAG_ABUSE_PREFETCH | IDE_HFLAG_BOOTABLE, 445 .pio_mask = ATA_PIO5, 446 .mwdma_mask = ATA_MWDMA2, 447 .udma_mask = 0x00, /* no udma */
··· 1 /* 2 * cmd64x.c: Enable interrupts at initialization time on Ultra/PCI machines. 3 * Due to massive hardware bugs, UltraDMA is only supported 4 * on the 646U2 and not on the 646U. ··· 71 */ 72 static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time) 73 { 74 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 75 int clock_time = 1000 / system_bus_clock(); 76 u8 cycle_count, active_count, recovery_count, drwtim; 77 static const u8 recovery_values[] = ··· 118 static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio) 119 { 120 ide_hwif_t *hwif = HWIF(drive); 121 + struct pci_dev *dev = to_pci_dev(hwif->dev); 122 unsigned int cycle_time; 123 u8 setup_count, arttim = 0; 124 ··· 183 static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed) 184 { 185 ide_hwif_t *hwif = HWIF(drive); 186 + struct pci_dev *dev = to_pci_dev(hwif->dev); 187 u8 unit = drive->dn & 0x01; 188 u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0; 189 ··· 245 static int cmd64x_ide_dma_end (ide_drive_t *drive) 246 { 247 ide_hwif_t *hwif = HWIF(drive); 248 + struct pci_dev *dev = to_pci_dev(hwif->dev); 249 int irq_reg = hwif->channel ? ARTTIM23 : CFR; 250 u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : 251 CFR_INTR_CH0; ··· 285 static int cmd64x_ide_dma_test_irq (ide_drive_t *drive) 286 { 287 ide_hwif_t *hwif = HWIF(drive); 288 + struct pci_dev *dev = to_pci_dev(hwif->dev); 289 int irq_reg = hwif->channel ? ARTTIM23 : CFR; 290 u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : 291 CFR_INTR_CH0; ··· 375 376 static u8 __devinit ata66_cmd64x(ide_hwif_t *hwif) 377 { 378 + struct pci_dev *dev = to_pci_dev(hwif->dev); 379 u8 bmidecsr = 0, mask = hwif->channel ? 0x02 : 0x01; 380 381 switch (dev->device) { ··· 390 391 static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif) 392 { 393 + struct pci_dev *dev = to_pci_dev(hwif->dev); 394 395 hwif->set_pio_mode = &cmd64x_set_pio_mode; 396 hwif->set_dma_mode = &cmd64x_set_dma_mode; ··· 443 .init_chipset = init_chipset_cmd64x, 444 .init_hwif = init_hwif_cmd64x, 445 .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, 446 + .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | 447 + IDE_HFLAG_ABUSE_PREFETCH | 448 + IDE_HFLAG_BOOTABLE, 449 .pio_mask = ATA_PIO5, 450 .mwdma_mask = ATA_MWDMA2, 451 .udma_mask = 0x00, /* no udma */
+1 -1
drivers/ide/pci/cs5520.c
··· 69 static void cs5520_set_pio_mode(ide_drive_t *drive, const u8 pio) 70 { 71 ide_hwif_t *hwif = HWIF(drive); 72 - struct pci_dev *pdev = hwif->pci_dev; 73 int controller = drive->dn > 1 ? 1 : 0; 74 75 /* FIXME: if DMA = 1 do we need to set the DMA bit here ? */
··· 69 static void cs5520_set_pio_mode(ide_drive_t *drive, const u8 pio) 70 { 71 ide_hwif_t *hwif = HWIF(drive); 72 + struct pci_dev *pdev = to_pci_dev(hwif->dev); 73 int controller = drive->dn > 1 ? 1 : 0; 74 75 /* FIXME: if DMA = 1 do we need to set the DMA bit here ? */
-2
drivers/ide/pci/cs5530.c
··· 1 /* 2 - * linux/drivers/ide/pci/cs5530.c Version 0.77 Sep 24 2007 3 - * 4 * Copyright (C) 2000 Andre Hedrick <andre@linux-ide.org> 5 * Copyright (C) 2000 Mark Lord <mlord@pobox.com> 6 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz
··· 1 /* 2 * Copyright (C) 2000 Andre Hedrick <andre@linux-ide.org> 3 * Copyright (C) 2000 Mark Lord <mlord@pobox.com> 4 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz
+3 -3
drivers/ide/pci/cs5535.c
··· 1 /* 2 - * linux/drivers/ide/pci/cs5535.c 3 - * 4 * Copyright (C) 2004-2005 Advanced Micro Devices, Inc. 5 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 6 * ··· 175 */ 176 static void __devinit init_hwif_cs5535(ide_hwif_t *hwif) 177 { 178 hwif->set_pio_mode = &cs5535_set_pio_mode; 179 hwif->set_dma_mode = &cs5535_set_dma_mode; 180 181 if (hwif->dma_base == 0) 182 return; 183 184 - hwif->cbl = cs5535_cable_detect(hwif->pci_dev); 185 } 186 187 static const struct ide_port_info cs5535_chipset __devinitdata = {
··· 1 /* 2 * Copyright (C) 2004-2005 Advanced Micro Devices, Inc. 3 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 4 * ··· 177 */ 178 static void __devinit init_hwif_cs5535(ide_hwif_t *hwif) 179 { 180 + struct pci_dev *dev = to_pci_dev(hwif->dev); 181 + 182 hwif->set_pio_mode = &cs5535_set_pio_mode; 183 hwif->set_dma_mode = &cs5535_set_dma_mode; 184 185 if (hwif->dma_base == 0) 186 return; 187 188 + hwif->cbl = cs5535_cable_detect(dev); 189 } 190 191 static const struct ide_port_info cs5535_chipset __devinitdata = {
+3 -4
drivers/ide/pci/cy82c693.c
··· 1 /* 2 - * linux/drivers/ide/pci/cy82c693.c Version 0.44 Nov 8, 2007 3 - * 4 * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer 5 * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>, Integrator 6 * ··· 226 static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) 227 { 228 ide_hwif_t *hwif = HWIF(drive); 229 - struct pci_dev *dev = hwif->pci_dev; 230 pio_clocks_t pclk; 231 unsigned int addrCtrl; 232 ··· 395 static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) 396 { 397 static ide_hwif_t *primary; 398 399 - if (PCI_FUNC(hwif->pci_dev->devfn) == 1) 400 primary = hwif; 401 else { 402 hwif->mate = primary;
··· 1 /* 2 * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer 3 * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>, Integrator 4 * ··· 228 static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) 229 { 230 ide_hwif_t *hwif = HWIF(drive); 231 + struct pci_dev *dev = to_pci_dev(hwif->dev); 232 pio_clocks_t pclk; 233 unsigned int addrCtrl; 234 ··· 397 static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) 398 { 399 static ide_hwif_t *primary; 400 + struct pci_dev *dev = to_pci_dev(hwif->dev); 401 402 + if (PCI_FUNC(dev->devfn) == 1) 403 primary = hwif; 404 else { 405 hwif->mate = primary;
+1 -3
drivers/ide/pci/delkin_cb.c
··· 1 /* 2 - * linux/drivers/ide/pci/delkin_cb.c 3 - * 4 * Created 20 Oct 2004 by Mark Lord 5 * 6 * Basic support for Delkin/ASKA/Workbit Cardbus CompactFlash adapter ··· 85 return -ENODEV; 86 } 87 pci_set_drvdata(dev, hwif); 88 - hwif->pci_dev = dev; 89 drive = &hwif->drives[0]; 90 if (drive->present) { 91 drive->io_32bit = 1;
··· 1 /* 2 * Created 20 Oct 2004 by Mark Lord 3 * 4 * Basic support for Delkin/ASKA/Workbit Cardbus CompactFlash adapter ··· 87 return -ENODEV; 88 } 89 pci_set_drvdata(dev, hwif); 90 + hwif->dev = &dev->dev; 91 drive = &hwif->drives[0]; 92 if (drive->present) { 93 drive->io_32bit = 1;
+2 -3
drivers/ide/pci/generic.c
··· 1 /* 2 - * linux/drivers/ide/pci/generic.c Version 0.11 December 30, 2002 3 - * 4 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> 5 * Portions (C) Copyright 2002 Red Hat Inc <alan@redhat.com> 6 * ··· 102 103 { /* 14 */ 104 .name = "Revolution", 105 - .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | 106 IDE_HFLAG_OFF_BOARD, 107 .swdma_mask = ATA_SWDMA2, 108 .mwdma_mask = ATA_MWDMA2,
··· 1 /* 2 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> 3 * Portions (C) Copyright 2002 Red Hat Inc <alan@redhat.com> 4 * ··· 104 105 { /* 14 */ 106 .name = "Revolution", 107 + .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | 108 + IDE_HFLAG_TRUST_BIOS_FOR_DMA | 109 IDE_HFLAG_OFF_BOARD, 110 .swdma_mask = ATA_SWDMA2, 111 .mwdma_mask = ATA_MWDMA2,
+3 -3
drivers/ide/pci/hpt34x.c
··· 1 /* 2 - * linux/drivers/ide/pci/hpt34x.c Version 0.40 Sept 10, 2002 3 - * 4 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> 5 * May be copied or modified under the terms of the GNU General Public License 6 * 7 * ··· 44 45 static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed) 46 { 47 - struct pci_dev *dev = HWIF(drive)->pci_dev; 48 u32 reg1= 0, tmp1 = 0, reg2 = 0, tmp2 = 0; 49 u8 hi_speed, lo_speed; 50 ··· 130 131 #define IDE_HFLAGS_HPT34X \ 132 (IDE_HFLAG_NO_ATAPI_DMA | \ 133 IDE_HFLAG_ABUSE_SET_DMA_MODE | \ 134 IDE_HFLAG_NO_AUTODMA) 135
··· 1 /* 2 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> 3 + * 4 * May be copied or modified under the terms of the GNU General Public License 5 * 6 * ··· 45 46 static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed) 47 { 48 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 49 u32 reg1= 0, tmp1 = 0, reg2 = 0, tmp2 = 0; 50 u8 hi_speed, lo_speed; 51 ··· 131 132 #define IDE_HFLAGS_HPT34X \ 133 (IDE_HFLAG_NO_ATAPI_DMA | \ 134 + IDE_HFLAG_NO_DSC | \ 135 IDE_HFLAG_ABUSE_SET_DMA_MODE | \ 136 IDE_HFLAG_NO_AUTODMA) 137
+18 -15
drivers/ide/pci/hpt366.c
··· 1 /* 2 - * linux/drivers/ide/pci/hpt366.c Version 1.30 Dec 12, 2007 3 - * 4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> 5 * Portions Copyright (C) 2001 Sun Microsystems, Inc. 6 * Portions Copyright (C) 2003 Red Hat Inc ··· 624 static u8 hpt3xx_udma_filter(ide_drive_t *drive) 625 { 626 ide_hwif_t *hwif = HWIF(drive); 627 - struct hpt_info *info = pci_get_drvdata(hwif->pci_dev); 628 u8 mask = hwif->ultra_mask; 629 630 switch (info->chip_type) { ··· 664 static u8 hpt3xx_mdma_filter(ide_drive_t *drive) 665 { 666 ide_hwif_t *hwif = HWIF(drive); 667 - struct hpt_info *info = pci_get_drvdata(hwif->pci_dev); 668 669 switch (info->chip_type) { 670 case HPT372 : ··· 699 700 static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed) 701 { 702 - struct pci_dev *dev = HWIF(drive)->pci_dev; 703 struct hpt_info *info = pci_get_drvdata(dev); 704 struct hpt_timings *t = info->timings; 705 u8 itr_addr = 0x40 + (drive->dn * 4); ··· 742 static void hpt3xx_maskproc(ide_drive_t *drive, int mask) 743 { 744 ide_hwif_t *hwif = HWIF(drive); 745 - struct pci_dev *dev = hwif->pci_dev; 746 struct hpt_info *info = pci_get_drvdata(dev); 747 748 if (drive->quirk_list) { ··· 774 */ 775 static void hpt366_dma_lost_irq(ide_drive_t *drive) 776 { 777 - struct pci_dev *dev = HWIF(drive)->pci_dev; 778 u8 mcr1 = 0, mcr3 = 0, scr1 = 0; 779 780 pci_read_config_byte(dev, 0x50, &mcr1); ··· 790 static void hpt370_clear_engine(ide_drive_t *drive) 791 { 792 ide_hwif_t *hwif = HWIF(drive); 793 794 - pci_write_config_byte(hwif->pci_dev, hwif->select_data, 0x37); 795 udelay(10); 796 } 797 798 static void hpt370_irq_timeout(ide_drive_t *drive) 799 { 800 ide_hwif_t *hwif = HWIF(drive); 801 u16 bfifo = 0; 802 u8 dma_cmd; 803 804 - pci_read_config_word(hwif->pci_dev, hwif->select_data + 2, &bfifo); 805 printk(KERN_DEBUG "%s: %d bytes in FIFO\n", drive->name, bfifo & 0x1ff); 806 807 /* get DMA command mode */ ··· 846 static int hpt374_ide_dma_test_irq(ide_drive_t *drive) 847 { 848 ide_hwif_t *hwif = HWIF(drive); 849 u16 bfifo = 0; 850 u8 dma_stat; 851 852 - pci_read_config_word(hwif->pci_dev, hwif->select_data + 2, &bfifo); 853 if (bfifo & 0x1FF) { 854 // printk("%s: %d bytes in FIFO\n", drive->name, bfifo); 855 return 0; ··· 870 static int hpt374_ide_dma_end(ide_drive_t *drive) 871 { 872 ide_hwif_t *hwif = HWIF(drive); 873 - struct pci_dev *dev = hwif->pci_dev; 874 u8 mcr = 0, mcr_addr = hwif->select_data; 875 u8 bwsr = 0, mask = hwif->channel ? 0x02 : 0x01; 876 ··· 945 static int hpt3xx_busproc(ide_drive_t *drive, int state) 946 { 947 ide_hwif_t *hwif = HWIF(drive); 948 - struct pci_dev *dev = hwif->pci_dev; 949 u8 mcr_addr = hwif->select_data + 2; 950 u8 resetmask = hwif->channel ? 0x80 : 0x40; 951 u8 bsr2 = 0; ··· 1281 1282 static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) 1283 { 1284 - struct pci_dev *dev = hwif->pci_dev; 1285 struct hpt_info *info = pci_get_drvdata(dev); 1286 int serialize = HPT_SERIALIZE_IO; 1287 u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02; ··· 1396 1397 static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) 1398 { 1399 - struct pci_dev *dev = hwif->pci_dev; 1400 u8 masterdma = 0, slavedma = 0; 1401 u8 dma_new = 0, dma_old = 0; 1402 unsigned long flags; ··· 1416 1417 local_irq_restore(flags); 1418 1419 - ide_setup_dma(hwif, dmabase, 8); 1420 } 1421 1422 static void __devinit hpt374_init(struct pci_dev *dev, struct pci_dev *dev2)
··· 1 /* 2 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> 3 * Portions Copyright (C) 2001 Sun Microsystems, Inc. 4 * Portions Copyright (C) 2003 Red Hat Inc ··· 626 static u8 hpt3xx_udma_filter(ide_drive_t *drive) 627 { 628 ide_hwif_t *hwif = HWIF(drive); 629 + struct pci_dev *dev = to_pci_dev(hwif->dev); 630 + struct hpt_info *info = pci_get_drvdata(dev); 631 u8 mask = hwif->ultra_mask; 632 633 switch (info->chip_type) { ··· 665 static u8 hpt3xx_mdma_filter(ide_drive_t *drive) 666 { 667 ide_hwif_t *hwif = HWIF(drive); 668 + struct pci_dev *dev = to_pci_dev(hwif->dev); 669 + struct hpt_info *info = pci_get_drvdata(dev); 670 671 switch (info->chip_type) { 672 case HPT372 : ··· 699 700 static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed) 701 { 702 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 703 struct hpt_info *info = pci_get_drvdata(dev); 704 struct hpt_timings *t = info->timings; 705 u8 itr_addr = 0x40 + (drive->dn * 4); ··· 742 static void hpt3xx_maskproc(ide_drive_t *drive, int mask) 743 { 744 ide_hwif_t *hwif = HWIF(drive); 745 + struct pci_dev *dev = to_pci_dev(hwif->dev); 746 struct hpt_info *info = pci_get_drvdata(dev); 747 748 if (drive->quirk_list) { ··· 774 */ 775 static void hpt366_dma_lost_irq(ide_drive_t *drive) 776 { 777 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 778 u8 mcr1 = 0, mcr3 = 0, scr1 = 0; 779 780 pci_read_config_byte(dev, 0x50, &mcr1); ··· 790 static void hpt370_clear_engine(ide_drive_t *drive) 791 { 792 ide_hwif_t *hwif = HWIF(drive); 793 + struct pci_dev *dev = to_pci_dev(hwif->dev); 794 795 + pci_write_config_byte(dev, hwif->select_data, 0x37); 796 udelay(10); 797 } 798 799 static void hpt370_irq_timeout(ide_drive_t *drive) 800 { 801 ide_hwif_t *hwif = HWIF(drive); 802 + struct pci_dev *dev = to_pci_dev(hwif->dev); 803 u16 bfifo = 0; 804 u8 dma_cmd; 805 806 + pci_read_config_word(dev, hwif->select_data + 2, &bfifo); 807 printk(KERN_DEBUG "%s: %d bytes in FIFO\n", drive->name, bfifo & 0x1ff); 808 809 /* get DMA command mode */ ··· 844 static int hpt374_ide_dma_test_irq(ide_drive_t *drive) 845 { 846 ide_hwif_t *hwif = HWIF(drive); 847 + struct pci_dev *dev = to_pci_dev(hwif->dev); 848 u16 bfifo = 0; 849 u8 dma_stat; 850 851 + pci_read_config_word(dev, hwif->select_data + 2, &bfifo); 852 if (bfifo & 0x1FF) { 853 // printk("%s: %d bytes in FIFO\n", drive->name, bfifo); 854 return 0; ··· 867 static int hpt374_ide_dma_end(ide_drive_t *drive) 868 { 869 ide_hwif_t *hwif = HWIF(drive); 870 + struct pci_dev *dev = to_pci_dev(hwif->dev); 871 u8 mcr = 0, mcr_addr = hwif->select_data; 872 u8 bwsr = 0, mask = hwif->channel ? 0x02 : 0x01; 873 ··· 942 static int hpt3xx_busproc(ide_drive_t *drive, int state) 943 { 944 ide_hwif_t *hwif = HWIF(drive); 945 + struct pci_dev *dev = to_pci_dev(hwif->dev); 946 u8 mcr_addr = hwif->select_data + 2; 947 u8 resetmask = hwif->channel ? 0x80 : 0x40; 948 u8 bsr2 = 0; ··· 1278 1279 static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) 1280 { 1281 + struct pci_dev *dev = to_pci_dev(hwif->dev); 1282 struct hpt_info *info = pci_get_drvdata(dev); 1283 int serialize = HPT_SERIALIZE_IO; 1284 u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02; ··· 1393 1394 static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) 1395 { 1396 + struct pci_dev *dev = to_pci_dev(hwif->dev); 1397 u8 masterdma = 0, slavedma = 0; 1398 u8 dma_new = 0, dma_old = 0; 1399 unsigned long flags; ··· 1413 1414 local_irq_restore(flags); 1415 1416 + ide_setup_dma(hwif, dmabase); 1417 } 1418 1419 static void __devinit hpt374_init(struct pci_dev *dev, struct pci_dev *dev2)
+4 -3
drivers/ide/pci/it8213.c
··· 28 static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio) 29 { 30 ide_hwif_t *hwif = HWIF(drive); 31 - struct pci_dev *dev = hwif->pci_dev; 32 int is_slave = drive->dn & 1; 33 int master_port = 0x40; 34 int slave_port = 0x44; ··· 85 static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) 86 { 87 ide_hwif_t *hwif = HWIF(drive); 88 - struct pci_dev *dev = hwif->pci_dev; 89 u8 maslave = 0x40; 90 int a_speed = 3 << (drive->dn * 4); 91 int u_flag = 1 << drive->dn; ··· 152 153 static void __devinit init_hwif_it8213(ide_hwif_t *hwif) 154 { 155 u8 reg42h = 0; 156 157 hwif->set_dma_mode = &it8213_set_dma_mode; ··· 161 if (!hwif->dma_base) 162 return; 163 164 - pci_read_config_byte(hwif->pci_dev, 0x42, &reg42h); 165 166 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 167 hwif->cbl = (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
··· 28 static void it8213_set_pio_mode(ide_drive_t *drive, const u8 pio) 29 { 30 ide_hwif_t *hwif = HWIF(drive); 31 + struct pci_dev *dev = to_pci_dev(hwif->dev); 32 int is_slave = drive->dn & 1; 33 int master_port = 0x40; 34 int slave_port = 0x44; ··· 85 static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed) 86 { 87 ide_hwif_t *hwif = HWIF(drive); 88 + struct pci_dev *dev = to_pci_dev(hwif->dev); 89 u8 maslave = 0x40; 90 int a_speed = 3 << (drive->dn * 4); 91 int u_flag = 1 << drive->dn; ··· 152 153 static void __devinit init_hwif_it8213(ide_hwif_t *hwif) 154 { 155 + struct pci_dev *dev = to_pci_dev(hwif->dev); 156 u8 reg42h = 0; 157 158 hwif->set_dma_mode = &it8213_set_dma_mode; ··· 160 if (!hwif->dma_base) 161 return; 162 163 + pci_read_config_byte(dev, 0x42, &reg42h); 164 165 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 166 hwif->cbl = (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
+28 -22
drivers/ide/pci/it821x.c
··· 1 - 2 /* 3 - * linux/drivers/ide/pci/it821x.c Version 0.16 Jul 3 2007 4 - * 5 * Copyright (C) 2004 Red Hat <alan@redhat.com> 6 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 7 * ··· 110 111 static void it821x_program(ide_drive_t *drive, u16 timing) 112 { 113 - ide_hwif_t *hwif = drive->hwif; 114 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 115 int channel = hwif->channel; 116 u8 conf; ··· 121 conf = timing >> 8; 122 else 123 conf = timing & 0xFF; 124 - pci_write_config_byte(hwif->pci_dev, 0x54 + 4 * channel, conf); 125 } 126 127 /** ··· 136 137 static void it821x_program_udma(ide_drive_t *drive, u16 timing) 138 { 139 - ide_hwif_t *hwif = drive->hwif; 140 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 141 int channel = hwif->channel; 142 int unit = drive->select.b.unit; ··· 148 conf = timing >> 8; 149 else 150 conf = timing & 0xFF; 151 - if(itdev->timing10 == 0) 152 - pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel + unit, conf); 153 else { 154 - pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel, conf); 155 - pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel + 1, conf); 156 } 157 } 158 ··· 168 static void it821x_clock_strategy(ide_drive_t *drive) 169 { 170 ide_hwif_t *hwif = drive->hwif; 171 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 172 173 u8 unit = drive->select.b.unit; ··· 207 itdev->clock_mode = ATA_50; 208 sel = 1; 209 } 210 - pci_read_config_byte(hwif->pci_dev, 0x50, &v); 211 v &= ~(1 << (1 + hwif->channel)); 212 v |= sel << (1 + hwif->channel); 213 - pci_write_config_byte(hwif->pci_dev, 0x50, v); 214 215 /* 216 * Reprogram the UDMA/PIO of the pair drive for the switch ··· 285 286 static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted) 287 { 288 - ide_hwif_t *hwif = drive->hwif; 289 struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif); 290 int unit = drive->select.b.unit; 291 int channel = hwif->channel; ··· 301 itdev->udma[unit] = UDMA_OFF; 302 303 /* UDMA bits off - Revision 0x10 do them in pairs */ 304 - pci_read_config_byte(hwif->pci_dev, 0x50, &conf); 305 - if(itdev->timing10) 306 conf |= channel ? 0x60: 0x18; 307 else 308 conf |= 1 << (3 + 2 * channel + unit); 309 - pci_write_config_byte(hwif->pci_dev, 0x50, conf); 310 311 it821x_clock_strategy(drive); 312 /* FIXME: do we need to program this ? */ ··· 324 325 static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted) 326 { 327 - ide_hwif_t *hwif = drive->hwif; 328 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 329 int unit = drive->select.b.unit; 330 int channel = hwif->channel; ··· 342 itdev->udma[unit] |= 0x8080; /* UDMA 5/6 select on */ 343 344 /* UDMA on. Again revision 0x10 must do the pair */ 345 - pci_read_config_byte(hwif->pci_dev, 0x50, &conf); 346 - if(itdev->timing10) 347 conf &= channel ? 0x9F: 0xE7; 348 else 349 conf &= ~ (1 << (3 + 2 * channel + unit)); 350 - pci_write_config_byte(hwif->pci_dev, 0x50, conf); 351 352 it821x_clock_strategy(drive); 353 it821x_program_udma(drive, itdev->udma[unit]); ··· 525 526 static void __devinit init_hwif_it821x(ide_hwif_t *hwif) 527 { 528 struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL); 529 u8 conf; 530 ··· 538 539 ide_set_hwifdata(hwif, idev); 540 541 - pci_read_config_byte(hwif->pci_dev, 0x50, &conf); 542 if (conf & 1) { 543 idev->smart = 1; 544 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; ··· 561 * this is necessary. 562 */ 563 564 - pci_read_config_byte(hwif->pci_dev, 0x08, &conf); 565 if (conf == 0x10) { 566 idev->timing10 = 1; 567 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
··· 1 /* 2 * Copyright (C) 2004 Red Hat <alan@redhat.com> 3 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 4 * ··· 113 114 static void it821x_program(ide_drive_t *drive, u16 timing) 115 { 116 + ide_hwif_t *hwif = drive->hwif; 117 + struct pci_dev *dev = to_pci_dev(hwif->dev); 118 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 119 int channel = hwif->channel; 120 u8 conf; ··· 123 conf = timing >> 8; 124 else 125 conf = timing & 0xFF; 126 + 127 + pci_write_config_byte(dev, 0x54 + 4 * channel, conf); 128 } 129 130 /** ··· 137 138 static void it821x_program_udma(ide_drive_t *drive, u16 timing) 139 { 140 + ide_hwif_t *hwif = drive->hwif; 141 + struct pci_dev *dev = to_pci_dev(hwif->dev); 142 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 143 int channel = hwif->channel; 144 int unit = drive->select.b.unit; ··· 148 conf = timing >> 8; 149 else 150 conf = timing & 0xFF; 151 + 152 + if (itdev->timing10 == 0) 153 + pci_write_config_byte(dev, 0x56 + 4 * channel + unit, conf); 154 else { 155 + pci_write_config_byte(dev, 0x56 + 4 * channel, conf); 156 + pci_write_config_byte(dev, 0x56 + 4 * channel + 1, conf); 157 } 158 } 159 ··· 167 static void it821x_clock_strategy(ide_drive_t *drive) 168 { 169 ide_hwif_t *hwif = drive->hwif; 170 + struct pci_dev *dev = to_pci_dev(hwif->dev); 171 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 172 173 u8 unit = drive->select.b.unit; ··· 205 itdev->clock_mode = ATA_50; 206 sel = 1; 207 } 208 + 209 + pci_read_config_byte(dev, 0x50, &v); 210 v &= ~(1 << (1 + hwif->channel)); 211 v |= sel << (1 + hwif->channel); 212 + pci_write_config_byte(dev, 0x50, v); 213 214 /* 215 * Reprogram the UDMA/PIO of the pair drive for the switch ··· 282 283 static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted) 284 { 285 + ide_hwif_t *hwif = drive->hwif; 286 + struct pci_dev *dev = to_pci_dev(hwif->dev); 287 struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif); 288 int unit = drive->select.b.unit; 289 int channel = hwif->channel; ··· 297 itdev->udma[unit] = UDMA_OFF; 298 299 /* UDMA bits off - Revision 0x10 do them in pairs */ 300 + pci_read_config_byte(dev, 0x50, &conf); 301 + if (itdev->timing10) 302 conf |= channel ? 0x60: 0x18; 303 else 304 conf |= 1 << (3 + 2 * channel + unit); 305 + pci_write_config_byte(dev, 0x50, conf); 306 307 it821x_clock_strategy(drive); 308 /* FIXME: do we need to program this ? */ ··· 320 321 static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted) 322 { 323 + ide_hwif_t *hwif = drive->hwif; 324 + struct pci_dev *dev = to_pci_dev(hwif->dev); 325 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 326 int unit = drive->select.b.unit; 327 int channel = hwif->channel; ··· 337 itdev->udma[unit] |= 0x8080; /* UDMA 5/6 select on */ 338 339 /* UDMA on. Again revision 0x10 must do the pair */ 340 + pci_read_config_byte(dev, 0x50, &conf); 341 + if (itdev->timing10) 342 conf &= channel ? 0x9F: 0xE7; 343 else 344 conf &= ~ (1 << (3 + 2 * channel + unit)); 345 + pci_write_config_byte(dev, 0x50, conf); 346 347 it821x_clock_strategy(drive); 348 it821x_program_udma(drive, itdev->udma[unit]); ··· 520 521 static void __devinit init_hwif_it821x(ide_hwif_t *hwif) 522 { 523 + struct pci_dev *dev = to_pci_dev(hwif->dev); 524 struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL); 525 u8 conf; 526 ··· 532 533 ide_set_hwifdata(hwif, idev); 534 535 + pci_read_config_byte(dev, 0x50, &conf); 536 if (conf & 1) { 537 idev->smart = 1; 538 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; ··· 555 * this is necessary. 556 */ 557 558 + pci_read_config_byte(dev, 0x08, &conf); 559 if (conf == 0x10) { 560 idev->timing10 = 1; 561 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
+1 -1
drivers/ide/pci/jmicron.c
··· 30 31 static u8 __devinit ata66_jmicron(ide_hwif_t *hwif) 32 { 33 - struct pci_dev *pdev = hwif->pci_dev; 34 35 u32 control; 36 u32 control5;
··· 30 31 static u8 __devinit ata66_jmicron(ide_hwif_t *hwif) 32 { 33 + struct pci_dev *pdev = to_pci_dev(hwif->dev); 34 35 u32 control; 36 u32 control5;
+9 -11
drivers/ide/pci/ns87415.c
··· 1 /* 2 - * linux/drivers/ide/pci/ns87415.c Version 2.00 Sep. 10, 2002 3 - * 4 * Copyright (C) 1997-1998 Mark Lord <mlord@pobox.com> 5 * Copyright (C) 1998 Eddie C. Dost <ecd@skynet.be> 6 * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> ··· 69 70 static void __devinit superio_ide_init_iops (struct hwif_s *hwif) 71 { 72 u32 base, dmabase; 73 - u8 tmp; 74 - struct pci_dev *pdev = hwif->pci_dev; 75 - u8 port = hwif->channel; 76 77 base = pci_resource_start(pdev, port * 2) & ~3; 78 dmabase = pci_resource_start(pdev, 4) & ~3; ··· 90 91 static void __devinit init_iops_ns87415(ide_hwif_t *hwif) 92 { 93 - if (PCI_SLOT(hwif->pci_dev->devfn) == 0xE) { 94 /* Built-in - assume it's under superio. */ 95 superio_ide_init_iops(hwif); 96 - } 97 } 98 #endif 99 ··· 108 static void ns87415_prepare_drive (ide_drive_t *drive, unsigned int use_dma) 109 { 110 ide_hwif_t *hwif = HWIF(drive); 111 unsigned int bit, other, new, *old = (unsigned int *) hwif->select_data; 112 - struct pci_dev *dev = hwif->pci_dev; 113 unsigned long flags; 114 115 local_irq_save(flags); ··· 187 188 static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) 189 { 190 - struct pci_dev *dev = hwif->pci_dev; 191 unsigned int ctrl, using_inta; 192 u8 progif; 193 #ifdef __sparc_v9__ ··· 229 230 #ifdef __sparc_v9__ 231 /* 232 - * XXX: Reset the device, if we don't it will not respond 233 - * to SELECT_DRIVE() properly during first probe_hwif(). 234 */ 235 timeout = 10000; 236 outb(12, hwif->io_ports[IDE_CONTROL_OFFSET]);
··· 1 /* 2 * Copyright (C) 1997-1998 Mark Lord <mlord@pobox.com> 3 * Copyright (C) 1998 Eddie C. Dost <ecd@skynet.be> 4 * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> ··· 71 72 static void __devinit superio_ide_init_iops (struct hwif_s *hwif) 73 { 74 + struct pci_dev *pdev = to_pci_dev(hwif->dev); 75 u32 base, dmabase; 76 + u8 port = hwif->channel, tmp; 77 78 base = pci_resource_start(pdev, port * 2) & ~3; 79 dmabase = pci_resource_start(pdev, 4) & ~3; ··· 93 94 static void __devinit init_iops_ns87415(ide_hwif_t *hwif) 95 { 96 + struct pci_dev *dev = to_pci_dev(hwif->dev); 97 + 98 + if (PCI_SLOT(dev->devfn) == 0xE) 99 /* Built-in - assume it's under superio. */ 100 superio_ide_init_iops(hwif); 101 } 102 #endif 103 ··· 110 static void ns87415_prepare_drive (ide_drive_t *drive, unsigned int use_dma) 111 { 112 ide_hwif_t *hwif = HWIF(drive); 113 + struct pci_dev *dev = to_pci_dev(hwif->dev); 114 unsigned int bit, other, new, *old = (unsigned int *) hwif->select_data; 115 unsigned long flags; 116 117 local_irq_save(flags); ··· 189 190 static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) 191 { 192 + struct pci_dev *dev = to_pci_dev(hwif->dev); 193 unsigned int ctrl, using_inta; 194 u8 progif; 195 #ifdef __sparc_v9__ ··· 231 232 #ifdef __sparc_v9__ 233 /* 234 + * XXX: Reset the device, if we don't it will not respond to 235 + * SELECT_DRIVE() properly during first ide_probe_port(). 236 */ 237 timeout = 10000; 238 outb(12, hwif->io_ports[IDE_CONTROL_OFFSET]);
-2
drivers/ide/pci/opti621.c
··· 1 /* 2 - * linux/drivers/ide/pci/opti621.c Version 0.9 Sep 24, 2007 3 - * 4 * Copyright (C) 1996-1998 Linus Torvalds & authors (see below) 5 */ 6
··· 1 /* 2 * Copyright (C) 1996-1998 Linus Torvalds & authors (see below) 3 */ 4
+4 -2
drivers/ide/pci/pdc202xx_new.c
··· 149 static void pdcnew_set_dma_mode(ide_drive_t *drive, const u8 speed) 150 { 151 ide_hwif_t *hwif = HWIF(drive); 152 u8 adj = (drive->dn & 1) ? 0x08 : 0x00; 153 154 /* ··· 160 * As we set up the PLL to output 133 MHz for UltraDMA/133 capable 161 * chips, we must override the default register settings... 162 */ 163 - if (max_dma_rate(hwif->pci_dev) == 4) { 164 u8 mode = speed & 0x07; 165 166 if (speed >= XFER_UDMA_0) { ··· 187 static void pdcnew_set_pio_mode(ide_drive_t *drive, const u8 pio) 188 { 189 ide_hwif_t *hwif = drive->hwif; 190 u8 adj = (drive->dn & 1) ? 0x08 : 0x00; 191 192 - if (max_dma_rate(hwif->pci_dev) == 4) { 193 set_indexed_reg(hwif, 0x0c + adj, pio_timings[pio].reg0c); 194 set_indexed_reg(hwif, 0x0d + adj, pio_timings[pio].reg0d); 195 set_indexed_reg(hwif, 0x13 + adj, pio_timings[pio].reg13);
··· 149 static void pdcnew_set_dma_mode(ide_drive_t *drive, const u8 speed) 150 { 151 ide_hwif_t *hwif = HWIF(drive); 152 + struct pci_dev *dev = to_pci_dev(hwif->dev); 153 u8 adj = (drive->dn & 1) ? 0x08 : 0x00; 154 155 /* ··· 159 * As we set up the PLL to output 133 MHz for UltraDMA/133 capable 160 * chips, we must override the default register settings... 161 */ 162 + if (max_dma_rate(dev) == 4) { 163 u8 mode = speed & 0x07; 164 165 if (speed >= XFER_UDMA_0) { ··· 186 static void pdcnew_set_pio_mode(ide_drive_t *drive, const u8 pio) 187 { 188 ide_hwif_t *hwif = drive->hwif; 189 + struct pci_dev *dev = to_pci_dev(hwif->dev); 190 u8 adj = (drive->dn & 1) ? 0x08 : 0x00; 191 192 + if (max_dma_rate(dev) == 4) { 193 set_indexed_reg(hwif, 0x0c + adj, pio_timings[pio].reg0c); 194 set_indexed_reg(hwif, 0x0d + adj, pio_timings[pio].reg0d); 195 set_indexed_reg(hwif, 0x13 + adj, pio_timings[pio].reg13);
+9 -8
drivers/ide/pci/pdc202xx_old.c
··· 1 /* 2 - * linux/drivers/ide/pci/pdc202xx_old.c Version 0.52 Aug 27, 2007 3 - * 4 * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org> 5 * Copyright (C) 2006-2007 MontaVista Software, Inc. 6 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz ··· 64 static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed) 65 { 66 ide_hwif_t *hwif = HWIF(drive); 67 - struct pci_dev *dev = hwif->pci_dev; 68 u8 drive_pci = 0x60 + (drive->dn << 2); 69 70 u8 AP = 0, BP = 0, CP = 0; ··· 142 143 static u8 pdc202xx_old_cable_detect (ide_hwif_t *hwif) 144 { 145 u16 CIS = 0, mask = (hwif->channel) ? (1<<11) : (1<<10); 146 147 - pci_read_config_word(hwif->pci_dev, 0x50, &CIS); 148 149 return (CIS & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 150 } ··· 304 305 static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif) 306 { 307 hwif->set_pio_mode = &pdc202xx_set_pio_mode; 308 hwif->set_dma_mode = &pdc202xx_set_mode; 309 310 hwif->quirkproc = &pdc202xx_quirkproc; 311 312 - if (hwif->pci_dev->device != PCI_DEVICE_ID_PROMISE_20246) 313 hwif->resetproc = &pdc202xx_reset; 314 315 if (hwif->dma_base == 0) ··· 320 hwif->dma_lost_irq = &pdc202xx_dma_lost_irq; 321 hwif->dma_timeout = &pdc202xx_dma_timeout; 322 323 - if (hwif->pci_dev->device != PCI_DEVICE_ID_PROMISE_20246) { 324 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 325 hwif->cbl = pdc202xx_old_cable_detect(hwif); 326 ··· 335 u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; 336 337 if (hwif->channel) { 338 - ide_setup_dma(hwif, dmabase, 8); 339 return; 340 } 341 ··· 359 } 360 #endif /* CONFIG_PDC202XX_BURST */ 361 362 - ide_setup_dma(hwif, dmabase, 8); 363 } 364 365 static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev,
··· 1 /* 2 * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org> 3 * Copyright (C) 2006-2007 MontaVista Software, Inc. 4 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz ··· 66 static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed) 67 { 68 ide_hwif_t *hwif = HWIF(drive); 69 + struct pci_dev *dev = to_pci_dev(hwif->dev); 70 u8 drive_pci = 0x60 + (drive->dn << 2); 71 72 u8 AP = 0, BP = 0, CP = 0; ··· 144 145 static u8 pdc202xx_old_cable_detect (ide_hwif_t *hwif) 146 { 147 + struct pci_dev *dev = to_pci_dev(hwif->dev); 148 u16 CIS = 0, mask = (hwif->channel) ? (1<<11) : (1<<10); 149 150 + pci_read_config_word(dev, 0x50, &CIS); 151 152 return (CIS & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 153 } ··· 305 306 static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif) 307 { 308 + struct pci_dev *dev = to_pci_dev(hwif->dev); 309 + 310 hwif->set_pio_mode = &pdc202xx_set_pio_mode; 311 hwif->set_dma_mode = &pdc202xx_set_mode; 312 313 hwif->quirkproc = &pdc202xx_quirkproc; 314 315 + if (dev->device != PCI_DEVICE_ID_PROMISE_20246) 316 hwif->resetproc = &pdc202xx_reset; 317 318 if (hwif->dma_base == 0) ··· 319 hwif->dma_lost_irq = &pdc202xx_dma_lost_irq; 320 hwif->dma_timeout = &pdc202xx_dma_timeout; 321 322 + if (dev->device != PCI_DEVICE_ID_PROMISE_20246) { 323 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 324 hwif->cbl = pdc202xx_old_cable_detect(hwif); 325 ··· 334 u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; 335 336 if (hwif->channel) { 337 + ide_setup_dma(hwif, dmabase); 338 return; 339 } 340 ··· 358 } 359 #endif /* CONFIG_PDC202XX_BURST */ 360 361 + ide_setup_dma(hwif, dmabase); 362 } 363 364 static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev,
+4 -51
drivers/ide/pci/piix.c
··· 1 /* 2 - * linux/drivers/ide/pci/piix.c Version 0.54 Sep 5, 2007 3 - * 4 * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer 5 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> 6 * Copyright (C) 2003 Red Hat Inc <alan@redhat.com> ··· 6 * 7 * May be copied or modified under the terms of the GNU General Public License 8 * 9 - * PIO mode setting function for Intel chipsets. 10 - * For use instead of BIOS settings. 11 * 12 - * 40-41 13 - * 42-43 14 - * 15 - * 41 16 - * 43 17 - * 18 - * | PIO 0 | c0 | 80 | 0 | 19 - * | PIO 2 | SW2 | d0 | 90 | 4 | 20 - * | PIO 3 | MW1 | e1 | a1 | 9 | 21 - * | PIO 4 | MW2 | e3 | a3 | b | 22 - * 23 - * sitre = word40 & 0x4000; primary 24 - * sitre = word42 & 0x4000; secondary 25 - * 26 - * 44 8421|8421 hdd|hdb 27 - * 28 - * 48 8421 hdd|hdc|hdb|hda udma enabled 29 - * 30 - * 0001 hda 31 - * 0010 hdb 32 - * 0100 hdc 33 - * 1000 hdd 34 - * 35 - * 4a 84|21 hdb|hda 36 - * 4b 84|21 hdd|hdc 37 - * 38 - * ata-33/82371AB 39 - * ata-33/82371EB 40 - * ata-33/82801AB ata-66/82801AA 41 - * 00|00 udma 0 00|00 reserved 42 - * 01|01 udma 1 01|01 udma 3 43 - * 10|10 udma 2 10|10 udma 4 44 - * 11|11 reserved 11|11 reserved 45 - * 46 - * 54 8421|8421 ata66 drive|ata66 enable 47 - * 48 - * pci_read_config_word(HWIF(drive)->pci_dev, 0x40, &reg40); 49 - * pci_read_config_word(HWIF(drive)->pci_dev, 0x42, &reg42); 50 - * pci_read_config_word(HWIF(drive)->pci_dev, 0x44, &reg44); 51 - * pci_read_config_byte(HWIF(drive)->pci_dev, 0x48, &reg48); 52 - * pci_read_config_word(HWIF(drive)->pci_dev, 0x4a, &reg4a); 53 - * pci_read_config_byte(HWIF(drive)->pci_dev, 0x54, &reg54); 54 - * 55 - * Documentation 56 * Publically available from Intel web site. Errata documentation 57 * is also publically available. As an aide to anyone hacking on this 58 * driver the list of errata that are relevant is below.going back to ··· 69 static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio) 70 { 71 ide_hwif_t *hwif = HWIF(drive); 72 - struct pci_dev *dev = hwif->pci_dev; 73 int is_slave = drive->dn & 1; 74 int master_port = hwif->channel ? 0x42 : 0x40; 75 int slave_port = 0x44; ··· 138 static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) 139 { 140 ide_hwif_t *hwif = HWIF(drive); 141 - struct pci_dev *dev = hwif->pci_dev; 142 u8 maslave = hwif->channel ? 0x42 : 0x40; 143 int a_speed = 3 << (drive->dn * 4); 144 int u_flag = 1 << drive->dn; ··· 258 259 static u8 __devinit piix_cable_detect(ide_hwif_t *hwif) 260 { 261 - struct pci_dev *pdev = hwif->pci_dev; 262 const struct ich_laptop *lap = &ich_laptop[0]; 263 u8 reg54h = 0, mask = hwif->channel ? 0xc0 : 0x30; 264
··· 1 /* 2 * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer 3 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 2003 Red Hat Inc <alan@redhat.com> ··· 8 * 9 * May be copied or modified under the terms of the GNU General Public License 10 * 11 + * Documentation: 12 * 13 * Publically available from Intel web site. Errata documentation 14 * is also publically available. As an aide to anyone hacking on this 15 * driver the list of errata that are relevant is below.going back to ··· 116 static void piix_set_pio_mode(ide_drive_t *drive, const u8 pio) 117 { 118 ide_hwif_t *hwif = HWIF(drive); 119 + struct pci_dev *dev = to_pci_dev(hwif->dev); 120 int is_slave = drive->dn & 1; 121 int master_port = hwif->channel ? 0x42 : 0x40; 122 int slave_port = 0x44; ··· 185 static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) 186 { 187 ide_hwif_t *hwif = HWIF(drive); 188 + struct pci_dev *dev = to_pci_dev(hwif->dev); 189 u8 maslave = hwif->channel ? 0x42 : 0x40; 190 int a_speed = 3 << (drive->dn * 4); 191 int u_flag = 1 << drive->dn; ··· 305 306 static u8 __devinit piix_cable_detect(ide_hwif_t *hwif) 307 { 308 + struct pci_dev *pdev = to_pci_dev(hwif->dev); 309 const struct ich_laptop *lap = &ich_laptop[0]; 310 u8 reg54h = 0, mask = hwif->channel ? 0xc0 : 0x30; 311
+1 -3
drivers/ide/pci/rz1000.c
··· 1 /* 2 - * linux/drivers/ide/pci/rz1000.c Version 0.06 January 12, 2003 3 - * 4 * Copyright (C) 1995-1998 Linus Torvalds & author (see below) 5 */ 6 ··· 30 31 static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif) 32 { 33 u16 reg; 34 - struct pci_dev *dev = hwif->pci_dev; 35 36 if (!pci_read_config_word (dev, 0x40, &reg) && 37 !pci_write_config_word(dev, 0x40, reg & 0xdfff)) {
··· 1 /* 2 * Copyright (C) 1995-1998 Linus Torvalds & author (see below) 3 */ 4 ··· 32 33 static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif) 34 { 35 + struct pci_dev *dev = to_pci_dev(hwif->dev); 36 u16 reg; 37 38 if (!pci_read_config_word (dev, 0x40, &reg) && 39 !pci_write_config_word(dev, 0x40, reg & 0xdfff)) {
+6 -8
drivers/ide/pci/sc1200.c
··· 1 /* 2 - * linux/drivers/ide/pci/sc1200.c Version 0.97 Aug 3 2007 3 - * 4 * Copyright (C) 2000-2002 Mark Lord <mlord@pobox.com> 5 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 6 * ··· 85 static void sc1200_tunepio(ide_drive_t *drive, u8 pio) 86 { 87 ide_hwif_t *hwif = drive->hwif; 88 - struct pci_dev *pdev = hwif->pci_dev; 89 unsigned int basereg = hwif->channel ? 0x50 : 0x40, format = 0; 90 91 pci_read_config_dword(pdev, basereg + 4, &format); ··· 128 static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode) 129 { 130 ide_hwif_t *hwif = HWIF(drive); 131 int unit = drive->select.b.unit; 132 unsigned int reg, timings; 133 unsigned short pci_clock; ··· 159 timings = mwdma_timing[pci_clock][mode - XFER_MW_DMA_0]; 160 161 if (unit == 0) { /* are we configuring drive0? */ 162 - pci_read_config_dword(hwif->pci_dev, basereg+4, &reg); 163 timings |= reg & 0x80000000; /* preserve PIO format bit */ 164 - pci_write_config_dword(hwif->pci_dev, basereg+4, timings); 165 - } else { 166 - pci_write_config_dword(hwif->pci_dev, basereg+12, timings); 167 - } 168 } 169 170 /* Replacement for the standard ide_dma_end action in
··· 1 /* 2 * Copyright (C) 2000-2002 Mark Lord <mlord@pobox.com> 3 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 4 * ··· 87 static void sc1200_tunepio(ide_drive_t *drive, u8 pio) 88 { 89 ide_hwif_t *hwif = drive->hwif; 90 + struct pci_dev *pdev = to_pci_dev(hwif->dev); 91 unsigned int basereg = hwif->channel ? 0x50 : 0x40, format = 0; 92 93 pci_read_config_dword(pdev, basereg + 4, &format); ··· 130 static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode) 131 { 132 ide_hwif_t *hwif = HWIF(drive); 133 + struct pci_dev *dev = to_pci_dev(hwif->dev); 134 int unit = drive->select.b.unit; 135 unsigned int reg, timings; 136 unsigned short pci_clock; ··· 160 timings = mwdma_timing[pci_clock][mode - XFER_MW_DMA_0]; 161 162 if (unit == 0) { /* are we configuring drive0? */ 163 + pci_read_config_dword(dev, basereg + 4, &reg); 164 timings |= reg & 0x80000000; /* preserve PIO format bit */ 165 + pci_write_config_dword(dev, basereg + 4, timings); 166 + } else 167 + pci_write_config_dword(dev, basereg + 12, timings); 168 } 169 170 /* Replacement for the standard ide_dma_end action in
+6 -7
drivers/ide/pci/scc_pata.c
··· 594 595 static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif) 596 { 597 - struct pci_dev *dev = hwif->pci_dev; 598 struct scc_ports *ports = pci_get_drvdata(dev); 599 unsigned long dma_base = ports->dma; 600 ··· 620 hwif->io_ports[IDE_STATUS_OFFSET] = dma_base + 0x3c; 621 hwif->io_ports[IDE_CONTROL_OFFSET] = dma_base + 0x40; 622 623 - hwif->irq = hwif->pci_dev->irq; 624 hwif->dma_base = dma_base; 625 hwif->config_data = ports->ctl; 626 hwif->mmio = 1; ··· 636 637 static void __devinit init_iops_scc(ide_hwif_t *hwif) 638 { 639 - struct pci_dev *dev = hwif->pci_dev; 640 hwif->hwif_data = NULL; 641 if (pci_get_drvdata(dev) == NULL) 642 return; ··· 727 unsigned long dma_size = pci_resource_len(dev, 1); 728 729 if (hwif->dmatable_cpu) { 730 - pci_free_consistent(hwif->pci_dev, 731 - PRD_ENTRIES * PRD_BYTES, 732 - hwif->dmatable_cpu, 733 - hwif->dmatable_dma); 734 hwif->dmatable_cpu = NULL; 735 } 736
··· 594 595 static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif) 596 { 597 + struct pci_dev *dev = to_pci_dev(hwif->dev); 598 struct scc_ports *ports = pci_get_drvdata(dev); 599 unsigned long dma_base = ports->dma; 600 ··· 620 hwif->io_ports[IDE_STATUS_OFFSET] = dma_base + 0x3c; 621 hwif->io_ports[IDE_CONTROL_OFFSET] = dma_base + 0x40; 622 623 + hwif->irq = dev->irq; 624 hwif->dma_base = dma_base; 625 hwif->config_data = ports->ctl; 626 hwif->mmio = 1; ··· 636 637 static void __devinit init_iops_scc(ide_hwif_t *hwif) 638 { 639 + struct pci_dev *dev = to_pci_dev(hwif->dev); 640 + 641 hwif->hwif_data = NULL; 642 if (pci_get_drvdata(dev) == NULL) 643 return; ··· 726 unsigned long dma_size = pci_resource_len(dev, 1); 727 728 if (hwif->dmatable_cpu) { 729 + pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES, 730 + hwif->dmatable_cpu, hwif->dmatable_dma); 731 hwif->dmatable_cpu = NULL; 732 } 733
+14 -10
drivers/ide/pci/serverworks.c
··· 1 /* 2 - * linux/drivers/ide/pci/serverworks.c Version 0.22 Jun 27 2007 3 - * 4 * Copyright (C) 1998-2000 Michel Aubry 5 * Copyright (C) 1998-2000 Andrzej Krzysztofowicz 6 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> ··· 65 66 static u8 svwks_udma_filter(ide_drive_t *drive) 67 { 68 - struct pci_dev *dev = HWIF(drive)->pci_dev; 69 u8 mask = 0; 70 71 if (dev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) ··· 128 static const u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 }; 129 static const u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 }; 130 131 - struct pci_dev *dev = drive->hwif->pci_dev; 132 133 pci_write_config_byte(dev, drive_pci[drive->dn], pio_modes[pio]); 134 ··· 151 static const u8 drive_pci2[] = { 0x45, 0x44, 0x47, 0x46 }; 152 153 ide_hwif_t *hwif = HWIF(drive); 154 - struct pci_dev *dev = hwif->pci_dev; 155 u8 unit = (drive->select.b.unit & 0x01); 156 157 u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0; ··· 285 */ 286 static u8 __devinit ata66_svwks_dell(ide_hwif_t *hwif) 287 { 288 - struct pci_dev *dev = hwif->pci_dev; 289 if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL && 290 dev->vendor == PCI_VENDOR_ID_SERVERWORKS && 291 (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE || ··· 304 */ 305 static u8 __devinit ata66_svwks_cobalt(ide_hwif_t *hwif) 306 { 307 - struct pci_dev *dev = hwif->pci_dev; 308 if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN && 309 dev->vendor == PCI_VENDOR_ID_SERVERWORKS && 310 dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ··· 316 317 static u8 __devinit ata66_svwks(ide_hwif_t *hwif) 318 { 319 - struct pci_dev *dev = hwif->pci_dev; 320 321 /* Server Works */ 322 if (dev->subsystem_vendor == PCI_VENDOR_ID_SERVERWORKS) ··· 340 341 static void __devinit init_hwif_svwks (ide_hwif_t *hwif) 342 { 343 hwif->set_pio_mode = &svwks_set_pio_mode; 344 hwif->set_dma_mode = &svwks_set_dma_mode; 345 hwif->udma_filter = &svwks_udma_filter; ··· 349 if (!hwif->dma_base) 350 return; 351 352 - if (hwif->pci_dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { 353 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 354 hwif->cbl = ata66_svwks(hwif); 355 } ··· 420 421 d = serverworks_chipsets[idx]; 422 423 - if (idx == 2 || idx == 3) { 424 if ((PCI_FUNC(dev->devfn) & 1) == 0) { 425 if (pci_resource_start(dev, 0) != 0x01f1) 426 d.host_flags &= ~IDE_HFLAG_BOOTABLE;
··· 1 /* 2 * Copyright (C) 1998-2000 Michel Aubry 3 * Copyright (C) 1998-2000 Andrzej Krzysztofowicz 4 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> ··· 67 68 static u8 svwks_udma_filter(ide_drive_t *drive) 69 { 70 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 71 u8 mask = 0; 72 73 if (dev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) ··· 130 static const u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 }; 131 static const u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 }; 132 133 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 134 135 pci_write_config_byte(dev, drive_pci[drive->dn], pio_modes[pio]); 136 ··· 153 static const u8 drive_pci2[] = { 0x45, 0x44, 0x47, 0x46 }; 154 155 ide_hwif_t *hwif = HWIF(drive); 156 + struct pci_dev *dev = to_pci_dev(hwif->dev); 157 u8 unit = (drive->select.b.unit & 0x01); 158 159 u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0; ··· 287 */ 288 static u8 __devinit ata66_svwks_dell(ide_hwif_t *hwif) 289 { 290 + struct pci_dev *dev = to_pci_dev(hwif->dev); 291 + 292 if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL && 293 dev->vendor == PCI_VENDOR_ID_SERVERWORKS && 294 (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE || ··· 305 */ 306 static u8 __devinit ata66_svwks_cobalt(ide_hwif_t *hwif) 307 { 308 + struct pci_dev *dev = to_pci_dev(hwif->dev); 309 + 310 if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN && 311 dev->vendor == PCI_VENDOR_ID_SERVERWORKS && 312 dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ··· 316 317 static u8 __devinit ata66_svwks(ide_hwif_t *hwif) 318 { 319 + struct pci_dev *dev = to_pci_dev(hwif->dev); 320 321 /* Server Works */ 322 if (dev->subsystem_vendor == PCI_VENDOR_ID_SERVERWORKS) ··· 340 341 static void __devinit init_hwif_svwks (ide_hwif_t *hwif) 342 { 343 + struct pci_dev *dev = to_pci_dev(hwif->dev); 344 + 345 hwif->set_pio_mode = &svwks_set_pio_mode; 346 hwif->set_dma_mode = &svwks_set_dma_mode; 347 hwif->udma_filter = &svwks_udma_filter; ··· 347 if (!hwif->dma_base) 348 return; 349 350 + if (dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { 351 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 352 hwif->cbl = ata66_svwks(hwif); 353 } ··· 418 419 d = serverworks_chipsets[idx]; 420 421 + if (idx == 1) 422 + d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; 423 + else if (idx == 2 || idx == 3) { 424 if ((PCI_FUNC(dev->devfn) & 1) == 0) { 425 if (pci_resource_start(dev, 0) != 0x01f1) 426 d.host_flags &= ~IDE_HFLAG_BOOTABLE;
+9 -10
drivers/ide/pci/sgiioc4.c
··· 159 } 160 161 if (intr_reg & 0x02) { 162 /* Error when transferring DMA data on PCI bus */ 163 u32 pci_err_addr_low, pci_err_addr_high, 164 pci_stat_cmd_reg; ··· 168 readl((void __iomem *)hwif->io_ports[IDE_IRQ_OFFSET]); 169 pci_err_addr_high = 170 readl((void __iomem *)(hwif->io_ports[IDE_IRQ_OFFSET] + 4)); 171 - pci_read_config_dword(hwif->pci_dev, PCI_COMMAND, 172 &pci_stat_cmd_reg); 173 printk(KERN_ERR 174 "%s(%s) : PCI Bus Error when doing DMA:" ··· 179 __FUNCTION__, drive->name, 180 pci_err_addr_high, pci_err_addr_low); 181 /* Clear the PCI Error indicator */ 182 - pci_write_config_dword(hwif->pci_dev, PCI_COMMAND, 183 - 0x00000146); 184 } 185 186 /* Clear the Interrupt, Error bits on the IOC4 */ ··· 334 static int __devinit 335 ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) 336 { 337 void __iomem *virt_dma_base; 338 int num_ports = sizeof (ioc4_dma_regs_t); 339 void *pad; ··· 360 } 361 hwif->dma_base = (unsigned long) virt_dma_base; 362 363 - hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev, 364 IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, 365 &hwif->dmatable_dma); 366 ··· 369 370 hwif->sg_max_nents = IOC4_PRD_ENTRIES; 371 372 - pad = pci_alloc_consistent(hwif->pci_dev, IOC4_IDE_CACHELINE_SIZE, 373 (dma_addr_t *) &(hwif->dma_status)); 374 375 if (pad) { ··· 377 return 0; 378 } 379 380 - pci_free_consistent(hwif->pci_dev, 381 - IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, 382 hwif->dmatable_cpu, hwif->dmatable_dma); 383 printk(KERN_INFO 384 "%s() -- Error! Unable to allocate DMA Maps for drive %s\n", ··· 517 } 518 519 use_pio_instead: 520 - pci_unmap_sg(hwif->pci_dev, hwif->sg_table, hwif->sg_nents, 521 - hwif->sg_dma_direction); 522 523 return 0; /* revert to PIO for this request */ 524 } ··· 640 hw.dev = &dev->dev; 641 ide_init_port_hw(hwif, &hw); 642 643 - hwif->pci_dev = dev; 644 hwif->channel = 0; /* Single Channel chip */ 645 646 /* The IOC4 uses MMIO rather than Port IO. */
··· 159 } 160 161 if (intr_reg & 0x02) { 162 + struct pci_dev *dev = to_pci_dev(hwif->dev); 163 /* Error when transferring DMA data on PCI bus */ 164 u32 pci_err_addr_low, pci_err_addr_high, 165 pci_stat_cmd_reg; ··· 167 readl((void __iomem *)hwif->io_ports[IDE_IRQ_OFFSET]); 168 pci_err_addr_high = 169 readl((void __iomem *)(hwif->io_ports[IDE_IRQ_OFFSET] + 4)); 170 + pci_read_config_dword(dev, PCI_COMMAND, 171 &pci_stat_cmd_reg); 172 printk(KERN_ERR 173 "%s(%s) : PCI Bus Error when doing DMA:" ··· 178 __FUNCTION__, drive->name, 179 pci_err_addr_high, pci_err_addr_low); 180 /* Clear the PCI Error indicator */ 181 + pci_write_config_dword(dev, PCI_COMMAND, 0x00000146); 182 } 183 184 /* Clear the Interrupt, Error bits on the IOC4 */ ··· 334 static int __devinit 335 ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) 336 { 337 + struct pci_dev *dev = to_pci_dev(hwif->dev); 338 void __iomem *virt_dma_base; 339 int num_ports = sizeof (ioc4_dma_regs_t); 340 void *pad; ··· 359 } 360 hwif->dma_base = (unsigned long) virt_dma_base; 361 362 + hwif->dmatable_cpu = pci_alloc_consistent(dev, 363 IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, 364 &hwif->dmatable_dma); 365 ··· 368 369 hwif->sg_max_nents = IOC4_PRD_ENTRIES; 370 371 + pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE, 372 (dma_addr_t *) &(hwif->dma_status)); 373 374 if (pad) { ··· 376 return 0; 377 } 378 379 + pci_free_consistent(dev, IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, 380 hwif->dmatable_cpu, hwif->dmatable_dma); 381 printk(KERN_INFO 382 "%s() -- Error! Unable to allocate DMA Maps for drive %s\n", ··· 517 } 518 519 use_pio_instead: 520 + ide_destroy_dmatable(drive); 521 522 return 0; /* revert to PIO for this request */ 523 } ··· 641 hw.dev = &dev->dev; 642 ide_init_port_hw(hwif, &hw); 643 644 + hwif->dev = &dev->dev; 645 hwif->channel = 0; /* Single Channel chip */ 646 647 /* The IOC4 uses MMIO rather than Port IO. */
+30 -23
drivers/ide/pci/siimage.c
··· 1 /* 2 - * linux/drivers/ide/pci/siimage.c Version 1.19 Nov 16 2007 3 - * 4 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> 5 * Copyright (C) 2003 Red Hat <alan@redhat.com> 6 * Copyright (C) 2007 MontaVista Software, Inc. ··· 77 78 static inline int is_sata(ide_hwif_t *hwif) 79 { 80 - return pdev_is_sata(hwif->pci_dev); 81 } 82 83 /** ··· 138 static u8 sil_pata_udma_filter(ide_drive_t *drive) 139 { 140 ide_hwif_t *hwif = drive->hwif; 141 unsigned long base = (unsigned long) hwif->hwif_data; 142 u8 mask = 0, scsc = 0; 143 144 if (hwif->mmio) 145 scsc = hwif->INB(base + 0x4A); 146 else 147 - pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc); 148 149 if ((scsc & 0x30) == 0x10) /* 133 */ 150 mask = ATA_UDMA6; ··· 218 mode |= (unit ? 0x10 : 0x01); 219 hwif->OUTB(mode, base + addr_mask); 220 } else { 221 - pci_write_config_word(hwif->pci_dev, addr, speedp); 222 - pci_write_config_word(hwif->pci_dev, tfaddr, speedt); 223 - pci_read_config_word(hwif->pci_dev, tfaddr-2, &speedp); 224 speedp &= ~0x200; 225 /* Set IORDY for mode 3 or 4 */ 226 if (pio > 2) 227 speedp |= 0x200; 228 - pci_write_config_word(hwif->pci_dev, tfaddr-2, speedp); 229 230 - pci_read_config_byte(hwif->pci_dev, addr_mask, &mode); 231 mode &= ~(unit ? 0x30 : 0x03); 232 mode |= (unit ? 0x10 : 0x01); 233 - pci_write_config_byte(hwif->pci_dev, addr_mask, mode); 234 } 235 } 236 ··· 251 u16 dma[] = { 0x2208, 0x10C2, 0x10C1 }; 252 253 ide_hwif_t *hwif = HWIF(drive); 254 u16 ultra = 0, multi = 0; 255 u8 mode = 0, unit = drive->select.b.unit; 256 unsigned long base = (unsigned long)hwif->hwif_data; ··· 268 multi = hwif->INW(ma); 269 ultra = hwif->INW(ua); 270 } else { 271 - pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc); 272 - pci_read_config_byte(hwif->pci_dev, addr_mask, &mode); 273 - pci_read_config_word(hwif->pci_dev, ma, &multi); 274 - pci_read_config_word(hwif->pci_dev, ua, &ultra); 275 } 276 277 mode &= ~((unit) ? 0x30 : 0x03); ··· 295 hwif->OUTW(multi, ma); 296 hwif->OUTW(ultra, ua); 297 } else { 298 - pci_write_config_byte(hwif->pci_dev, addr_mask, mode); 299 - pci_write_config_word(hwif->pci_dev, ma, multi); 300 - pci_write_config_word(hwif->pci_dev, ua, ultra); 301 } 302 } 303 ··· 305 static int siimage_io_ide_dma_test_irq (ide_drive_t *drive) 306 { 307 ide_hwif_t *hwif = HWIF(drive); 308 u8 dma_altstat = 0; 309 unsigned long addr = siimage_selreg(hwif, 1); 310 ··· 314 return 1; 315 316 /* return 1 if Device INTR asserted */ 317 - pci_read_config_byte(hwif->pci_dev, addr, &dma_altstat); 318 if (dma_altstat & 8) 319 return 0; //return 1; 320 return 0; ··· 380 static int sil_sata_busproc(ide_drive_t * drive, int state) 381 { 382 ide_hwif_t *hwif = HWIF(drive); 383 u32 stat_config = 0; 384 unsigned long addr = siimage_selreg(hwif, 0); 385 386 if (hwif->mmio) 387 stat_config = readl((void __iomem *)addr); 388 else 389 - pci_read_config_dword(hwif->pci_dev, addr, &stat_config); 390 391 switch (state) { 392 case BUSSTATE_ON: ··· 647 648 static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) 649 { 650 - struct pci_dev *dev = hwif->pci_dev; 651 void *addr = pci_get_drvdata(dev); 652 u8 ch = hwif->channel; 653 hw_regs_t hw; ··· 760 761 static void __devinit init_iops_siimage(ide_hwif_t *hwif) 762 { 763 hwif->hwif_data = NULL; 764 765 /* Pessimal until we finish probing */ 766 hwif->rqsize = 15; 767 768 - if (pci_get_drvdata(hwif->pci_dev) == NULL) 769 return; 770 771 init_mmio_iops_siimage(hwif); ··· 783 784 static u8 __devinit ata66_siimage(ide_hwif_t *hwif) 785 { 786 unsigned long addr = siimage_selreg(hwif, 0); 787 u8 ata66 = 0; 788 789 - if (pci_get_drvdata(hwif->pci_dev) == NULL) 790 - pci_read_config_byte(hwif->pci_dev, addr, &ata66); 791 else 792 ata66 = hwif->INB(addr); 793
··· 1 /* 2 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> 3 * Copyright (C) 2003 Red Hat <alan@redhat.com> 4 * Copyright (C) 2007 MontaVista Software, Inc. ··· 79 80 static inline int is_sata(ide_hwif_t *hwif) 81 { 82 + return pdev_is_sata(to_pci_dev(hwif->dev)); 83 } 84 85 /** ··· 140 static u8 sil_pata_udma_filter(ide_drive_t *drive) 141 { 142 ide_hwif_t *hwif = drive->hwif; 143 + struct pci_dev *dev = to_pci_dev(hwif->dev); 144 unsigned long base = (unsigned long) hwif->hwif_data; 145 u8 mask = 0, scsc = 0; 146 147 if (hwif->mmio) 148 scsc = hwif->INB(base + 0x4A); 149 else 150 + pci_read_config_byte(dev, 0x8A, &scsc); 151 152 if ((scsc & 0x30) == 0x10) /* 133 */ 153 mask = ATA_UDMA6; ··· 219 mode |= (unit ? 0x10 : 0x01); 220 hwif->OUTB(mode, base + addr_mask); 221 } else { 222 + struct pci_dev *dev = to_pci_dev(hwif->dev); 223 + 224 + pci_write_config_word(dev, addr, speedp); 225 + pci_write_config_word(dev, tfaddr, speedt); 226 + pci_read_config_word(dev, tfaddr - 2, &speedp); 227 speedp &= ~0x200; 228 /* Set IORDY for mode 3 or 4 */ 229 if (pio > 2) 230 speedp |= 0x200; 231 + pci_write_config_word(dev, tfaddr - 2, speedp); 232 233 + pci_read_config_byte(dev, addr_mask, &mode); 234 mode &= ~(unit ? 0x30 : 0x03); 235 mode |= (unit ? 0x10 : 0x01); 236 + pci_write_config_byte(dev, addr_mask, mode); 237 } 238 } 239 ··· 250 u16 dma[] = { 0x2208, 0x10C2, 0x10C1 }; 251 252 ide_hwif_t *hwif = HWIF(drive); 253 + struct pci_dev *dev = to_pci_dev(hwif->dev); 254 u16 ultra = 0, multi = 0; 255 u8 mode = 0, unit = drive->select.b.unit; 256 unsigned long base = (unsigned long)hwif->hwif_data; ··· 266 multi = hwif->INW(ma); 267 ultra = hwif->INW(ua); 268 } else { 269 + pci_read_config_byte(dev, 0x8A, &scsc); 270 + pci_read_config_byte(dev, addr_mask, &mode); 271 + pci_read_config_word(dev, ma, &multi); 272 + pci_read_config_word(dev, ua, &ultra); 273 } 274 275 mode &= ~((unit) ? 0x30 : 0x03); ··· 293 hwif->OUTW(multi, ma); 294 hwif->OUTW(ultra, ua); 295 } else { 296 + pci_write_config_byte(dev, addr_mask, mode); 297 + pci_write_config_word(dev, ma, multi); 298 + pci_write_config_word(dev, ua, ultra); 299 } 300 } 301 ··· 303 static int siimage_io_ide_dma_test_irq (ide_drive_t *drive) 304 { 305 ide_hwif_t *hwif = HWIF(drive); 306 + struct pci_dev *dev = to_pci_dev(hwif->dev); 307 u8 dma_altstat = 0; 308 unsigned long addr = siimage_selreg(hwif, 1); 309 ··· 311 return 1; 312 313 /* return 1 if Device INTR asserted */ 314 + pci_read_config_byte(dev, addr, &dma_altstat); 315 if (dma_altstat & 8) 316 return 0; //return 1; 317 return 0; ··· 377 static int sil_sata_busproc(ide_drive_t * drive, int state) 378 { 379 ide_hwif_t *hwif = HWIF(drive); 380 + struct pci_dev *dev = to_pci_dev(hwif->dev); 381 u32 stat_config = 0; 382 unsigned long addr = siimage_selreg(hwif, 0); 383 384 if (hwif->mmio) 385 stat_config = readl((void __iomem *)addr); 386 else 387 + pci_read_config_dword(dev, addr, &stat_config); 388 389 switch (state) { 390 case BUSSTATE_ON: ··· 643 644 static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) 645 { 646 + struct pci_dev *dev = to_pci_dev(hwif->dev); 647 void *addr = pci_get_drvdata(dev); 648 u8 ch = hwif->channel; 649 hw_regs_t hw; ··· 756 757 static void __devinit init_iops_siimage(ide_hwif_t *hwif) 758 { 759 + struct pci_dev *dev = to_pci_dev(hwif->dev); 760 + 761 hwif->hwif_data = NULL; 762 763 /* Pessimal until we finish probing */ 764 hwif->rqsize = 15; 765 766 + if (pci_get_drvdata(dev) == NULL) 767 return; 768 769 init_mmio_iops_siimage(hwif); ··· 777 778 static u8 __devinit ata66_siimage(ide_hwif_t *hwif) 779 { 780 + struct pci_dev *dev = to_pci_dev(hwif->dev); 781 unsigned long addr = siimage_selreg(hwif, 0); 782 u8 ata66 = 0; 783 784 + if (pci_get_drvdata(dev) == NULL) 785 + pci_read_config_byte(dev, addr, &ata66); 786 else 787 ata66 = hwif->INB(addr); 788
+11 -13
drivers/ide/pci/sis5513.c
··· 1 /* 2 - * linux/drivers/ide/pci/sis5513.c Version 0.31 Aug 9, 2007 3 - * 4 * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> 5 * Copyright (C) 2002 Lionel Bouton <Lionel.Bouton@inet6.fr>, Maintainer 6 * Copyright (C) 2003 Vojtech Pavlik <vojtech@suse.cz> ··· 195 196 static u8 sis_ata133_get_base(ide_drive_t *drive) 197 { 198 - struct pci_dev *dev = drive->hwif->pci_dev; 199 u32 reg54 = 0; 200 201 pci_read_config_dword(dev, 0x54, &reg54); ··· 205 206 static void sis_ata16_program_timings(ide_drive_t *drive, const u8 mode) 207 { 208 - struct pci_dev *dev = drive->hwif->pci_dev; 209 u16 t1 = 0; 210 u8 drive_pci = 0x40 + drive->dn * 2; 211 ··· 228 229 static void sis_ata100_program_timings(ide_drive_t *drive, const u8 mode) 230 { 231 - struct pci_dev *dev = drive->hwif->pci_dev; 232 u8 t1, drive_pci = 0x40 + drive->dn * 2; 233 234 /* timing bits: 7:4 active 3:0 recovery */ ··· 251 252 static void sis_ata133_program_timings(ide_drive_t *drive, const u8 mode) 253 { 254 - struct pci_dev *dev = drive->hwif->pci_dev; 255 u32 t1 = 0; 256 u8 drive_pci = sis_ata133_get_base(drive), clk, idx; 257 ··· 284 static void config_drive_art_rwp (ide_drive_t *drive) 285 { 286 ide_hwif_t *hwif = HWIF(drive); 287 - struct pci_dev *dev = hwif->pci_dev; 288 u8 reg4bh = 0; 289 u8 rw_prefetch = 0; 290 ··· 305 306 static void sis_ata133_program_udma_timings(ide_drive_t *drive, const u8 mode) 307 { 308 - struct pci_dev *dev = drive->hwif->pci_dev; 309 u32 regdw = 0; 310 u8 drive_pci = sis_ata133_get_base(drive), clk, idx; 311 ··· 324 325 static void sis_ata33_program_udma_timings(ide_drive_t *drive, const u8 mode) 326 { 327 - struct pci_dev *dev = drive->hwif->pci_dev; 328 u8 drive_pci = 0x40 + drive->dn * 2, reg = 0, i = chipset_family; 329 330 pci_read_config_byte(dev, drive_pci + 1, &reg); ··· 357 358 static u8 sis5513_ata133_udma_filter(ide_drive_t *drive) 359 { 360 - struct pci_dev *dev = drive->hwif->pci_dev; 361 u32 regdw = 0; 362 u8 drive_pci = sis_ata133_get_base(drive); 363 ··· 528 529 static u8 __devinit ata66_sis5513(ide_hwif_t *hwif) 530 { 531 - struct pci_dev *pdev = hwif->pci_dev; 532 const struct sis_laptop *lap = &sis_laptop[0]; 533 u8 ata66 = 0; 534 ··· 543 if (chipset_family >= ATA_133) { 544 u16 regw = 0; 545 u16 reg_addr = hwif->channel ? 0x52: 0x50; 546 - pci_read_config_word(hwif->pci_dev, reg_addr, &regw); 547 ata66 = (regw & 0x8000) ? 0 : 1; 548 } else if (chipset_family >= ATA_66) { 549 u8 reg48h = 0; 550 u8 mask = hwif->channel ? 0x20 : 0x10; 551 - pci_read_config_byte(hwif->pci_dev, 0x48, &reg48h); 552 ata66 = (reg48h & mask) ? 0 : 1; 553 } 554
··· 1 /* 2 * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> 3 * Copyright (C) 2002 Lionel Bouton <Lionel.Bouton@inet6.fr>, Maintainer 4 * Copyright (C) 2003 Vojtech Pavlik <vojtech@suse.cz> ··· 197 198 static u8 sis_ata133_get_base(ide_drive_t *drive) 199 { 200 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 201 u32 reg54 = 0; 202 203 pci_read_config_dword(dev, 0x54, &reg54); ··· 207 208 static void sis_ata16_program_timings(ide_drive_t *drive, const u8 mode) 209 { 210 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 211 u16 t1 = 0; 212 u8 drive_pci = 0x40 + drive->dn * 2; 213 ··· 230 231 static void sis_ata100_program_timings(ide_drive_t *drive, const u8 mode) 232 { 233 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 234 u8 t1, drive_pci = 0x40 + drive->dn * 2; 235 236 /* timing bits: 7:4 active 3:0 recovery */ ··· 253 254 static void sis_ata133_program_timings(ide_drive_t *drive, const u8 mode) 255 { 256 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 257 u32 t1 = 0; 258 u8 drive_pci = sis_ata133_get_base(drive), clk, idx; 259 ··· 286 static void config_drive_art_rwp (ide_drive_t *drive) 287 { 288 ide_hwif_t *hwif = HWIF(drive); 289 + struct pci_dev *dev = to_pci_dev(hwif->dev); 290 u8 reg4bh = 0; 291 u8 rw_prefetch = 0; 292 ··· 307 308 static void sis_ata133_program_udma_timings(ide_drive_t *drive, const u8 mode) 309 { 310 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 311 u32 regdw = 0; 312 u8 drive_pci = sis_ata133_get_base(drive), clk, idx; 313 ··· 326 327 static void sis_ata33_program_udma_timings(ide_drive_t *drive, const u8 mode) 328 { 329 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 330 u8 drive_pci = 0x40 + drive->dn * 2, reg = 0, i = chipset_family; 331 332 pci_read_config_byte(dev, drive_pci + 1, &reg); ··· 359 360 static u8 sis5513_ata133_udma_filter(ide_drive_t *drive) 361 { 362 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 363 u32 regdw = 0; 364 u8 drive_pci = sis_ata133_get_base(drive); 365 ··· 530 531 static u8 __devinit ata66_sis5513(ide_hwif_t *hwif) 532 { 533 + struct pci_dev *pdev = to_pci_dev(hwif->dev); 534 const struct sis_laptop *lap = &sis_laptop[0]; 535 u8 ata66 = 0; 536 ··· 545 if (chipset_family >= ATA_133) { 546 u16 regw = 0; 547 u16 reg_addr = hwif->channel ? 0x52: 0x50; 548 + pci_read_config_word(pdev, reg_addr, &regw); 549 ata66 = (regw & 0x8000) ? 0 : 1; 550 } else if (chipset_family >= ATA_66) { 551 u8 reg48h = 0; 552 u8 mask = hwif->channel ? 0x20 : 0x10; 553 + pci_read_config_byte(pdev, 0x48, &reg48h); 554 ata66 = (reg48h & mask) ? 0 : 1; 555 } 556
+10 -9
drivers/ide/pci/sl82c105.c
··· 1 /* 2 - * linux/drivers/ide/pci/sl82c105.c 3 - * 4 * SL82C105/Winbond 553 IDE driver 5 * 6 * Maintainer unknown. ··· 76 */ 77 static void sl82c105_set_pio_mode(ide_drive_t *drive, const u8 pio) 78 { 79 - struct pci_dev *dev = HWIF(drive)->pci_dev; 80 int reg = 0x44 + drive->dn * 4; 81 u16 drv_ctrl; 82 ··· 145 static void sl82c105_dma_lost_irq(ide_drive_t *drive) 146 { 147 ide_hwif_t *hwif = HWIF(drive); 148 - struct pci_dev *dev = hwif->pci_dev; 149 u32 val, mask = hwif->channel ? CTRL_IDE_IRQB : CTRL_IDE_IRQA; 150 u8 dma_cmd; 151 ··· 182 static void sl82c105_dma_start(ide_drive_t *drive) 183 { 184 ide_hwif_t *hwif = HWIF(drive); 185 - struct pci_dev *dev = hwif->pci_dev; 186 int reg = 0x44 + drive->dn * 4; 187 188 DBG(("%s(drive:%s)\n", __FUNCTION__, drive->name)); ··· 195 196 static void sl82c105_dma_timeout(ide_drive_t *drive) 197 { 198 DBG(("sl82c105_dma_timeout(drive:%s)\n", drive->name)); 199 200 - sl82c105_reset_host(HWIF(drive)->pci_dev); 201 ide_dma_timeout(drive); 202 } 203 204 static int sl82c105_dma_end(ide_drive_t *drive) 205 { 206 - struct pci_dev *dev = HWIF(drive)->pci_dev; 207 int reg = 0x44 + drive->dn * 4; 208 int ret; 209 ··· 224 */ 225 static void sl82c105_resetproc(ide_drive_t *drive) 226 { 227 - struct pci_dev *dev = HWIF(drive)->pci_dev; 228 u32 val; 229 230 DBG(("sl82c105_resetproc(drive:%s)\n", drive->name)); ··· 293 */ 294 static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) 295 { 296 unsigned int rev; 297 298 DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index)); ··· 305 if (!hwif->dma_base) 306 return; 307 308 - rev = sl82c105_bridge_revision(hwif->pci_dev); 309 if (rev <= 5) { 310 /* 311 * Never ever EVER under any circumstances enable
··· 1 /* 2 * SL82C105/Winbond 553 IDE driver 3 * 4 * Maintainer unknown. ··· 78 */ 79 static void sl82c105_set_pio_mode(ide_drive_t *drive, const u8 pio) 80 { 81 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 82 int reg = 0x44 + drive->dn * 4; 83 u16 drv_ctrl; 84 ··· 147 static void sl82c105_dma_lost_irq(ide_drive_t *drive) 148 { 149 ide_hwif_t *hwif = HWIF(drive); 150 + struct pci_dev *dev = to_pci_dev(hwif->dev); 151 u32 val, mask = hwif->channel ? CTRL_IDE_IRQB : CTRL_IDE_IRQA; 152 u8 dma_cmd; 153 ··· 184 static void sl82c105_dma_start(ide_drive_t *drive) 185 { 186 ide_hwif_t *hwif = HWIF(drive); 187 + struct pci_dev *dev = to_pci_dev(hwif->dev); 188 int reg = 0x44 + drive->dn * 4; 189 190 DBG(("%s(drive:%s)\n", __FUNCTION__, drive->name)); ··· 197 198 static void sl82c105_dma_timeout(ide_drive_t *drive) 199 { 200 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 201 + 202 DBG(("sl82c105_dma_timeout(drive:%s)\n", drive->name)); 203 204 + sl82c105_reset_host(dev); 205 ide_dma_timeout(drive); 206 } 207 208 static int sl82c105_dma_end(ide_drive_t *drive) 209 { 210 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 211 int reg = 0x44 + drive->dn * 4; 212 int ret; 213 ··· 224 */ 225 static void sl82c105_resetproc(ide_drive_t *drive) 226 { 227 + struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 228 u32 val; 229 230 DBG(("sl82c105_resetproc(drive:%s)\n", drive->name)); ··· 293 */ 294 static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) 295 { 296 + struct pci_dev *dev = to_pci_dev(hwif->dev); 297 unsigned int rev; 298 299 DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index)); ··· 304 if (!hwif->dma_base) 305 return; 306 307 + rev = sl82c105_bridge_revision(dev); 308 if (rev <= 5) { 309 /* 310 * Never ever EVER under any circumstances enable
+4 -5
drivers/ide/pci/slc90e66.c
··· 1 /* 2 - * linux/drivers/ide/pci/slc90e66.c Version 0.19 Sep 24, 2007 3 - * 4 * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> 5 * Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com> 6 * ··· 24 static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) 25 { 26 ide_hwif_t *hwif = HWIF(drive); 27 - struct pci_dev *dev = hwif->pci_dev; 28 int is_slave = drive->dn & 1; 29 int master_port = hwif->channel ? 0x42 : 0x40; 30 int slave_port = 0x44; ··· 77 static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed) 78 { 79 ide_hwif_t *hwif = HWIF(drive); 80 - struct pci_dev *dev = hwif->pci_dev; 81 u8 maslave = hwif->channel ? 0x42 : 0x40; 82 int sitre = 0, a_speed = 7 << (drive->dn * 4); 83 int u_speed = 0, u_flag = 1 << drive->dn; ··· 120 121 static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif) 122 { 123 u8 reg47 = 0; 124 u8 mask = hwif->channel ? 0x01 : 0x02; /* bit0:Primary */ 125 126 hwif->set_pio_mode = &slc90e66_set_pio_mode; 127 hwif->set_dma_mode = &slc90e66_set_dma_mode; 128 129 - pci_read_config_byte(hwif->pci_dev, 0x47, &reg47); 130 131 if (hwif->dma_base == 0) 132 return;
··· 1 /* 2 * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> 3 * Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com> 4 * ··· 26 static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) 27 { 28 ide_hwif_t *hwif = HWIF(drive); 29 + struct pci_dev *dev = to_pci_dev(hwif->dev); 30 int is_slave = drive->dn & 1; 31 int master_port = hwif->channel ? 0x42 : 0x40; 32 int slave_port = 0x44; ··· 79 static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed) 80 { 81 ide_hwif_t *hwif = HWIF(drive); 82 + struct pci_dev *dev = to_pci_dev(hwif->dev); 83 u8 maslave = hwif->channel ? 0x42 : 0x40; 84 int sitre = 0, a_speed = 7 << (drive->dn * 4); 85 int u_speed = 0, u_flag = 1 << drive->dn; ··· 122 123 static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif) 124 { 125 + struct pci_dev *dev = to_pci_dev(hwif->dev); 126 u8 reg47 = 0; 127 u8 mask = hwif->channel ? 0x01 : 0x02; /* bit0:Primary */ 128 129 hwif->set_pio_mode = &slc90e66_set_pio_mode; 130 hwif->set_dma_mode = &slc90e66_set_dma_mode; 131 132 + pci_read_config_byte(dev, 0x47, &reg47); 133 134 if (hwif->dma_base == 0) 135 return;
+2 -3
drivers/ide/pci/tc86c001.c
··· 1 /* 2 - * drivers/ide/pci/tc86c001.c Version 1.01 Sep 5, 2007 3 - * 4 * Copyright (C) 2002 Toshiba Corporation 5 * Copyright (C) 2005-2006 MontaVista Software, Inc. <source@mvista.com> 6 * ··· 162 163 static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) 164 { 165 - unsigned long sc_base = pci_resource_start(hwif->pci_dev, 5); 166 u16 scr1 = inw(sc_base + 0x00); 167 168 /* System Control 1 Register bit 15 (Soft Reset) set */
··· 1 /* 2 * Copyright (C) 2002 Toshiba Corporation 3 * Copyright (C) 2005-2006 MontaVista Software, Inc. <source@mvista.com> 4 * ··· 164 165 static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) 166 { 167 + struct pci_dev *dev = to_pci_dev(hwif->dev); 168 + unsigned long sc_base = pci_resource_start(dev, 5); 169 u16 scr1 = inw(sc_base + 0x00); 170 171 /* System Control 1 Register bit 15 (Soft Reset) set */
+1 -3
drivers/ide/pci/triflex.c
··· 1 /* 2 - * triflex.c 3 - * 4 * IDE Chipset driver for the Compaq TriFlex IDE controller. 5 * 6 * Known to work with the Compaq Workstation 5x00 series. ··· 41 static void triflex_set_mode(ide_drive_t *drive, const u8 speed) 42 { 43 ide_hwif_t *hwif = HWIF(drive); 44 - struct pci_dev *dev = hwif->pci_dev; 45 u8 channel_offset = hwif->channel ? 0x74 : 0x70; 46 u16 timing = 0; 47 u32 triflex_timings = 0;
··· 1 /* 2 * IDE Chipset driver for the Compaq TriFlex IDE controller. 3 * 4 * Known to work with the Compaq Workstation 5x00 series. ··· 43 static void triflex_set_mode(ide_drive_t *drive, const u8 speed) 44 { 45 ide_hwif_t *hwif = HWIF(drive); 46 + struct pci_dev *dev = to_pci_dev(hwif->dev); 47 u8 channel_offset = hwif->channel ? 0x74 : 0x70; 48 u16 timing = 0; 49 u32 triflex_timings = 0;
+37 -26
drivers/ide/pci/trm290.c
··· 1 /* 2 - * linux/drivers/ide/pci/trm290.c Version 1.05 Dec. 26, 2007 3 - * 4 * Copyright (c) 1997-1998 Mark Lord 5 * Copyright (c) 2007 MontaVista Software, Inc. <source@mvista.com> 6 * May be copied or modified under the terms of the GNU General Public License 7 * 8 * June 22, 2004 - get rid of check_region ··· 208 } 209 /* select DMA xfer */ 210 trm290_prepare_drive(drive, 1); 211 - outl(hwif->dmatable_dma | rw, hwif->dma_command); 212 drive->waiting_for_dma = 1; 213 /* start DMA */ 214 - outw((count * 2) - 1, hwif->dma_status); 215 return 0; 216 } 217 ··· 221 222 static int trm290_ide_dma_end (ide_drive_t *drive) 223 { 224 - ide_hwif_t *hwif = HWIF(drive); 225 - u16 status = 0; 226 227 drive->waiting_for_dma = 0; 228 /* purge DMA mappings */ 229 ide_destroy_dmatable(drive); 230 - status = inw(hwif->dma_status); 231 - return (status != 0x00ff); 232 } 233 234 static int trm290_ide_dma_test_irq (ide_drive_t *drive) 235 { 236 - ide_hwif_t *hwif = HWIF(drive); 237 - u16 status = 0; 238 239 - status = inw(hwif->dma_status); 240 - return (status == 0x00ff); 241 } 242 243 static void trm290_dma_host_set(ide_drive_t *drive, int on) ··· 244 245 static void __devinit init_hwif_trm290(ide_hwif_t *hwif) 246 { 247 - unsigned int cfgbase = 0; 248 unsigned long flags; 249 u8 reg = 0; 250 - struct pci_dev *dev = hwif->pci_dev; 251 252 - cfgbase = pci_resource_start(dev, 4); 253 - if ((dev->class & 5) && cfgbase) { 254 - hwif->config_data = cfgbase; 255 - printk(KERN_INFO "TRM290: chip config base at 0x%04lx\n", 256 - hwif->config_data); 257 - } else { 258 - hwif->config_data = 0x3df0; 259 - printk(KERN_INFO "TRM290: using default config base at 0x%04lx\n", 260 - hwif->config_data); 261 } 262 263 local_irq_save(flags); 264 /* put config reg into first byte of hwif->select_data */ ··· 289 outb(reg, hwif->config_data + 3); 290 local_irq_restore(flags); 291 292 - if ((reg & 0x10)) 293 /* legacy mode */ 294 hwif->irq = hwif->channel ? 15 : 14; 295 else if (!hwif->irq && hwif->mate && hwif->mate->irq) 296 /* sharing IRQ with mate */ 297 hwif->irq = hwif->mate->irq; 298 - 299 - ide_setup_dma(hwif, (hwif->config_data + 4) ^ (hwif->channel ? 0x0080 : 0x0000), 3); 300 301 hwif->dma_host_set = &trm290_dma_host_set; 302 hwif->dma_setup = &trm290_dma_setup;
··· 1 /* 2 * Copyright (c) 1997-1998 Mark Lord 3 * Copyright (c) 2007 MontaVista Software, Inc. <source@mvista.com> 4 + * 5 * May be copied or modified under the terms of the GNU General Public License 6 * 7 * June 22, 2004 - get rid of check_region ··· 209 } 210 /* select DMA xfer */ 211 trm290_prepare_drive(drive, 1); 212 + outl(hwif->dmatable_dma | rw, hwif->dma_base); 213 drive->waiting_for_dma = 1; 214 /* start DMA */ 215 + outw(count * 2 - 1, hwif->dma_base + 2); 216 return 0; 217 } 218 ··· 222 223 static int trm290_ide_dma_end (ide_drive_t *drive) 224 { 225 + u16 status; 226 227 drive->waiting_for_dma = 0; 228 /* purge DMA mappings */ 229 ide_destroy_dmatable(drive); 230 + status = inw(HWIF(drive)->dma_base + 2); 231 + return status != 0x00ff; 232 } 233 234 static int trm290_ide_dma_test_irq (ide_drive_t *drive) 235 { 236 + u16 status; 237 238 + status = inw(HWIF(drive)->dma_base + 2); 239 + return status == 0x00ff; 240 } 241 242 static void trm290_dma_host_set(ide_drive_t *drive, int on) ··· 247 248 static void __devinit init_hwif_trm290(ide_hwif_t *hwif) 249 { 250 + struct pci_dev *dev = to_pci_dev(hwif->dev); 251 + unsigned int cfg_base = pci_resource_start(dev, 4); 252 unsigned long flags; 253 u8 reg = 0; 254 255 + if ((dev->class & 5) && cfg_base) 256 + printk(KERN_INFO "TRM290: chip"); 257 + else { 258 + cfg_base = 0x3df0; 259 + printk(KERN_INFO "TRM290: using default"); 260 } 261 + printk(KERN_CONT " config base at 0x%04x\n", cfg_base); 262 + hwif->config_data = cfg_base; 263 + hwif->dma_base = (cfg_base + 4) ^ (hwif->channel ? 0x80 : 0); 264 + 265 + printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx", 266 + hwif->name, hwif->dma_base, hwif->dma_base + 3); 267 + 268 + if (!request_region(hwif->dma_base, 4, hwif->name)) { 269 + printk(KERN_CONT " -- Error, ports in use.\n"); 270 + return; 271 + } 272 + 273 + hwif->dmatable_cpu = pci_alloc_consistent(dev, PRD_ENTRIES * PRD_BYTES, 274 + &hwif->dmatable_dma); 275 + if (!hwif->dmatable_cpu) { 276 + printk(KERN_CONT " -- Error, unable to allocate DMA table.\n"); 277 + release_region(hwif->dma_base, 4); 278 + return; 279 + } 280 + printk(KERN_CONT "\n"); 281 282 local_irq_save(flags); 283 /* put config reg into first byte of hwif->select_data */ ··· 276 outb(reg, hwif->config_data + 3); 277 local_irq_restore(flags); 278 279 + if (reg & 0x10) 280 /* legacy mode */ 281 hwif->irq = hwif->channel ? 15 : 14; 282 else if (!hwif->irq && hwif->mate && hwif->mate->irq) 283 /* sharing IRQ with mate */ 284 hwif->irq = hwif->mate->irq; 285 286 hwif->dma_host_set = &trm290_dma_host_set; 287 hwif->dma_setup = &trm290_dma_setup;
+7 -8
drivers/ide/pci/via82cxxx.c
··· 1 /* 2 - * 3 - * Version 3.50 4 - * 5 * VIA IDE driver for Linux. Supported southbridges: 6 * 7 * vt82c576, vt82c586, vt82c586a, vt82c586b, vt82c596a, vt82c596b, ··· 118 119 static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) 120 { 121 - struct pci_dev *dev = hwif->pci_dev; 122 - struct via82cxxx_dev *vdev = pci_get_drvdata(hwif->pci_dev); 123 u8 t; 124 125 if (~vdev->via_config->flags & VIA_BAD_AST) { ··· 156 157 static void via_set_drive(ide_drive_t *drive, const u8 speed) 158 { 159 - ide_drive_t *peer = HWIF(drive)->drives + (~drive->dn & 1); 160 - struct via82cxxx_dev *vdev = pci_get_drvdata(drive->hwif->pci_dev); 161 struct ide_timing t, p; 162 unsigned int T, UT; 163 ··· 407 408 static u8 __devinit via82cxxx_cable_detect(ide_hwif_t *hwif) 409 { 410 - struct pci_dev *pdev = hwif->pci_dev; 411 struct via82cxxx_dev *vdev = pci_get_drvdata(pdev); 412 413 if (via_cable_override(pdev))
··· 1 /* 2 * VIA IDE driver for Linux. Supported southbridges: 3 * 4 * vt82c576, vt82c586, vt82c586a, vt82c586b, vt82c596a, vt82c596b, ··· 121 122 static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) 123 { 124 + struct pci_dev *dev = to_pci_dev(hwif->dev); 125 + struct via82cxxx_dev *vdev = pci_get_drvdata(dev); 126 u8 t; 127 128 if (~vdev->via_config->flags & VIA_BAD_AST) { ··· 159 160 static void via_set_drive(ide_drive_t *drive, const u8 speed) 161 { 162 + ide_hwif_t *hwif = drive->hwif; 163 + ide_drive_t *peer = hwif->drives + (~drive->dn & 1); 164 + struct pci_dev *dev = to_pci_dev(hwif->dev); 165 + struct via82cxxx_dev *vdev = pci_get_drvdata(dev); 166 struct ide_timing t, p; 167 unsigned int T, UT; 168 ··· 408 409 static u8 __devinit via82cxxx_cable_detect(ide_hwif_t *hwif) 410 { 411 + struct pci_dev *pdev = to_pci_dev(hwif->dev); 412 struct via82cxxx_dev *vdev = pci_get_drvdata(pdev); 413 414 if (via_cable_override(pdev))
-2
drivers/ide/ppc/mpc8xx.c
··· 1 /* 2 - * linux/drivers/ide/ppc/ide-m8xx.c 3 - * 4 * Copyright (C) 2000, 2001 Wolfgang Denk, wd@denx.de 5 * Modified for direct IDE interface 6 * by Thomas Lange, thomas@corelatus.com
··· 1 /* 2 * Copyright (C) 2000, 2001 Wolfgang Denk, wd@denx.de 3 * Modified for direct IDE interface 4 * by Thomas Lange, thomas@corelatus.com
+18 -21
drivers/ide/ppc/pmac.c
··· 1 /* 2 - * linux/drivers/ide/ppc/pmac.c 3 - * 4 * Support for IDE interfaces on PowerMacs. 5 * These IDE interfaces are memory-mapped and have a DBDMA channel 6 * for doing DMA. 7 * ··· 1010 * (it is kept in 2.4). This introduce an interface numbering change on some 1011 * rare machines unfortunately, but it's better this way. 1012 */ 1013 - static int 1014 pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) 1015 { 1016 struct device_node *np = pmif->node; ··· 1199 base = ioremap(macio_resource_start(mdev, 0), 0x400); 1200 regbase = (unsigned long) base; 1201 1202 - hwif->pci_dev = mdev->bus->pdev; 1203 1204 pmif->mdev = mdev; 1205 pmif->node = mdev->ofdev.node; ··· 1227 /* The inteface is released to the common IDE layer */ 1228 dev_set_drvdata(&mdev->ofdev.dev, NULL); 1229 iounmap(base); 1230 - if (pmif->dma_regs) 1231 iounmap(pmif->dma_regs); 1232 memset(pmif, 0, sizeof(*pmif)); 1233 macio_release_resource(mdev, 0); 1234 - if (pmif->dma_regs) 1235 - macio_release_resource(mdev, 1); 1236 } 1237 1238 return rc; ··· 1314 return -ENXIO; 1315 } 1316 1317 - hwif->pci_dev = pdev; 1318 pmif->mdev = NULL; 1319 pmif->node = np; 1320 ··· 1534 } 1535 1536 printk(KERN_DEBUG "%s: empty DMA table?\n", drive->name); 1537 - use_pio_instead: 1538 - pci_unmap_sg(hwif->pci_dev, 1539 - hwif->sg_table, 1540 - hwif->sg_nents, 1541 - hwif->sg_dma_direction); 1542 return 0; /* revert to PIO for this request */ 1543 } 1544 ··· 1546 pmac_ide_destroy_dmatable (ide_drive_t *drive) 1547 { 1548 ide_hwif_t *hwif = drive->hwif; 1549 - struct pci_dev *dev = HWIF(drive)->pci_dev; 1550 - struct scatterlist *sg = hwif->sg_table; 1551 - int nents = hwif->sg_nents; 1552 1553 - if (nents) { 1554 - pci_unmap_sg(dev, sg, nents, hwif->sg_dma_direction); 1555 hwif->sg_nents = 0; 1556 } 1557 } ··· 1721 * Allocate the data structures needed for using DMA with an interface 1722 * and fill the proper list of functions pointers 1723 */ 1724 - static void __init 1725 pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) 1726 { 1727 /* We won't need pci_dev if we switch to generic consistent 1728 * DMA routines ... 1729 */ 1730 - if (hwif->pci_dev == NULL) 1731 return; 1732 /* 1733 * Allocate space for the DBDMA commands. ··· 1737 * aligning the start address to a multiple of 16 bytes. 1738 */ 1739 pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent( 1740 - hwif->pci_dev, 1741 (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd), 1742 &hwif->dmatable_dma); 1743 if (pmif->dma_table_cpu == NULL) {
··· 1 /* 2 * Support for IDE interfaces on PowerMacs. 3 + * 4 * These IDE interfaces are memory-mapped and have a DBDMA channel 5 * for doing DMA. 6 * ··· 1011 * (it is kept in 2.4). This introduce an interface numbering change on some 1012 * rare machines unfortunately, but it's better this way. 1013 */ 1014 + static int __devinit 1015 pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) 1016 { 1017 struct device_node *np = pmif->node; ··· 1200 base = ioremap(macio_resource_start(mdev, 0), 0x400); 1201 regbase = (unsigned long) base; 1202 1203 + hwif->dev = &mdev->bus->pdev->dev; 1204 1205 pmif->mdev = mdev; 1206 pmif->node = mdev->ofdev.node; ··· 1228 /* The inteface is released to the common IDE layer */ 1229 dev_set_drvdata(&mdev->ofdev.dev, NULL); 1230 iounmap(base); 1231 + if (pmif->dma_regs) { 1232 iounmap(pmif->dma_regs); 1233 + macio_release_resource(mdev, 1); 1234 + } 1235 memset(pmif, 0, sizeof(*pmif)); 1236 macio_release_resource(mdev, 0); 1237 } 1238 1239 return rc; ··· 1315 return -ENXIO; 1316 } 1317 1318 + hwif->dev = &pdev->dev; 1319 pmif->mdev = NULL; 1320 pmif->node = np; 1321 ··· 1535 } 1536 1537 printk(KERN_DEBUG "%s: empty DMA table?\n", drive->name); 1538 + 1539 + use_pio_instead: 1540 + ide_destroy_dmatable(drive); 1541 + 1542 return 0; /* revert to PIO for this request */ 1543 } 1544 ··· 1548 pmac_ide_destroy_dmatable (ide_drive_t *drive) 1549 { 1550 ide_hwif_t *hwif = drive->hwif; 1551 1552 + if (hwif->sg_nents) { 1553 + ide_destroy_dmatable(drive); 1554 hwif->sg_nents = 0; 1555 } 1556 } ··· 1726 * Allocate the data structures needed for using DMA with an interface 1727 * and fill the proper list of functions pointers 1728 */ 1729 + static void __devinit 1730 pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) 1731 { 1732 + struct pci_dev *dev = to_pci_dev(hwif->dev); 1733 + 1734 /* We won't need pci_dev if we switch to generic consistent 1735 * DMA routines ... 1736 */ 1737 + if (dev == NULL) 1738 return; 1739 /* 1740 * Allocate space for the DBDMA commands. ··· 1740 * aligning the start address to a multiple of 16 bytes. 1741 */ 1742 pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent( 1743 + dev, 1744 (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd), 1745 &hwif->dmatable_dma); 1746 if (pmif->dma_table_cpu == NULL) {
+40 -52
drivers/ide/setup-pci.c
··· 1 /* 2 - * linux/drivers/ide/setup-pci.c Version 1.10 2002/08/19 3 * 4 - * Copyright (c) 1998-2000 Andre Hedrick <andre@linux-ide.org> 5 - * 6 - * Copyright (c) 1995-1998 Mark Lord 7 * May be copied or modified under the terms of the GNU General Public License 8 */ 9 ··· 139 } 140 141 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI 142 /** 143 * ide_get_or_set_dma_base - setup BMIBA 144 * @d: IDE port info ··· 161 162 static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_hwif_t *hwif) 163 { 164 - unsigned long dma_base = 0; 165 - struct pci_dev *dev = hwif->pci_dev; 166 167 if (hwif->mmio) 168 return hwif->dma_base; ··· 184 if (hwif->channel) 185 dma_base += 8; 186 187 - if ((d->host_flags & IDE_HFLAG_CS5520) == 0) { 188 - u8 simplex_stat = 0; 189 190 - switch(dev->device) { 191 - case PCI_DEVICE_ID_AL_M5219: 192 - case PCI_DEVICE_ID_AL_M5229: 193 - case PCI_DEVICE_ID_AMD_VIPER_7409: 194 - case PCI_DEVICE_ID_CMD_643: 195 - case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE: 196 - case PCI_DEVICE_ID_REVOLUTION: 197 - simplex_stat = inb(dma_base + 2); 198 - outb(simplex_stat & 0x60, dma_base + 2); 199 - simplex_stat = inb(dma_base + 2); 200 - if (simplex_stat & 0x80) { 201 - printk(KERN_INFO "%s: simplex device: " 202 - "DMA forced\n", 203 - d->name); 204 - } 205 - break; 206 - default: 207 - /* 208 - * If the device claims "simplex" DMA, 209 - * this means only one of the two interfaces 210 - * can be trusted with DMA at any point in time. 211 - * So we should enable DMA only on one of the 212 - * two interfaces. 213 - */ 214 - simplex_stat = hwif->INB(dma_base + 2); 215 - if (simplex_stat & 0x80) { 216 - /* simplex device? */ 217 - /* 218 - * At this point we haven't probed the drives so we can't make the 219 - * appropriate decision. Really we should defer this problem 220 - * until we tune the drive then try to grab DMA ownership if we want 221 - * to be the DMA end. This has to be become dynamic to handle hot 222 - * plug. 223 - */ 224 - if (hwif->mate && hwif->mate->dma_base) { 225 - printk(KERN_INFO "%s: simplex device: " 226 - "DMA disabled\n", 227 - d->name); 228 - dma_base = 0; 229 - } 230 - } 231 - } 232 } 233 return dma_base; 234 } 235 #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ ··· 390 391 hwif->noprobe = oldnoprobe; 392 393 - hwif->pci_dev = dev; 394 hwif->cds = d; 395 hwif->channel = port; 396 ··· 439 if (d->init_dma) { 440 d->init_dma(hwif, dma_base); 441 } else { 442 - ide_setup_dma(hwif, dma_base, 8); 443 } 444 } else { 445 printk(KERN_INFO "%s: %s Bus-Master DMA disabled "
··· 1 /* 2 + * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> 3 + * Copyright (C) 1995-1998 Mark Lord 4 + * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 5 * 6 * May be copied or modified under the terms of the GNU General Public License 7 */ 8 ··· 140 } 141 142 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI 143 + static void ide_pci_clear_simplex(unsigned long dma_base, const char *name) 144 + { 145 + u8 dma_stat = inb(dma_base + 2); 146 + 147 + outb(dma_stat & 0x60, dma_base + 2); 148 + dma_stat = inb(dma_base + 2); 149 + if (dma_stat & 0x80) 150 + printk(KERN_INFO "%s: simplex device: DMA forced\n", name); 151 + } 152 + 153 /** 154 * ide_get_or_set_dma_base - setup BMIBA 155 * @d: IDE port info ··· 152 153 static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_hwif_t *hwif) 154 { 155 + struct pci_dev *dev = to_pci_dev(hwif->dev); 156 + unsigned long dma_base = 0; 157 + u8 dma_stat = 0; 158 159 if (hwif->mmio) 160 return hwif->dma_base; ··· 174 if (hwif->channel) 175 dma_base += 8; 176 177 + if (d->host_flags & IDE_HFLAG_CS5520) 178 + goto out; 179 180 + if (d->host_flags & IDE_HFLAG_CLEAR_SIMPLEX) { 181 + ide_pci_clear_simplex(dma_base, d->name); 182 + goto out; 183 } 184 + 185 + /* 186 + * If the device claims "simplex" DMA, this means that only one of 187 + * the two interfaces can be trusted with DMA at any point in time 188 + * (so we should enable DMA only on one of the two interfaces). 189 + * 190 + * FIXME: At this point we haven't probed the drives so we can't make 191 + * the appropriate decision. Really we should defer this problem until 192 + * we tune the drive then try to grab DMA ownership if we want to be 193 + * the DMA end. This has to be become dynamic to handle hot-plug. 194 + */ 195 + dma_stat = hwif->INB(dma_base + 2); 196 + if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) { 197 + printk(KERN_INFO "%s: simplex device: DMA disabled\n", d->name); 198 + dma_base = 0; 199 + } 200 + out: 201 return dma_base; 202 } 203 #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ ··· 402 403 hwif->noprobe = oldnoprobe; 404 405 + hwif->dev = &dev->dev; 406 hwif->cds = d; 407 hwif->channel = port; 408 ··· 451 if (d->init_dma) { 452 d->init_dma(hwif, dma_base); 453 } else { 454 + ide_setup_dma(hwif, dma_base); 455 } 456 } else { 457 printk(KERN_INFO "%s: %s Bus-Master DMA disabled "
+2 -3
drivers/scsi/ide-scsi.c
··· 1 /* 2 - * linux/drivers/scsi/ide-scsi.c Version 0.9 Jul 4, 1999 3 - * 4 - * Copyright (C) 1996 - 1999 Gadi Oxman <gadio@netvision.net.il> 5 */ 6 7 /*
··· 1 /* 2 + * Copyright (C) 1996-1999 Gadi Oxman <gadio@netvision.net.il> 3 + * Copyright (C) 2004-2005 Bartlomiej Zolnierkiewicz 4 */ 5 6 /*
-1
include/asm-mips/mach-au1x00/au1xxx_ide.h
··· 74 struct dbdma_cmd *dma_table_cpu; 75 dma_addr_t dma_table_dma; 76 #endif 77 - struct device *dev; 78 int irq; 79 u32 regbase; 80 #ifdef CONFIG_PM
··· 74 struct dbdma_cmd *dma_table_cpu; 75 dma_addr_t dma_table_dma; 76 #endif 77 int irq; 78 u32 regbase; 79 #ifdef CONFIG_PM
+14
include/linux/cdrom.h
··· 1187 1188 extern int cdrom_get_media_event(struct cdrom_device_info *cdi, struct media_event_desc *med); 1189 1190 #endif /* End of kernel only stuff */ 1191 1192 #endif /* _LINUX_CDROM_H */
··· 1187 1188 extern int cdrom_get_media_event(struct cdrom_device_info *cdi, struct media_event_desc *med); 1189 1190 + static inline void lba_to_msf(int lba, u8 *m, u8 *s, u8 *f) 1191 + { 1192 + lba += CD_MSF_OFFSET; 1193 + lba &= 0xffffff; /* negative lbas use only 24 bits */ 1194 + *m = lba / (CD_SECS * CD_FRAMES); 1195 + lba %= (CD_SECS * CD_FRAMES); 1196 + *s = lba / CD_FRAMES; 1197 + *f = lba % CD_FRAMES; 1198 + } 1199 + 1200 + static inline int msf_to_lba(u8 m, u8 s, u8 f) 1201 + { 1202 + return (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET; 1203 + } 1204 #endif /* End of kernel only stuff */ 1205 1206 #endif /* _LINUX_CDROM_H */
+2
include/linux/hdsmart.h
··· 17 #ifndef _LINUX_HDSMART_H 18 #define _LINUX_HDSMART_H 19 20 #define OFFLINE_FULL_SCAN 0 21 #define SHORT_SELF_TEST 1 22 #define EXTEND_SELF_TEST 2 ··· 121 unsigned char resevered[2]; 122 unsigned char chksum; 123 } __attribute__ ((packed)) ata_smart_selftestlog_t; 124 125 #endif /* _LINUX_HDSMART_H */
··· 17 #ifndef _LINUX_HDSMART_H 18 #define _LINUX_HDSMART_H 19 20 + #ifndef __KERNEL 21 #define OFFLINE_FULL_SCAN 0 22 #define SHORT_SELF_TEST 1 23 #define EXTEND_SELF_TEST 2 ··· 120 unsigned char resevered[2]; 121 unsigned char chksum; 122 } __attribute__ ((packed)) ata_smart_selftestlog_t; 123 + #endif /* __KERNEL__ * 124 125 #endif /* _LINUX_HDSMART_H */
+20 -20
include/linux/ide.h
··· 9 #include <linux/init.h> 10 #include <linux/ioport.h> 11 #include <linux/hdreg.h> 12 - #include <linux/hdsmart.h> 13 #include <linux/blkdev.h> 14 #include <linux/proc_fs.h> 15 #include <linux/interrupt.h> ··· 502 503 hwif_chipset_t chipset; /* sub-module for tuning.. */ 504 505 - struct pci_dev *pci_dev; /* for pci chipsets */ 506 const struct ide_port_info *cds; /* chipset device struct */ 507 508 ide_ack_intr_t *ack_intr; ··· 628 typedef struct hwgroup_s { 629 /* irq handler, if active */ 630 ide_startstop_t (*handler)(ide_drive_t *); 631 - /* irq handler, suspended if active */ 632 - ide_startstop_t (*handler_save)(ide_drive_t *); 633 /* BOOL: protects all fields below */ 634 volatile int busy; 635 /* BOOL: wake us up on timer expiry */ ··· 643 /* ptr to current hwif in linked-list */ 644 ide_hwif_t *hwif; 645 646 - /* for pci chipsets */ 647 - struct pci_dev *pci_dev; 648 - 649 /* current request */ 650 struct request *rq; 651 /* failsafe timer */ 652 struct timer_list timer; 653 - /* local copy of current write rq */ 654 - struct request wrq; 655 /* timeout value during long polls */ 656 unsigned long poll_timeout; 657 /* queried upon timeouts */ 658 int (*expiry)(ide_drive_t *); 659 - /* ide_system_bus_speed */ 660 - int pio_clock; 661 int req_gen; 662 int req_gen_timer; 663 - 664 - unsigned char cmd_buf[4]; 665 } ide_hwgroup_t; 666 667 typedef struct ide_driver_s ide_driver_t; ··· 978 979 void task_end_request(ide_drive_t *, struct request *, u8); 980 981 - u8 wait_drive_not_busy(ide_drive_t *); 982 - 983 int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16); 984 int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); 985 ··· 1007 1008 #ifdef CONFIG_IDEPCI_PCIBUS_ORDER 1009 extern int ide_scan_direction; 1010 - int __init ide_scan_pcibus(void); 1011 extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner, const char *mod_name); 1012 #define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE, KBUILD_MODNAME) 1013 #else ··· 1085 IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26), 1086 /* host is CY82C693 */ 1087 IDE_HFLAG_CY82C693 = (1 << 27), 1088 }; 1089 1090 #ifdef CONFIG_BLK_DEV_OFFBOARD ··· 1146 int ide_set_dma(ide_drive_t *); 1147 ide_startstop_t ide_dma_intr(ide_drive_t *); 1148 1149 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI 1150 - extern int ide_build_sglist(ide_drive_t *, struct request *); 1151 extern int ide_build_dmatable(ide_drive_t *, struct request *); 1152 - extern void ide_destroy_dmatable(ide_drive_t *); 1153 extern int ide_release_dma(ide_hwif_t *); 1154 - extern void ide_setup_dma(ide_hwif_t *, unsigned long, unsigned int); 1155 1156 void ide_dma_host_set(ide_drive_t *, int); 1157 extern int ide_dma_setup(ide_drive_t *); ··· 1191 static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} 1192 #endif 1193 1194 extern int ide_hwif_request_regions(ide_hwif_t *hwif); 1195 extern void ide_hwif_release_regions(ide_hwif_t* hwif); 1196 extern void ide_unregister (unsigned int index); ··· 1286 #define ide_id_has_flush_cache_ext(id) \ 1287 (((id)->cfs_enable_2 & 0x2400) == 0x2400) 1288 1289 static inline int hwif_to_node(ide_hwif_t *hwif) 1290 { 1291 - struct pci_dev *dev = hwif->pci_dev; 1292 return dev ? pcibus_to_node(dev->bus) : -1; 1293 } 1294
··· 9 #include <linux/init.h> 10 #include <linux/ioport.h> 11 #include <linux/hdreg.h> 12 #include <linux/blkdev.h> 13 #include <linux/proc_fs.h> 14 #include <linux/interrupt.h> ··· 503 504 hwif_chipset_t chipset; /* sub-module for tuning.. */ 505 506 + struct device *dev; 507 + 508 const struct ide_port_info *cds; /* chipset device struct */ 509 510 ide_ack_intr_t *ack_intr; ··· 628 typedef struct hwgroup_s { 629 /* irq handler, if active */ 630 ide_startstop_t (*handler)(ide_drive_t *); 631 + 632 /* BOOL: protects all fields below */ 633 volatile int busy; 634 /* BOOL: wake us up on timer expiry */ ··· 644 /* ptr to current hwif in linked-list */ 645 ide_hwif_t *hwif; 646 647 /* current request */ 648 struct request *rq; 649 + 650 /* failsafe timer */ 651 struct timer_list timer; 652 /* timeout value during long polls */ 653 unsigned long poll_timeout; 654 /* queried upon timeouts */ 655 int (*expiry)(ide_drive_t *); 656 + 657 int req_gen; 658 int req_gen_timer; 659 } ide_hwgroup_t; 660 661 typedef struct ide_driver_s ide_driver_t; ··· 986 987 void task_end_request(ide_drive_t *, struct request *, u8); 988 989 int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16); 990 int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); 991 ··· 1017 1018 #ifdef CONFIG_IDEPCI_PCIBUS_ORDER 1019 extern int ide_scan_direction; 1020 extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner, const char *mod_name); 1021 #define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE, KBUILD_MODNAME) 1022 #else ··· 1096 IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26), 1097 /* host is CY82C693 */ 1098 IDE_HFLAG_CY82C693 = (1 << 27), 1099 + /* force host out of "simplex" mode */ 1100 + IDE_HFLAG_CLEAR_SIMPLEX = (1 << 28), 1101 + /* DSC overlap is unsupported */ 1102 + IDE_HFLAG_NO_DSC = (1 << 29), 1103 }; 1104 1105 #ifdef CONFIG_BLK_DEV_OFFBOARD ··· 1153 int ide_set_dma(ide_drive_t *); 1154 ide_startstop_t ide_dma_intr(ide_drive_t *); 1155 1156 + int ide_build_sglist(ide_drive_t *, struct request *); 1157 + void ide_destroy_dmatable(ide_drive_t *); 1158 + 1159 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI 1160 extern int ide_build_dmatable(ide_drive_t *, struct request *); 1161 extern int ide_release_dma(ide_hwif_t *); 1162 + extern void ide_setup_dma(ide_hwif_t *, unsigned long); 1163 1164 void ide_dma_host_set(ide_drive_t *, int); 1165 extern int ide_dma_setup(ide_drive_t *); ··· 1197 static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} 1198 #endif 1199 1200 + void ide_remove_port_from_hwgroup(ide_hwif_t *); 1201 extern int ide_hwif_request_regions(ide_hwif_t *hwif); 1202 extern void ide_hwif_release_regions(ide_hwif_t* hwif); 1203 extern void ide_unregister (unsigned int index); ··· 1291 #define ide_id_has_flush_cache_ext(id) \ 1292 (((id)->cfs_enable_2 & 0x2400) == 0x2400) 1293 1294 + static inline void ide_dump_identify(u8 *id) 1295 + { 1296 + print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 2, id, 512, 0); 1297 + } 1298 + 1299 static inline int hwif_to_node(ide_hwif_t *hwif) 1300 { 1301 + struct pci_dev *dev = to_pci_dev(hwif->dev); 1302 return dev ? pcibus_to_node(dev->bus) : -1; 1303 } 1304