pata_legacy.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. /*
  2. * pata-legacy.c - Legacy port PATA/SATA controller driver.
  3. * Copyright 2005/2006 Red Hat, all rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2, or (at your option)
  8. * any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; see the file COPYING. If not, write to
  17. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18. *
  19. * An ATA driver for the legacy ATA ports.
  20. *
  21. * Data Sources:
  22. * Opti 82C465/82C611 support: Data sheets at opti-inc.com
  23. * HT6560 series:
  24. * Promise 20230/20620:
  25. * http://www.ryston.cz/petr/vlb/pdc20230b.html
  26. * http://www.ryston.cz/petr/vlb/pdc20230c.html
  27. * http://www.ryston.cz/petr/vlb/pdc20630.html
  28. * QDI65x0:
  29. * http://www.ryston.cz/petr/vlb/qd6500.html
  30. * http://www.ryston.cz/petr/vlb/qd6580.html
  31. *
  32. * QDI65x0 probe code based on drivers/ide/legacy/qd65xx.c
  33. * Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by
  34. * Samuel Thibault <samuel.thibault@ens-lyon.org>
  35. *
  36. * Unsupported but docs exist:
  37. * Appian/Adaptec AIC25VL01/Cirrus Logic PD7220
  38. *
  39. * This driver handles legacy (that is "ISA/VLB side") IDE ports found
  40. * on PC class systems. There are three hybrid devices that are exceptions
  41. * The Cyrix 5510/5520 where a pre SFF ATA device is on the bridge and
  42. * the MPIIX where the tuning is PCI side but the IDE is "ISA side".
  43. *
  44. * Specific support is included for the ht6560a/ht6560b/opti82c611a/
  45. * opti82c465mv/promise 20230c/20630/qdi65x0/winbond83759A
  46. *
  47. * Support for the Winbond 83759A when operating in advanced mode.
  48. * Multichip mode is not currently supported.
  49. *
  50. * Use the autospeed and pio_mask options with:
  51. * Appian ADI/2 aka CLPD7220 or AIC25VL01.
  52. * Use the jumpers, autospeed and set pio_mask to the mode on the jumpers with
  53. * Goldstar GM82C711, PIC-1288A-125, UMC 82C871F, Winbond W83759,
  54. * Winbond W83759A, Promise PDC20230-B
  55. *
  56. * For now use autospeed and pio_mask as above with the W83759A. This may
  57. * change.
  58. *
  59. */
  60. #include <linux/async.h>
  61. #include <linux/kernel.h>
  62. #include <linux/module.h>
  63. #include <linux/pci.h>
  64. #include <linux/init.h>
  65. #include <linux/blkdev.h>
  66. #include <linux/delay.h>
  67. #include <scsi/scsi_host.h>
  68. #include <linux/ata.h>
  69. #include <linux/libata.h>
  70. #include <linux/platform_device.h>
  71. #define DRV_NAME "pata_legacy"
  72. #define DRV_VERSION "0.6.5"
  73. #define NR_HOST 6
  74. static int all;
  75. module_param(all, int, 0444);
  76. MODULE_PARM_DESC(all, "Grab all legacy port devices, even if PCI(0=off, 1=on)");
  77. enum controller {
  78. BIOS = 0,
  79. SNOOP = 1,
  80. PDC20230 = 2,
  81. HT6560A = 3,
  82. HT6560B = 4,
  83. OPTI611A = 5,
  84. OPTI46X = 6,
  85. QDI6500 = 7,
  86. QDI6580 = 8,
  87. QDI6580DP = 9, /* Dual channel mode is different */
  88. W83759A = 10,
  89. UNKNOWN = -1
  90. };
  91. struct legacy_data {
  92. unsigned long timing;
  93. u8 clock[2];
  94. u8 last;
  95. int fast;
  96. enum controller type;
  97. struct platform_device *platform_dev;
  98. };
  99. struct legacy_probe {
  100. unsigned char *name;
  101. unsigned long port;
  102. unsigned int irq;
  103. unsigned int slot;
  104. enum controller type;
  105. unsigned long private;
  106. };
  107. struct legacy_controller {
  108. const char *name;
  109. struct ata_port_operations *ops;
  110. unsigned int pio_mask;
  111. unsigned int flags;
  112. unsigned int pflags;
  113. int (*setup)(struct platform_device *, struct legacy_probe *probe,
  114. struct legacy_data *data);
  115. };
  116. static int legacy_port[NR_HOST] = { 0x1f0, 0x170, 0x1e8, 0x168, 0x1e0, 0x160 };
  117. static struct legacy_probe probe_list[NR_HOST];
  118. static struct legacy_data legacy_data[NR_HOST];
  119. static struct ata_host *legacy_host[NR_HOST];
  120. static int nr_legacy_host;
  121. static int probe_all; /* Set to check all ISA port ranges */
  122. static int ht6560a; /* HT 6560A on primary 1, second 2, both 3 */
  123. static int ht6560b; /* HT 6560A on primary 1, second 2, both 3 */
  124. static int opti82c611a; /* Opti82c611A on primary 1, sec 2, both 3 */
  125. static int opti82c46x; /* Opti 82c465MV present(pri/sec autodetect) */
  126. static int autospeed; /* Chip present which snoops speed changes */
  127. static int pio_mask = ATA_PIO4; /* PIO range for autospeed devices */
  128. static int iordy_mask = 0xFFFFFFFF; /* Use iordy if available */
  129. /* Set to probe QDI controllers */
  130. #ifdef CONFIG_PATA_QDI_MODULE
  131. static int qdi = 1;
  132. #else
  133. static int qdi;
  134. #endif
  135. #ifdef CONFIG_PATA_WINBOND_VLB_MODULE
  136. static int winbond = 1; /* Set to probe Winbond controllers,
  137. give I/O port if non standard */
  138. #else
  139. static int winbond; /* Set to probe Winbond controllers,
  140. give I/O port if non standard */
  141. #endif
  142. /**
  143. * legacy_probe_add - Add interface to probe list
  144. * @port: Controller port
  145. * @irq: IRQ number
  146. * @type: Controller type
  147. * @private: Controller specific info
  148. *
  149. * Add an entry into the probe list for ATA controllers. This is used
  150. * to add the default ISA slots and then to build up the table
  151. * further according to other ISA/VLB/Weird device scans
  152. *
  153. * An I/O port list is used to keep ordering stable and sane, as we
  154. * don't have any good way to talk about ordering otherwise
  155. */
  156. static int legacy_probe_add(unsigned long port, unsigned int irq,
  157. enum controller type, unsigned long private)
  158. {
  159. struct legacy_probe *lp = &probe_list[0];
  160. int i;
  161. struct legacy_probe *free = NULL;
  162. for (i = 0; i < NR_HOST; i++) {
  163. if (lp->port == 0 && free == NULL)
  164. free = lp;
  165. /* Matching port, or the correct slot for ordering */
  166. if (lp->port == port || legacy_port[i] == port) {
  167. free = lp;
  168. break;
  169. }
  170. lp++;
  171. }
  172. if (free == NULL) {
  173. printk(KERN_ERR "pata_legacy: Too many interfaces.\n");
  174. return -1;
  175. }
  176. /* Fill in the entry for later probing */
  177. free->port = port;
  178. free->irq = irq;
  179. free->type = type;
  180. free->private = private;
  181. return 0;
  182. }
  183. /**
  184. * legacy_set_mode - mode setting
  185. * @link: IDE link
  186. * @unused: Device that failed when error is returned
  187. *
  188. * Use a non standard set_mode function. We don't want to be tuned.
  189. *
  190. * The BIOS configured everything. Our job is not to fiddle. Just use
  191. * whatever PIO the hardware is using and leave it at that. When we
  192. * get some kind of nice user driven API for control then we can
  193. * expand on this as per hdparm in the base kernel.
  194. */
  195. static int legacy_set_mode(struct ata_link *link, struct ata_device **unused)
  196. {
  197. struct ata_device *dev;
  198. ata_for_each_dev(dev, link, ENABLED) {
  199. ata_dev_info(dev, "configured for PIO\n");
  200. dev->pio_mode = XFER_PIO_0;
  201. dev->xfer_mode = XFER_PIO_0;
  202. dev->xfer_shift = ATA_SHIFT_PIO;
  203. dev->flags |= ATA_DFLAG_PIO;
  204. }
  205. return 0;
  206. }
  207. static struct scsi_host_template legacy_sht = {
  208. ATA_PIO_SHT(DRV_NAME),
  209. };
  210. static const struct ata_port_operations legacy_base_port_ops = {
  211. .inherits = &ata_sff_port_ops,
  212. .cable_detect = ata_cable_40wire,
  213. };
  214. /*
  215. * These ops are used if the user indicates the hardware
  216. * snoops the commands to decide on the mode and handles the
  217. * mode selection "magically" itself. Several legacy controllers
  218. * do this. The mode range can be set if it is not 0x1F by setting
  219. * pio_mask as well.
  220. */
  221. static struct ata_port_operations simple_port_ops = {
  222. .inherits = &legacy_base_port_ops,
  223. .sff_data_xfer = ata_sff_data_xfer_noirq,
  224. };
  225. static struct ata_port_operations legacy_port_ops = {
  226. .inherits = &legacy_base_port_ops,
  227. .sff_data_xfer = ata_sff_data_xfer_noirq,
  228. .set_mode = legacy_set_mode,
  229. };
  230. /*
  231. * Promise 20230C and 20620 support
  232. *
  233. * This controller supports PIO0 to PIO2. We set PIO timings
  234. * conservatively to allow for 50MHz Vesa Local Bus. The 20620 DMA
  235. * support is weird being DMA to controller and PIO'd to the host
  236. * and not supported.
  237. */
  238. static void pdc20230_set_piomode(struct ata_port *ap, struct ata_device *adev)
  239. {
  240. int tries = 5;
  241. int pio = adev->pio_mode - XFER_PIO_0;
  242. u8 rt;
  243. unsigned long flags;
  244. /* Safe as UP only. Force I/Os to occur together */
  245. local_irq_save(flags);
  246. /* Unlock the control interface */
  247. do {
  248. inb(0x1F5);
  249. outb(inb(0x1F2) | 0x80, 0x1F2);
  250. inb(0x1F2);
  251. inb(0x3F6);
  252. inb(0x3F6);
  253. inb(0x1F2);
  254. inb(0x1F2);
  255. }
  256. while ((inb(0x1F2) & 0x80) && --tries);
  257. local_irq_restore(flags);
  258. outb(inb(0x1F4) & 0x07, 0x1F4);
  259. rt = inb(0x1F3);
  260. rt &= 0x07 << (3 * adev->devno);
  261. if (pio)
  262. rt |= (1 + 3 * pio) << (3 * adev->devno);
  263. udelay(100);
  264. outb(inb(0x1F2) | 0x01, 0x1F2);
  265. udelay(100);
  266. inb(0x1F5);
  267. }
  268. static unsigned int pdc_data_xfer_vlb(struct ata_device *dev,
  269. unsigned char *buf, unsigned int buflen, int rw)
  270. {
  271. int slop = buflen & 3;
  272. struct ata_port *ap = dev->link->ap;
  273. /* 32bit I/O capable *and* we need to write a whole number of dwords */
  274. if (ata_id_has_dword_io(dev->id) && (slop == 0 || slop == 3)
  275. && (ap->pflags & ATA_PFLAG_PIO32)) {
  276. unsigned long flags;
  277. local_irq_save(flags);
  278. /* Perform the 32bit I/O synchronization sequence */
  279. ioread8(ap->ioaddr.nsect_addr);
  280. ioread8(ap->ioaddr.nsect_addr);
  281. ioread8(ap->ioaddr.nsect_addr);
  282. /* Now the data */
  283. if (rw == READ)
  284. ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
  285. else
  286. iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
  287. if (unlikely(slop)) {
  288. __le32 pad;
  289. if (rw == READ) {
  290. pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
  291. memcpy(buf + buflen - slop, &pad, slop);
  292. } else {
  293. memcpy(&pad, buf + buflen - slop, slop);
  294. iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr);
  295. }
  296. buflen += 4 - slop;
  297. }
  298. local_irq_restore(flags);
  299. } else
  300. buflen = ata_sff_data_xfer_noirq(dev, buf, buflen, rw);
  301. return buflen;
  302. }
  303. static struct ata_port_operations pdc20230_port_ops = {
  304. .inherits = &legacy_base_port_ops,
  305. .set_piomode = pdc20230_set_piomode,
  306. .sff_data_xfer = pdc_data_xfer_vlb,
  307. };
  308. /*
  309. * Holtek 6560A support
  310. *
  311. * This controller supports PIO0 to PIO2 (no IORDY even though higher
  312. * timings can be loaded).
  313. */
  314. static void ht6560a_set_piomode(struct ata_port *ap, struct ata_device *adev)
  315. {
  316. u8 active, recover;
  317. struct ata_timing t;
  318. /* Get the timing data in cycles. For now play safe at 50Mhz */
  319. ata_timing_compute(adev, adev->pio_mode, &t, 20000, 1000);
  320. active = clamp_val(t.active, 2, 15);
  321. recover = clamp_val(t.recover, 4, 15);
  322. inb(0x3E6);
  323. inb(0x3E6);
  324. inb(0x3E6);
  325. inb(0x3E6);
  326. iowrite8(recover << 4 | active, ap->ioaddr.device_addr);
  327. ioread8(ap->ioaddr.status_addr);
  328. }
  329. static struct ata_port_operations ht6560a_port_ops = {
  330. .inherits = &legacy_base_port_ops,
  331. .set_piomode = ht6560a_set_piomode,
  332. };
  333. /*
  334. * Holtek 6560B support
  335. *
  336. * This controller supports PIO0 to PIO4. We honour the BIOS/jumper FIFO
  337. * setting unless we see an ATAPI device in which case we force it off.
  338. *
  339. * FIXME: need to implement 2nd channel support.
  340. */
  341. static void ht6560b_set_piomode(struct ata_port *ap, struct ata_device *adev)
  342. {
  343. u8 active, recover;
  344. struct ata_timing t;
  345. /* Get the timing data in cycles. For now play safe at 50Mhz */
  346. ata_timing_compute(adev, adev->pio_mode, &t, 20000, 1000);
  347. active = clamp_val(t.active, 2, 15);
  348. recover = clamp_val(t.recover, 2, 16) & 0x0F;
  349. inb(0x3E6);
  350. inb(0x3E6);
  351. inb(0x3E6);
  352. inb(0x3E6);
  353. iowrite8(recover << 4 | active, ap->ioaddr.device_addr);
  354. if (adev->class != ATA_DEV_ATA) {
  355. u8 rconf = inb(0x3E6);
  356. if (rconf & 0x24) {
  357. rconf &= ~0x24;
  358. outb(rconf, 0x3E6);
  359. }
  360. }
  361. ioread8(ap->ioaddr.status_addr);
  362. }
  363. static struct ata_port_operations ht6560b_port_ops = {
  364. .inherits = &legacy_base_port_ops,
  365. .set_piomode = ht6560b_set_piomode,
  366. };
  367. /*
  368. * Opti core chipset helpers
  369. */
  370. /**
  371. * opti_syscfg - read OPTI chipset configuration
  372. * @reg: Configuration register to read
  373. *
  374. * Returns the value of an OPTI system board configuration register.
  375. */
  376. static u8 opti_syscfg(u8 reg)
  377. {
  378. unsigned long flags;
  379. u8 r;
  380. /* Uniprocessor chipset and must force cycles adjancent */
  381. local_irq_save(flags);
  382. outb(reg, 0x22);
  383. r = inb(0x24);
  384. local_irq_restore(flags);
  385. return r;
  386. }
  387. /*
  388. * Opti 82C611A
  389. *
  390. * This controller supports PIO0 to PIO3.
  391. */
  392. static void opti82c611a_set_piomode(struct ata_port *ap,
  393. struct ata_device *adev)
  394. {
  395. u8 active, recover, setup;
  396. struct ata_timing t;
  397. struct ata_device *pair = ata_dev_pair(adev);
  398. int clock;
  399. int khz[4] = { 50000, 40000, 33000, 25000 };
  400. u8 rc;
  401. /* Enter configuration mode */
  402. ioread16(ap->ioaddr.error_addr);
  403. ioread16(ap->ioaddr.error_addr);
  404. iowrite8(3, ap->ioaddr.nsect_addr);
  405. /* Read VLB clock strapping */
  406. clock = 1000000000 / khz[ioread8(ap->ioaddr.lbah_addr) & 0x03];
  407. /* Get the timing data in cycles */
  408. ata_timing_compute(adev, adev->pio_mode, &t, clock, 1000);
  409. /* Setup timing is shared */
  410. if (pair) {
  411. struct ata_timing tp;
  412. ata_timing_compute(pair, pair->pio_mode, &tp, clock, 1000);
  413. ata_timing_merge(&t, &tp, &t, ATA_TIMING_SETUP);
  414. }
  415. active = clamp_val(t.active, 2, 17) - 2;
  416. recover = clamp_val(t.recover, 1, 16) - 1;
  417. setup = clamp_val(t.setup, 1, 4) - 1;
  418. /* Select the right timing bank for write timing */
  419. rc = ioread8(ap->ioaddr.lbal_addr);
  420. rc &= 0x7F;
  421. rc |= (adev->devno << 7);
  422. iowrite8(rc, ap->ioaddr.lbal_addr);
  423. /* Write the timings */
  424. iowrite8(active << 4 | recover, ap->ioaddr.error_addr);
  425. /* Select the right bank for read timings, also
  426. load the shared timings for address */
  427. rc = ioread8(ap->ioaddr.device_addr);
  428. rc &= 0xC0;
  429. rc |= adev->devno; /* Index select */
  430. rc |= (setup << 4) | 0x04;
  431. iowrite8(rc, ap->ioaddr.device_addr);
  432. /* Load the read timings */
  433. iowrite8(active << 4 | recover, ap->ioaddr.data_addr);
  434. /* Ensure the timing register mode is right */
  435. rc = ioread8(ap->ioaddr.lbal_addr);
  436. rc &= 0x73;
  437. rc |= 0x84;
  438. iowrite8(rc, ap->ioaddr.lbal_addr);
  439. /* Exit command mode */
  440. iowrite8(0x83, ap->ioaddr.nsect_addr);
  441. }
  442. static struct ata_port_operations opti82c611a_port_ops = {
  443. .inherits = &legacy_base_port_ops,
  444. .set_piomode = opti82c611a_set_piomode,
  445. };
  446. /*
  447. * Opti 82C465MV
  448. *
  449. * This controller supports PIO0 to PIO3. Unlike the 611A the MVB
  450. * version is dual channel but doesn't have a lot of unique registers.
  451. */
  452. static void opti82c46x_set_piomode(struct ata_port *ap, struct ata_device *adev)
  453. {
  454. u8 active, recover, setup;
  455. struct ata_timing t;
  456. struct ata_device *pair = ata_dev_pair(adev);
  457. int clock;
  458. int khz[4] = { 50000, 40000, 33000, 25000 };
  459. u8 rc;
  460. u8 sysclk;
  461. /* Get the clock */
  462. sysclk = (opti_syscfg(0xAC) & 0xC0) >> 6; /* BIOS set */
  463. /* Enter configuration mode */
  464. ioread16(ap->ioaddr.error_addr);
  465. ioread16(ap->ioaddr.error_addr);
  466. iowrite8(3, ap->ioaddr.nsect_addr);
  467. /* Read VLB clock strapping */
  468. clock = 1000000000 / khz[sysclk];
  469. /* Get the timing data in cycles */
  470. ata_timing_compute(adev, adev->pio_mode, &t, clock, 1000);
  471. /* Setup timing is shared */
  472. if (pair) {
  473. struct ata_timing tp;
  474. ata_timing_compute(pair, pair->pio_mode, &tp, clock, 1000);
  475. ata_timing_merge(&t, &tp, &t, ATA_TIMING_SETUP);
  476. }
  477. active = clamp_val(t.active, 2, 17) - 2;
  478. recover = clamp_val(t.recover, 1, 16) - 1;
  479. setup = clamp_val(t.setup, 1, 4) - 1;
  480. /* Select the right timing bank for write timing */
  481. rc = ioread8(ap->ioaddr.lbal_addr);
  482. rc &= 0x7F;
  483. rc |= (adev->devno << 7);
  484. iowrite8(rc, ap->ioaddr.lbal_addr);
  485. /* Write the timings */
  486. iowrite8(active << 4 | recover, ap->ioaddr.error_addr);
  487. /* Select the right bank for read timings, also
  488. load the shared timings for address */
  489. rc = ioread8(ap->ioaddr.device_addr);
  490. rc &= 0xC0;
  491. rc |= adev->devno; /* Index select */
  492. rc |= (setup << 4) | 0x04;
  493. iowrite8(rc, ap->ioaddr.device_addr);
  494. /* Load the read timings */
  495. iowrite8(active << 4 | recover, ap->ioaddr.data_addr);
  496. /* Ensure the timing register mode is right */
  497. rc = ioread8(ap->ioaddr.lbal_addr);
  498. rc &= 0x73;
  499. rc |= 0x84;
  500. iowrite8(rc, ap->ioaddr.lbal_addr);
  501. /* Exit command mode */
  502. iowrite8(0x83, ap->ioaddr.nsect_addr);
  503. /* We need to know this for quad device on the MVB */
  504. ap->host->private_data = ap;
  505. }
  506. /**
  507. * opt82c465mv_qc_issue - command issue
  508. * @qc: command pending
  509. *
  510. * Called when the libata layer is about to issue a command. We wrap
  511. * this interface so that we can load the correct ATA timings. The
  512. * MVB has a single set of timing registers and these are shared
  513. * across channels. As there are two registers we really ought to
  514. * track the last two used values as a sort of register window. For
  515. * now we just reload on a channel switch. On the single channel
  516. * setup this condition never fires so we do nothing extra.
  517. *
  518. * FIXME: dual channel needs ->serialize support
  519. */
  520. static unsigned int opti82c46x_qc_issue(struct ata_queued_cmd *qc)
  521. {
  522. struct ata_port *ap = qc->ap;
  523. struct ata_device *adev = qc->dev;
  524. /* If timings are set and for the wrong channel (2nd test is
  525. due to a libata shortcoming and will eventually go I hope) */
  526. if (ap->host->private_data != ap->host
  527. && ap->host->private_data != NULL)
  528. opti82c46x_set_piomode(ap, adev);
  529. return ata_sff_qc_issue(qc);
  530. }
  531. static struct ata_port_operations opti82c46x_port_ops = {
  532. .inherits = &legacy_base_port_ops,
  533. .set_piomode = opti82c46x_set_piomode,
  534. .qc_issue = opti82c46x_qc_issue,
  535. };
  536. /**
  537. * qdi65x0_set_piomode - PIO setup for QDI65x0
  538. * @ap: Port
  539. * @adev: Device
  540. *
  541. * In single channel mode the 6580 has one clock per device and we can
  542. * avoid the requirement to clock switch. We also have to load the timing
  543. * into the right clock according to whether we are master or slave.
  544. *
  545. * In dual channel mode the 6580 has one clock per channel and we have
  546. * to software clockswitch in qc_issue.
  547. */
  548. static void qdi65x0_set_piomode(struct ata_port *ap, struct ata_device *adev)
  549. {
  550. struct ata_timing t;
  551. struct legacy_data *ld_qdi = ap->host->private_data;
  552. int active, recovery;
  553. u8 timing;
  554. /* Get the timing data in cycles */
  555. ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000);
  556. if (ld_qdi->fast) {
  557. active = 8 - clamp_val(t.active, 1, 8);
  558. recovery = 18 - clamp_val(t.recover, 3, 18);
  559. } else {
  560. active = 9 - clamp_val(t.active, 2, 9);
  561. recovery = 15 - clamp_val(t.recover, 0, 15);
  562. }
  563. timing = (recovery << 4) | active | 0x08;
  564. ld_qdi->clock[adev->devno] = timing;
  565. if (ld_qdi->type == QDI6580)
  566. outb(timing, ld_qdi->timing + 2 * adev->devno);
  567. else
  568. outb(timing, ld_qdi->timing + 2 * ap->port_no);
  569. /* Clear the FIFO */
  570. if (ld_qdi->type != QDI6500 && adev->class != ATA_DEV_ATA)
  571. outb(0x5F, (ld_qdi->timing & 0xFFF0) + 3);
  572. }
  573. /**
  574. * qdi_qc_issue - command issue
  575. * @qc: command pending
  576. *
  577. * Called when the libata layer is about to issue a command. We wrap
  578. * this interface so that we can load the correct ATA timings.
  579. */
  580. static unsigned int qdi_qc_issue(struct ata_queued_cmd *qc)
  581. {
  582. struct ata_port *ap = qc->ap;
  583. struct ata_device *adev = qc->dev;
  584. struct legacy_data *ld_qdi = ap->host->private_data;
  585. if (ld_qdi->clock[adev->devno] != ld_qdi->last) {
  586. if (adev->pio_mode) {
  587. ld_qdi->last = ld_qdi->clock[adev->devno];
  588. outb(ld_qdi->clock[adev->devno], ld_qdi->timing +
  589. 2 * ap->port_no);
  590. }
  591. }
  592. return ata_sff_qc_issue(qc);
  593. }
  594. static unsigned int vlb32_data_xfer(struct ata_device *adev, unsigned char *buf,
  595. unsigned int buflen, int rw)
  596. {
  597. struct ata_port *ap = adev->link->ap;
  598. int slop = buflen & 3;
  599. if (ata_id_has_dword_io(adev->id) && (slop == 0 || slop == 3)
  600. && (ap->pflags & ATA_PFLAG_PIO32)) {
  601. if (rw == WRITE)
  602. iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
  603. else
  604. ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
  605. if (unlikely(slop)) {
  606. __le32 pad;
  607. if (rw == WRITE) {
  608. memcpy(&pad, buf + buflen - slop, slop);
  609. iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr);
  610. } else {
  611. pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
  612. memcpy(buf + buflen - slop, &pad, slop);
  613. }
  614. }
  615. return (buflen + 3) & ~3;
  616. } else
  617. return ata_sff_data_xfer(adev, buf, buflen, rw);
  618. }
  619. static int qdi_port(struct platform_device *dev,
  620. struct legacy_probe *lp, struct legacy_data *ld)
  621. {
  622. if (devm_request_region(&dev->dev, lp->private, 4, "qdi") == NULL)
  623. return -EBUSY;
  624. ld->timing = lp->private;
  625. return 0;
  626. }
  627. static struct ata_port_operations qdi6500_port_ops = {
  628. .inherits = &legacy_base_port_ops,
  629. .set_piomode = qdi65x0_set_piomode,
  630. .qc_issue = qdi_qc_issue,
  631. .sff_data_xfer = vlb32_data_xfer,
  632. };
  633. static struct ata_port_operations qdi6580_port_ops = {
  634. .inherits = &legacy_base_port_ops,
  635. .set_piomode = qdi65x0_set_piomode,
  636. .sff_data_xfer = vlb32_data_xfer,
  637. };
  638. static struct ata_port_operations qdi6580dp_port_ops = {
  639. .inherits = &legacy_base_port_ops,
  640. .set_piomode = qdi65x0_set_piomode,
  641. .qc_issue = qdi_qc_issue,
  642. .sff_data_xfer = vlb32_data_xfer,
  643. };
  644. static DEFINE_SPINLOCK(winbond_lock);
  645. static void winbond_writecfg(unsigned long port, u8 reg, u8 val)
  646. {
  647. unsigned long flags;
  648. spin_lock_irqsave(&winbond_lock, flags);
  649. outb(reg, port + 0x01);
  650. outb(val, port + 0x02);
  651. spin_unlock_irqrestore(&winbond_lock, flags);
  652. }
  653. static u8 winbond_readcfg(unsigned long port, u8 reg)
  654. {
  655. u8 val;
  656. unsigned long flags;
  657. spin_lock_irqsave(&winbond_lock, flags);
  658. outb(reg, port + 0x01);
  659. val = inb(port + 0x02);
  660. spin_unlock_irqrestore(&winbond_lock, flags);
  661. return val;
  662. }
  663. static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev)
  664. {
  665. struct ata_timing t;
  666. struct legacy_data *ld_winbond = ap->host->private_data;
  667. int active, recovery;
  668. u8 reg;
  669. int timing = 0x88 + (ap->port_no * 4) + (adev->devno * 2);
  670. reg = winbond_readcfg(ld_winbond->timing, 0x81);
  671. /* Get the timing data in cycles */
  672. if (reg & 0x40) /* Fast VLB bus, assume 50MHz */
  673. ata_timing_compute(adev, adev->pio_mode, &t, 20000, 1000);
  674. else
  675. ata_timing_compute(adev, adev->pio_mode, &t, 30303, 1000);
  676. active = (clamp_val(t.active, 3, 17) - 1) & 0x0F;
  677. recovery = (clamp_val(t.recover, 1, 15) + 1) & 0x0F;
  678. timing = (active << 4) | recovery;
  679. winbond_writecfg(ld_winbond->timing, timing, reg);
  680. /* Load the setup timing */
  681. reg = 0x35;
  682. if (adev->class != ATA_DEV_ATA)
  683. reg |= 0x08; /* FIFO off */
  684. if (!ata_pio_need_iordy(adev))
  685. reg |= 0x02; /* IORDY off */
  686. reg |= (clamp_val(t.setup, 0, 3) << 6);
  687. winbond_writecfg(ld_winbond->timing, timing + 1, reg);
  688. }
  689. static int winbond_port(struct platform_device *dev,
  690. struct legacy_probe *lp, struct legacy_data *ld)
  691. {
  692. if (devm_request_region(&dev->dev, lp->private, 4, "winbond") == NULL)
  693. return -EBUSY;
  694. ld->timing = lp->private;
  695. return 0;
  696. }
  697. static struct ata_port_operations winbond_port_ops = {
  698. .inherits = &legacy_base_port_ops,
  699. .set_piomode = winbond_set_piomode,
  700. .sff_data_xfer = vlb32_data_xfer,
  701. };
  702. static struct legacy_controller controllers[] = {
  703. {"BIOS", &legacy_port_ops, ATA_PIO4,
  704. ATA_FLAG_NO_IORDY, 0, NULL },
  705. {"Snooping", &simple_port_ops, ATA_PIO4,
  706. 0, 0, NULL },
  707. {"PDC20230", &pdc20230_port_ops, ATA_PIO2,
  708. ATA_FLAG_NO_IORDY,
  709. ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE, NULL },
  710. {"HT6560A", &ht6560a_port_ops, ATA_PIO2,
  711. ATA_FLAG_NO_IORDY, 0, NULL },
  712. {"HT6560B", &ht6560b_port_ops, ATA_PIO4,
  713. ATA_FLAG_NO_IORDY, 0, NULL },
  714. {"OPTI82C611A", &opti82c611a_port_ops, ATA_PIO3,
  715. 0, 0, NULL },
  716. {"OPTI82C46X", &opti82c46x_port_ops, ATA_PIO3,
  717. 0, 0, NULL },
  718. {"QDI6500", &qdi6500_port_ops, ATA_PIO2,
  719. ATA_FLAG_NO_IORDY,
  720. ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE, qdi_port },
  721. {"QDI6580", &qdi6580_port_ops, ATA_PIO4,
  722. 0, ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE, qdi_port },
  723. {"QDI6580DP", &qdi6580dp_port_ops, ATA_PIO4,
  724. 0, ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE, qdi_port },
  725. {"W83759A", &winbond_port_ops, ATA_PIO4,
  726. 0, ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE,
  727. winbond_port }
  728. };
  729. /**
  730. * probe_chip_type - Discover controller
  731. * @probe: Probe entry to check
  732. *
  733. * Probe an ATA port and identify the type of controller. We don't
  734. * check if the controller appears to be driveless at this point.
  735. */
  736. static __init int probe_chip_type(struct legacy_probe *probe)
  737. {
  738. int mask = 1 << probe->slot;
  739. if (winbond && (probe->port == 0x1F0 || probe->port == 0x170)) {
  740. u8 reg = winbond_readcfg(winbond, 0x81);
  741. reg |= 0x80; /* jumpered mode off */
  742. winbond_writecfg(winbond, 0x81, reg);
  743. reg = winbond_readcfg(winbond, 0x83);
  744. reg |= 0xF0; /* local control */
  745. winbond_writecfg(winbond, 0x83, reg);
  746. reg = winbond_readcfg(winbond, 0x85);
  747. reg |= 0xF0; /* programmable timing */
  748. winbond_writecfg(winbond, 0x85, reg);
  749. reg = winbond_readcfg(winbond, 0x81);
  750. if (reg & mask)
  751. return W83759A;
  752. }
  753. if (probe->port == 0x1F0) {
  754. unsigned long flags;
  755. local_irq_save(flags);
  756. /* Probes */
  757. outb(inb(0x1F2) | 0x80, 0x1F2);
  758. inb(0x1F5);
  759. inb(0x1F2);
  760. inb(0x3F6);
  761. inb(0x3F6);
  762. inb(0x1F2);
  763. inb(0x1F2);
  764. if ((inb(0x1F2) & 0x80) == 0) {
  765. /* PDC20230c or 20630 ? */
  766. printk(KERN_INFO "PDC20230-C/20630 VLB ATA controller"
  767. " detected.\n");
  768. udelay(100);
  769. inb(0x1F5);
  770. local_irq_restore(flags);
  771. return PDC20230;
  772. } else {
  773. outb(0x55, 0x1F2);
  774. inb(0x1F2);
  775. inb(0x1F2);
  776. if (inb(0x1F2) == 0x00)
  777. printk(KERN_INFO "PDC20230-B VLB ATA "
  778. "controller detected.\n");
  779. local_irq_restore(flags);
  780. return BIOS;
  781. }
  782. }
  783. if (ht6560a & mask)
  784. return HT6560A;
  785. if (ht6560b & mask)
  786. return HT6560B;
  787. if (opti82c611a & mask)
  788. return OPTI611A;
  789. if (opti82c46x & mask)
  790. return OPTI46X;
  791. if (autospeed & mask)
  792. return SNOOP;
  793. return BIOS;
  794. }
  795. /**
  796. * legacy_init_one - attach a legacy interface
  797. * @pl: probe record
  798. *
  799. * Register an ISA bus IDE interface. Such interfaces are PIO and we
  800. * assume do not support IRQ sharing.
  801. */
  802. static __init int legacy_init_one(struct legacy_probe *probe)
  803. {
  804. struct legacy_controller *controller = &controllers[probe->type];
  805. int pio_modes = controller->pio_mask;
  806. unsigned long io = probe->port;
  807. u32 mask = (1 << probe->slot);
  808. struct ata_port_operations *ops = controller->ops;
  809. struct legacy_data *ld = &legacy_data[probe->slot];
  810. struct ata_host *host = NULL;
  811. struct ata_port *ap;
  812. struct platform_device *pdev;
  813. struct ata_device *dev;
  814. void __iomem *io_addr, *ctrl_addr;
  815. u32 iordy = (iordy_mask & mask) ? 0: ATA_FLAG_NO_IORDY;
  816. int ret;
  817. iordy |= controller->flags;
  818. pdev = platform_device_register_simple(DRV_NAME, probe->slot, NULL, 0);
  819. if (IS_ERR(pdev))
  820. return PTR_ERR(pdev);
  821. ret = -EBUSY;
  822. if (devm_request_region(&pdev->dev, io, 8, "pata_legacy") == NULL ||
  823. devm_request_region(&pdev->dev, io + 0x0206, 1,
  824. "pata_legacy") == NULL)
  825. goto fail;
  826. ret = -ENOMEM;
  827. io_addr = devm_ioport_map(&pdev->dev, io, 8);
  828. ctrl_addr = devm_ioport_map(&pdev->dev, io + 0x0206, 1);
  829. if (!io_addr || !ctrl_addr)
  830. goto fail;
  831. ld->type = probe->type;
  832. if (controller->setup)
  833. if (controller->setup(pdev, probe, ld) < 0)
  834. goto fail;
  835. host = ata_host_alloc(&pdev->dev, 1);
  836. if (!host)
  837. goto fail;
  838. ap = host->ports[0];
  839. ap->ops = ops;
  840. ap->pio_mask = pio_modes;
  841. ap->flags |= ATA_FLAG_SLAVE_POSS | iordy;
  842. ap->pflags |= controller->pflags;
  843. ap->ioaddr.cmd_addr = io_addr;
  844. ap->ioaddr.altstatus_addr = ctrl_addr;
  845. ap->ioaddr.ctl_addr = ctrl_addr;
  846. ata_sff_std_ports(&ap->ioaddr);
  847. ap->host->private_data = ld;
  848. ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", io, io + 0x0206);
  849. ret = ata_host_activate(host, probe->irq, ata_sff_interrupt, 0,
  850. &legacy_sht);
  851. if (ret)
  852. goto fail;
  853. async_synchronize_full();
  854. ld->platform_dev = pdev;
  855. /* Nothing found means we drop the port as its probably not there */
  856. ret = -ENODEV;
  857. ata_for_each_dev(dev, &ap->link, ALL) {
  858. if (!ata_dev_absent(dev)) {
  859. legacy_host[probe->slot] = host;
  860. ld->platform_dev = pdev;
  861. return 0;
  862. }
  863. }
  864. ata_host_detach(host);
  865. fail:
  866. platform_device_unregister(pdev);
  867. return ret;
  868. }
  869. /**
  870. * legacy_check_special_cases - ATA special cases
  871. * @p: PCI device to check
  872. * @master: set this if we find an ATA master
  873. * @master: set this if we find an ATA secondary
  874. *
  875. * A small number of vendors implemented early PCI ATA interfaces
  876. * on bridge logic without the ATA interface being PCI visible.
  877. * Where we have a matching PCI driver we must skip the relevant
  878. * device here. If we don't know about it then the legacy driver
  879. * is the right driver anyway.
  880. */
  881. static void __init legacy_check_special_cases(struct pci_dev *p, int *primary,
  882. int *secondary)
  883. {
  884. /* Cyrix CS5510 pre SFF MWDMA ATA on the bridge */
  885. if (p->vendor == 0x1078 && p->device == 0x0000) {
  886. *primary = *secondary = 1;
  887. return;
  888. }
  889. /* Cyrix CS5520 pre SFF MWDMA ATA on the bridge */
  890. if (p->vendor == 0x1078 && p->device == 0x0002) {
  891. *primary = *secondary = 1;
  892. return;
  893. }
  894. /* Intel MPIIX - PIO ATA on non PCI side of bridge */
  895. if (p->vendor == 0x8086 && p->device == 0x1234) {
  896. u16 r;
  897. pci_read_config_word(p, 0x6C, &r);
  898. if (r & 0x8000) {
  899. /* ATA port enabled */
  900. if (r & 0x4000)
  901. *secondary = 1;
  902. else
  903. *primary = 1;
  904. }
  905. return;
  906. }
  907. }
  908. static __init void probe_opti_vlb(void)
  909. {
  910. /* If an OPTI 82C46X is present find out where the channels are */
  911. static const char *optis[4] = {
  912. "3/463MV", "5MV",
  913. "5MVA", "5MVB"
  914. };
  915. u8 chans = 1;
  916. u8 ctrl = (opti_syscfg(0x30) & 0xC0) >> 6;
  917. opti82c46x = 3; /* Assume master and slave first */
  918. printk(KERN_INFO DRV_NAME ": Opti 82C46%s chipset support.\n",
  919. optis[ctrl]);
  920. if (ctrl == 3)
  921. chans = (opti_syscfg(0x3F) & 0x20) ? 2 : 1;
  922. ctrl = opti_syscfg(0xAC);
  923. /* Check enabled and this port is the 465MV port. On the
  924. MVB we may have two channels */
  925. if (ctrl & 8) {
  926. if (chans == 2) {
  927. legacy_probe_add(0x1F0, 14, OPTI46X, 0);
  928. legacy_probe_add(0x170, 15, OPTI46X, 0);
  929. }
  930. if (ctrl & 4)
  931. legacy_probe_add(0x170, 15, OPTI46X, 0);
  932. else
  933. legacy_probe_add(0x1F0, 14, OPTI46X, 0);
  934. } else
  935. legacy_probe_add(0x1F0, 14, OPTI46X, 0);
  936. }
  937. static __init void qdi65_identify_port(u8 r, u8 res, unsigned long port)
  938. {
  939. static const unsigned long ide_port[2] = { 0x170, 0x1F0 };
  940. /* Check card type */
  941. if ((r & 0xF0) == 0xC0) {
  942. /* QD6500: single channel */
  943. if (r & 8)
  944. /* Disabled ? */
  945. return;
  946. legacy_probe_add(ide_port[r & 0x01], 14 + (r & 0x01),
  947. QDI6500, port);
  948. }
  949. if (((r & 0xF0) == 0xA0) || (r & 0xF0) == 0x50) {
  950. /* QD6580: dual channel */
  951. if (!request_region(port + 2 , 2, "pata_qdi")) {
  952. release_region(port, 2);
  953. return;
  954. }
  955. res = inb(port + 3);
  956. /* Single channel mode ? */
  957. if (res & 1)
  958. legacy_probe_add(ide_port[r & 0x01], 14 + (r & 0x01),
  959. QDI6580, port);
  960. else { /* Dual channel mode */
  961. legacy_probe_add(0x1F0, 14, QDI6580DP, port);
  962. /* port + 0x02, r & 0x04 */
  963. legacy_probe_add(0x170, 15, QDI6580DP, port + 2);
  964. }
  965. release_region(port + 2, 2);
  966. }
  967. }
  968. static __init void probe_qdi_vlb(void)
  969. {
  970. unsigned long flags;
  971. static const unsigned long qd_port[2] = { 0x30, 0xB0 };
  972. int i;
  973. /*
  974. * Check each possible QD65xx base address
  975. */
  976. for (i = 0; i < 2; i++) {
  977. unsigned long port = qd_port[i];
  978. u8 r, res;
  979. if (request_region(port, 2, "pata_qdi")) {
  980. /* Check for a card */
  981. local_irq_save(flags);
  982. /* I have no h/w that needs this delay but it
  983. is present in the historic code */
  984. r = inb(port);
  985. udelay(1);
  986. outb(0x19, port);
  987. udelay(1);
  988. res = inb(port);
  989. udelay(1);
  990. outb(r, port);
  991. udelay(1);
  992. local_irq_restore(flags);
  993. /* Fail */
  994. if (res == 0x19) {
  995. release_region(port, 2);
  996. continue;
  997. }
  998. /* Passes the presence test */
  999. r = inb(port + 1);
  1000. udelay(1);
  1001. /* Check port agrees with port set */
  1002. if ((r & 2) >> 1 == i)
  1003. qdi65_identify_port(r, res, port);
  1004. release_region(port, 2);
  1005. }
  1006. }
  1007. }
  1008. /**
  1009. * legacy_init - attach legacy interfaces
  1010. *
  1011. * Attach legacy IDE interfaces by scanning the usual IRQ/port suspects.
  1012. * Right now we do not scan the ide0 and ide1 address but should do so
  1013. * for non PCI systems or systems with no PCI IDE legacy mode devices.
  1014. * If you fix that note there are special cases to consider like VLB
  1015. * drivers and CS5510/20.
  1016. */
  1017. static __init int legacy_init(void)
  1018. {
  1019. int i;
  1020. int ct = 0;
  1021. int primary = 0;
  1022. int secondary = 0;
  1023. int pci_present = 0;
  1024. struct legacy_probe *pl = &probe_list[0];
  1025. int slot = 0;
  1026. struct pci_dev *p = NULL;
  1027. for_each_pci_dev(p) {
  1028. int r;
  1029. /* Check for any overlap of the system ATA mappings. Native
  1030. mode controllers stuck on these addresses or some devices
  1031. in 'raid' mode won't be found by the storage class test */
  1032. for (r = 0; r < 6; r++) {
  1033. if (pci_resource_start(p, r) == 0x1f0)
  1034. primary = 1;
  1035. if (pci_resource_start(p, r) == 0x170)
  1036. secondary = 1;
  1037. }
  1038. /* Check for special cases */
  1039. legacy_check_special_cases(p, &primary, &secondary);
  1040. /* If PCI bus is present then don't probe for tertiary
  1041. legacy ports */
  1042. pci_present = 1;
  1043. }
  1044. if (winbond == 1)
  1045. winbond = 0x130; /* Default port, alt is 1B0 */
  1046. if (primary == 0 || all)
  1047. legacy_probe_add(0x1F0, 14, UNKNOWN, 0);
  1048. if (secondary == 0 || all)
  1049. legacy_probe_add(0x170, 15, UNKNOWN, 0);
  1050. if (probe_all || !pci_present) {
  1051. /* ISA/VLB extra ports */
  1052. legacy_probe_add(0x1E8, 11, UNKNOWN, 0);
  1053. legacy_probe_add(0x168, 10, UNKNOWN, 0);
  1054. legacy_probe_add(0x1E0, 8, UNKNOWN, 0);
  1055. legacy_probe_add(0x160, 12, UNKNOWN, 0);
  1056. }
  1057. if (opti82c46x)
  1058. probe_opti_vlb();
  1059. if (qdi)
  1060. probe_qdi_vlb();
  1061. for (i = 0; i < NR_HOST; i++, pl++) {
  1062. if (pl->port == 0)
  1063. continue;
  1064. if (pl->type == UNKNOWN)
  1065. pl->type = probe_chip_type(pl);
  1066. pl->slot = slot++;
  1067. if (legacy_init_one(pl) == 0)
  1068. ct++;
  1069. }
  1070. if (ct != 0)
  1071. return 0;
  1072. return -ENODEV;
  1073. }
  1074. static __exit void legacy_exit(void)
  1075. {
  1076. int i;
  1077. for (i = 0; i < nr_legacy_host; i++) {
  1078. struct legacy_data *ld = &legacy_data[i];
  1079. ata_host_detach(legacy_host[i]);
  1080. platform_device_unregister(ld->platform_dev);
  1081. }
  1082. }
  1083. MODULE_AUTHOR("Alan Cox");
  1084. MODULE_DESCRIPTION("low-level driver for legacy ATA");
  1085. MODULE_LICENSE("GPL");
  1086. MODULE_VERSION(DRV_VERSION);
  1087. MODULE_ALIAS("pata_qdi");
  1088. MODULE_ALIAS("pata_winbond");
  1089. module_param(probe_all, int, 0);
  1090. module_param(autospeed, int, 0);
  1091. module_param(ht6560a, int, 0);
  1092. module_param(ht6560b, int, 0);
  1093. module_param(opti82c611a, int, 0);
  1094. module_param(opti82c46x, int, 0);
  1095. module_param(qdi, int, 0);
  1096. module_param(winbond, int, 0);
  1097. module_param(pio_mask, int, 0);
  1098. module_param(iordy_mask, int, 0);
  1099. module_init(legacy_init);
  1100. module_exit(legacy_exit);