pata_scc.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188
  1. /*
  2. * Support for IDE interfaces on Celleb platform
  3. *
  4. * (C) Copyright 2006 TOSHIBA CORPORATION
  5. *
  6. * This code is based on drivers/ata/ata_piix.c:
  7. * Copyright 2003-2005 Red Hat Inc
  8. * Copyright 2003-2005 Jeff Garzik
  9. * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer
  10. * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
  11. * Copyright (C) 2003 Red Hat Inc
  12. *
  13. * and drivers/ata/ahci.c:
  14. * Copyright 2004-2005 Red Hat, Inc.
  15. *
  16. * and drivers/ata/libata-core.c:
  17. * Copyright 2003-2004 Red Hat, Inc. All rights reserved.
  18. * Copyright 2003-2004 Jeff Garzik
  19. *
  20. * This program is free software; you can redistribute it and/or modify
  21. * it under the terms of the GNU General Public License as published by
  22. * the Free Software Foundation; either version 2 of the License, or
  23. * (at your option) any later version.
  24. *
  25. * This program is distributed in the hope that it will be useful,
  26. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. * GNU General Public License for more details.
  29. *
  30. * You should have received a copy of the GNU General Public License along
  31. * with this program; if not, write to the Free Software Foundation, Inc.,
  32. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  33. */
  34. #include <linux/kernel.h>
  35. #include <linux/module.h>
  36. #include <linux/pci.h>
  37. #include <linux/init.h>
  38. #include <linux/blkdev.h>
  39. #include <linux/delay.h>
  40. #include <linux/device.h>
  41. #include <scsi/scsi_host.h>
  42. #include <linux/libata.h>
  43. #define DRV_NAME "pata_scc"
  44. #define DRV_VERSION "0.3"
  45. #define PCI_DEVICE_ID_TOSHIBA_SCC_ATA 0x01b4
  46. /* PCI BARs */
  47. #define SCC_CTRL_BAR 0
  48. #define SCC_BMID_BAR 1
  49. /* offset of CTRL registers */
  50. #define SCC_CTL_PIOSHT 0x000
  51. #define SCC_CTL_PIOCT 0x004
  52. #define SCC_CTL_MDMACT 0x008
  53. #define SCC_CTL_MCRCST 0x00C
  54. #define SCC_CTL_SDMACT 0x010
  55. #define SCC_CTL_SCRCST 0x014
  56. #define SCC_CTL_UDENVT 0x018
  57. #define SCC_CTL_TDVHSEL 0x020
  58. #define SCC_CTL_MODEREG 0x024
  59. #define SCC_CTL_ECMODE 0xF00
  60. #define SCC_CTL_MAEA0 0xF50
  61. #define SCC_CTL_MAEC0 0xF54
  62. #define SCC_CTL_CCKCTRL 0xFF0
  63. /* offset of BMID registers */
  64. #define SCC_DMA_CMD 0x000
  65. #define SCC_DMA_STATUS 0x004
  66. #define SCC_DMA_TABLE_OFS 0x008
  67. #define SCC_DMA_INTMASK 0x010
  68. #define SCC_DMA_INTST 0x014
  69. #define SCC_DMA_PTERADD 0x018
  70. #define SCC_REG_CMD_ADDR 0x020
  71. #define SCC_REG_DATA 0x000
  72. #define SCC_REG_ERR 0x004
  73. #define SCC_REG_FEATURE 0x004
  74. #define SCC_REG_NSECT 0x008
  75. #define SCC_REG_LBAL 0x00C
  76. #define SCC_REG_LBAM 0x010
  77. #define SCC_REG_LBAH 0x014
  78. #define SCC_REG_DEVICE 0x018
  79. #define SCC_REG_STATUS 0x01C
  80. #define SCC_REG_CMD 0x01C
  81. #define SCC_REG_ALTSTATUS 0x020
  82. /* register value */
  83. #define TDVHSEL_MASTER 0x00000001
  84. #define TDVHSEL_SLAVE 0x00000004
  85. #define MODE_JCUSFEN 0x00000080
  86. #define ECMODE_VALUE 0x01
  87. #define CCKCTRL_ATARESET 0x00040000
  88. #define CCKCTRL_BUFCNT 0x00020000
  89. #define CCKCTRL_CRST 0x00010000
  90. #define CCKCTRL_OCLKEN 0x00000100
  91. #define CCKCTRL_ATACLKOEN 0x00000002
  92. #define CCKCTRL_LCLKEN 0x00000001
  93. #define QCHCD_IOS_SS 0x00000001
  94. #define QCHSD_STPDIAG 0x00020000
  95. #define INTMASK_MSK 0xD1000012
  96. #define INTSTS_SERROR 0x80000000
  97. #define INTSTS_PRERR 0x40000000
  98. #define INTSTS_RERR 0x10000000
  99. #define INTSTS_ICERR 0x01000000
  100. #define INTSTS_BMSINT 0x00000010
  101. #define INTSTS_BMHE 0x00000008
  102. #define INTSTS_IOIRQS 0x00000004
  103. #define INTSTS_INTRQ 0x00000002
  104. #define INTSTS_ACTEINT 0x00000001
  105. /* PIO transfer mode table */
  106. /* JCHST */
  107. static const unsigned long JCHSTtbl[2][7] = {
  108. {0x0E, 0x05, 0x02, 0x03, 0x02, 0x00, 0x00}, /* 100MHz */
  109. {0x13, 0x07, 0x04, 0x04, 0x03, 0x00, 0x00} /* 133MHz */
  110. };
  111. /* JCHHT */
  112. static const unsigned long JCHHTtbl[2][7] = {
  113. {0x0E, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00}, /* 100MHz */
  114. {0x13, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00} /* 133MHz */
  115. };
  116. /* JCHCT */
  117. static const unsigned long JCHCTtbl[2][7] = {
  118. {0x1D, 0x1D, 0x1C, 0x0B, 0x06, 0x00, 0x00}, /* 100MHz */
  119. {0x27, 0x26, 0x26, 0x0E, 0x09, 0x00, 0x00} /* 133MHz */
  120. };
  121. /* DMA transfer mode table */
  122. /* JCHDCTM/JCHDCTS */
  123. static const unsigned long JCHDCTxtbl[2][7] = {
  124. {0x0A, 0x06, 0x04, 0x03, 0x01, 0x00, 0x00}, /* 100MHz */
  125. {0x0E, 0x09, 0x06, 0x04, 0x02, 0x01, 0x00} /* 133MHz */
  126. };
  127. /* JCSTWTM/JCSTWTS */
  128. static const unsigned long JCSTWTxtbl[2][7] = {
  129. {0x06, 0x04, 0x03, 0x02, 0x02, 0x02, 0x00}, /* 100MHz */
  130. {0x09, 0x06, 0x04, 0x02, 0x02, 0x02, 0x02} /* 133MHz */
  131. };
  132. /* JCTSS */
  133. static const unsigned long JCTSStbl[2][7] = {
  134. {0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00}, /* 100MHz */
  135. {0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05} /* 133MHz */
  136. };
  137. /* JCENVT */
  138. static const unsigned long JCENVTtbl[2][7] = {
  139. {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00}, /* 100MHz */
  140. {0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02} /* 133MHz */
  141. };
  142. /* JCACTSELS/JCACTSELM */
  143. static const unsigned long JCACTSELtbl[2][7] = {
  144. {0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00}, /* 100MHz */
  145. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01} /* 133MHz */
  146. };
  147. static const struct pci_device_id scc_pci_tbl[] = {
  148. {PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_SCC_ATA,
  149. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  150. { } /* terminate list */
  151. };
  152. /**
  153. * scc_set_piomode - Initialize host controller PATA PIO timings
  154. * @ap: Port whose timings we are configuring
  155. * @adev: um
  156. *
  157. * Set PIO mode for device.
  158. *
  159. * LOCKING:
  160. * None (inherited from caller).
  161. */
  162. static void scc_set_piomode (struct ata_port *ap, struct ata_device *adev)
  163. {
  164. unsigned int pio = adev->pio_mode - XFER_PIO_0;
  165. void __iomem *ctrl_base = ap->host->iomap[SCC_CTRL_BAR];
  166. void __iomem *cckctrl_port = ctrl_base + SCC_CTL_CCKCTRL;
  167. void __iomem *piosht_port = ctrl_base + SCC_CTL_PIOSHT;
  168. void __iomem *pioct_port = ctrl_base + SCC_CTL_PIOCT;
  169. unsigned long reg;
  170. int offset;
  171. reg = in_be32(cckctrl_port);
  172. if (reg & CCKCTRL_ATACLKOEN)
  173. offset = 1; /* 133MHz */
  174. else
  175. offset = 0; /* 100MHz */
  176. reg = JCHSTtbl[offset][pio] << 16 | JCHHTtbl[offset][pio];
  177. out_be32(piosht_port, reg);
  178. reg = JCHCTtbl[offset][pio];
  179. out_be32(pioct_port, reg);
  180. }
  181. /**
  182. * scc_set_dmamode - Initialize host controller PATA DMA timings
  183. * @ap: Port whose timings we are configuring
  184. * @adev: um
  185. *
  186. * Set UDMA mode for device.
  187. *
  188. * LOCKING:
  189. * None (inherited from caller).
  190. */
  191. static void scc_set_dmamode (struct ata_port *ap, struct ata_device *adev)
  192. {
  193. unsigned int udma = adev->dma_mode;
  194. unsigned int is_slave = (adev->devno != 0);
  195. u8 speed = udma;
  196. void __iomem *ctrl_base = ap->host->iomap[SCC_CTRL_BAR];
  197. void __iomem *cckctrl_port = ctrl_base + SCC_CTL_CCKCTRL;
  198. void __iomem *mdmact_port = ctrl_base + SCC_CTL_MDMACT;
  199. void __iomem *mcrcst_port = ctrl_base + SCC_CTL_MCRCST;
  200. void __iomem *sdmact_port = ctrl_base + SCC_CTL_SDMACT;
  201. void __iomem *scrcst_port = ctrl_base + SCC_CTL_SCRCST;
  202. void __iomem *udenvt_port = ctrl_base + SCC_CTL_UDENVT;
  203. void __iomem *tdvhsel_port = ctrl_base + SCC_CTL_TDVHSEL;
  204. int offset, idx;
  205. if (in_be32(cckctrl_port) & CCKCTRL_ATACLKOEN)
  206. offset = 1; /* 133MHz */
  207. else
  208. offset = 0; /* 100MHz */
  209. if (speed >= XFER_UDMA_0)
  210. idx = speed - XFER_UDMA_0;
  211. else
  212. return;
  213. if (is_slave) {
  214. out_be32(sdmact_port, JCHDCTxtbl[offset][idx]);
  215. out_be32(scrcst_port, JCSTWTxtbl[offset][idx]);
  216. out_be32(tdvhsel_port,
  217. (in_be32(tdvhsel_port) & ~TDVHSEL_SLAVE) | (JCACTSELtbl[offset][idx] << 2));
  218. } else {
  219. out_be32(mdmact_port, JCHDCTxtbl[offset][idx]);
  220. out_be32(mcrcst_port, JCSTWTxtbl[offset][idx]);
  221. out_be32(tdvhsel_port,
  222. (in_be32(tdvhsel_port) & ~TDVHSEL_MASTER) | JCACTSELtbl[offset][idx]);
  223. }
  224. out_be32(udenvt_port,
  225. JCTSStbl[offset][idx] << 16 | JCENVTtbl[offset][idx]);
  226. }
  227. unsigned long scc_mode_filter(struct ata_device *adev, unsigned long mask)
  228. {
  229. /* errata A308 workaround: limit ATAPI UDMA mode to UDMA4 */
  230. if (adev->class == ATA_DEV_ATAPI &&
  231. (mask & (0xE0 << ATA_SHIFT_UDMA))) {
  232. printk(KERN_INFO "%s: limit ATAPI UDMA to UDMA4\n", DRV_NAME);
  233. mask &= ~(0xE0 << ATA_SHIFT_UDMA);
  234. }
  235. return ata_bmdma_mode_filter(adev, mask);
  236. }
  237. /**
  238. * scc_tf_load - send taskfile registers to host controller
  239. * @ap: Port to which output is sent
  240. * @tf: ATA taskfile register set
  241. *
  242. * Note: Original code is ata_sff_tf_load().
  243. */
  244. static void scc_tf_load (struct ata_port *ap, const struct ata_taskfile *tf)
  245. {
  246. struct ata_ioports *ioaddr = &ap->ioaddr;
  247. unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
  248. if (tf->ctl != ap->last_ctl) {
  249. out_be32(ioaddr->ctl_addr, tf->ctl);
  250. ap->last_ctl = tf->ctl;
  251. ata_wait_idle(ap);
  252. }
  253. if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
  254. out_be32(ioaddr->feature_addr, tf->hob_feature);
  255. out_be32(ioaddr->nsect_addr, tf->hob_nsect);
  256. out_be32(ioaddr->lbal_addr, tf->hob_lbal);
  257. out_be32(ioaddr->lbam_addr, tf->hob_lbam);
  258. out_be32(ioaddr->lbah_addr, tf->hob_lbah);
  259. VPRINTK("hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n",
  260. tf->hob_feature,
  261. tf->hob_nsect,
  262. tf->hob_lbal,
  263. tf->hob_lbam,
  264. tf->hob_lbah);
  265. }
  266. if (is_addr) {
  267. out_be32(ioaddr->feature_addr, tf->feature);
  268. out_be32(ioaddr->nsect_addr, tf->nsect);
  269. out_be32(ioaddr->lbal_addr, tf->lbal);
  270. out_be32(ioaddr->lbam_addr, tf->lbam);
  271. out_be32(ioaddr->lbah_addr, tf->lbah);
  272. VPRINTK("feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n",
  273. tf->feature,
  274. tf->nsect,
  275. tf->lbal,
  276. tf->lbam,
  277. tf->lbah);
  278. }
  279. if (tf->flags & ATA_TFLAG_DEVICE) {
  280. out_be32(ioaddr->device_addr, tf->device);
  281. VPRINTK("device 0x%X\n", tf->device);
  282. }
  283. ata_wait_idle(ap);
  284. }
  285. /**
  286. * scc_check_status - Read device status reg & clear interrupt
  287. * @ap: port where the device is
  288. *
  289. * Note: Original code is ata_check_status().
  290. */
  291. static u8 scc_check_status (struct ata_port *ap)
  292. {
  293. return in_be32(ap->ioaddr.status_addr);
  294. }
  295. /**
  296. * scc_tf_read - input device's ATA taskfile shadow registers
  297. * @ap: Port from which input is read
  298. * @tf: ATA taskfile register set for storing input
  299. *
  300. * Note: Original code is ata_sff_tf_read().
  301. */
  302. static void scc_tf_read (struct ata_port *ap, struct ata_taskfile *tf)
  303. {
  304. struct ata_ioports *ioaddr = &ap->ioaddr;
  305. tf->command = scc_check_status(ap);
  306. tf->feature = in_be32(ioaddr->error_addr);
  307. tf->nsect = in_be32(ioaddr->nsect_addr);
  308. tf->lbal = in_be32(ioaddr->lbal_addr);
  309. tf->lbam = in_be32(ioaddr->lbam_addr);
  310. tf->lbah = in_be32(ioaddr->lbah_addr);
  311. tf->device = in_be32(ioaddr->device_addr);
  312. if (tf->flags & ATA_TFLAG_LBA48) {
  313. out_be32(ioaddr->ctl_addr, tf->ctl | ATA_HOB);
  314. tf->hob_feature = in_be32(ioaddr->error_addr);
  315. tf->hob_nsect = in_be32(ioaddr->nsect_addr);
  316. tf->hob_lbal = in_be32(ioaddr->lbal_addr);
  317. tf->hob_lbam = in_be32(ioaddr->lbam_addr);
  318. tf->hob_lbah = in_be32(ioaddr->lbah_addr);
  319. out_be32(ioaddr->ctl_addr, tf->ctl);
  320. ap->last_ctl = tf->ctl;
  321. }
  322. }
  323. /**
  324. * scc_exec_command - issue ATA command to host controller
  325. * @ap: port to which command is being issued
  326. * @tf: ATA taskfile register set
  327. *
  328. * Note: Original code is ata_sff_exec_command().
  329. */
  330. static void scc_exec_command (struct ata_port *ap,
  331. const struct ata_taskfile *tf)
  332. {
  333. DPRINTK("ata%u: cmd 0x%X\n", ap->print_id, tf->command);
  334. out_be32(ap->ioaddr.command_addr, tf->command);
  335. ata_sff_pause(ap);
  336. }
  337. /**
  338. * scc_check_altstatus - Read device alternate status reg
  339. * @ap: port where the device is
  340. */
  341. static u8 scc_check_altstatus (struct ata_port *ap)
  342. {
  343. return in_be32(ap->ioaddr.altstatus_addr);
  344. }
  345. /**
  346. * scc_dev_select - Select device 0/1 on ATA bus
  347. * @ap: ATA channel to manipulate
  348. * @device: ATA device (numbered from zero) to select
  349. *
  350. * Note: Original code is ata_sff_dev_select().
  351. */
  352. static void scc_dev_select (struct ata_port *ap, unsigned int device)
  353. {
  354. u8 tmp;
  355. if (device == 0)
  356. tmp = ATA_DEVICE_OBS;
  357. else
  358. tmp = ATA_DEVICE_OBS | ATA_DEV1;
  359. out_be32(ap->ioaddr.device_addr, tmp);
  360. ata_sff_pause(ap);
  361. }
  362. /**
  363. * scc_bmdma_setup - Set up PCI IDE BMDMA transaction
  364. * @qc: Info associated with this ATA transaction.
  365. *
  366. * Note: Original code is ata_bmdma_setup().
  367. */
  368. static void scc_bmdma_setup (struct ata_queued_cmd *qc)
  369. {
  370. struct ata_port *ap = qc->ap;
  371. unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
  372. u8 dmactl;
  373. void __iomem *mmio = ap->ioaddr.bmdma_addr;
  374. /* load PRD table addr */
  375. out_be32(mmio + SCC_DMA_TABLE_OFS, ap->prd_dma);
  376. /* specify data direction, triple-check start bit is clear */
  377. dmactl = in_be32(mmio + SCC_DMA_CMD);
  378. dmactl &= ~(ATA_DMA_WR | ATA_DMA_START);
  379. if (!rw)
  380. dmactl |= ATA_DMA_WR;
  381. out_be32(mmio + SCC_DMA_CMD, dmactl);
  382. /* issue r/w command */
  383. ap->ops->sff_exec_command(ap, &qc->tf);
  384. }
  385. /**
  386. * scc_bmdma_start - Start a PCI IDE BMDMA transaction
  387. * @qc: Info associated with this ATA transaction.
  388. *
  389. * Note: Original code is ata_bmdma_start().
  390. */
  391. static void scc_bmdma_start (struct ata_queued_cmd *qc)
  392. {
  393. struct ata_port *ap = qc->ap;
  394. u8 dmactl;
  395. void __iomem *mmio = ap->ioaddr.bmdma_addr;
  396. /* start host DMA transaction */
  397. dmactl = in_be32(mmio + SCC_DMA_CMD);
  398. out_be32(mmio + SCC_DMA_CMD, dmactl | ATA_DMA_START);
  399. }
  400. /**
  401. * scc_devchk - PATA device presence detection
  402. * @ap: ATA channel to examine
  403. * @device: Device to examine (starting at zero)
  404. *
  405. * Note: Original code is ata_devchk().
  406. */
  407. static unsigned int scc_devchk (struct ata_port *ap,
  408. unsigned int device)
  409. {
  410. struct ata_ioports *ioaddr = &ap->ioaddr;
  411. u8 nsect, lbal;
  412. ap->ops->sff_dev_select(ap, device);
  413. out_be32(ioaddr->nsect_addr, 0x55);
  414. out_be32(ioaddr->lbal_addr, 0xaa);
  415. out_be32(ioaddr->nsect_addr, 0xaa);
  416. out_be32(ioaddr->lbal_addr, 0x55);
  417. out_be32(ioaddr->nsect_addr, 0x55);
  418. out_be32(ioaddr->lbal_addr, 0xaa);
  419. nsect = in_be32(ioaddr->nsect_addr);
  420. lbal = in_be32(ioaddr->lbal_addr);
  421. if ((nsect == 0x55) && (lbal == 0xaa))
  422. return 1; /* we found a device */
  423. return 0; /* nothing found */
  424. }
  425. /**
  426. * scc_wait_after_reset - wait for devices to become ready after reset
  427. *
  428. * Note: Original code is ata_sff_wait_after_reset
  429. */
  430. int scc_wait_after_reset(struct ata_link *link, unsigned int devmask,
  431. unsigned long deadline)
  432. {
  433. struct ata_port *ap = link->ap;
  434. struct ata_ioports *ioaddr = &ap->ioaddr;
  435. unsigned int dev0 = devmask & (1 << 0);
  436. unsigned int dev1 = devmask & (1 << 1);
  437. int rc, ret = 0;
  438. /* Spec mandates ">= 2ms" before checking status. We wait
  439. * 150ms, because that was the magic delay used for ATAPI
  440. * devices in Hale Landis's ATADRVR, for the period of time
  441. * between when the ATA command register is written, and then
  442. * status is checked. Because waiting for "a while" before
  443. * checking status is fine, post SRST, we perform this magic
  444. * delay here as well.
  445. *
  446. * Old drivers/ide uses the 2mS rule and then waits for ready.
  447. */
  448. msleep(150);
  449. /* always check readiness of the master device */
  450. rc = ata_sff_wait_ready(link, deadline);
  451. /* -ENODEV means the odd clown forgot the D7 pulldown resistor
  452. * and TF status is 0xff, bail out on it too.
  453. */
  454. if (rc)
  455. return rc;
  456. /* if device 1 was found in ata_devchk, wait for register
  457. * access briefly, then wait for BSY to clear.
  458. */
  459. if (dev1) {
  460. int i;
  461. ap->ops->sff_dev_select(ap, 1);
  462. /* Wait for register access. Some ATAPI devices fail
  463. * to set nsect/lbal after reset, so don't waste too
  464. * much time on it. We're gonna wait for !BSY anyway.
  465. */
  466. for (i = 0; i < 2; i++) {
  467. u8 nsect, lbal;
  468. nsect = in_be32(ioaddr->nsect_addr);
  469. lbal = in_be32(ioaddr->lbal_addr);
  470. if ((nsect == 1) && (lbal == 1))
  471. break;
  472. msleep(50); /* give drive a breather */
  473. }
  474. rc = ata_sff_wait_ready(link, deadline);
  475. if (rc) {
  476. if (rc != -ENODEV)
  477. return rc;
  478. ret = rc;
  479. }
  480. }
  481. /* is all this really necessary? */
  482. ap->ops->sff_dev_select(ap, 0);
  483. if (dev1)
  484. ap->ops->sff_dev_select(ap, 1);
  485. if (dev0)
  486. ap->ops->sff_dev_select(ap, 0);
  487. return ret;
  488. }
  489. /**
  490. * scc_bus_softreset - PATA device software reset
  491. *
  492. * Note: Original code is ata_bus_softreset().
  493. */
  494. static unsigned int scc_bus_softreset(struct ata_port *ap, unsigned int devmask,
  495. unsigned long deadline)
  496. {
  497. struct ata_ioports *ioaddr = &ap->ioaddr;
  498. DPRINTK("ata%u: bus reset via SRST\n", ap->print_id);
  499. /* software reset. causes dev0 to be selected */
  500. out_be32(ioaddr->ctl_addr, ap->ctl);
  501. udelay(20);
  502. out_be32(ioaddr->ctl_addr, ap->ctl | ATA_SRST);
  503. udelay(20);
  504. out_be32(ioaddr->ctl_addr, ap->ctl);
  505. scc_wait_after_reset(&ap->link, devmask, deadline);
  506. return 0;
  507. }
  508. /**
  509. * scc_softreset - reset host port via ATA SRST
  510. * @ap: port to reset
  511. * @classes: resulting classes of attached devices
  512. * @deadline: deadline jiffies for the operation
  513. *
  514. * Note: Original code is ata_sff_softreset().
  515. */
  516. static int scc_softreset(struct ata_link *link, unsigned int *classes,
  517. unsigned long deadline)
  518. {
  519. struct ata_port *ap = link->ap;
  520. unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS;
  521. unsigned int devmask = 0, err_mask;
  522. u8 err;
  523. DPRINTK("ENTER\n");
  524. /* determine if device 0/1 are present */
  525. if (scc_devchk(ap, 0))
  526. devmask |= (1 << 0);
  527. if (slave_possible && scc_devchk(ap, 1))
  528. devmask |= (1 << 1);
  529. /* select device 0 again */
  530. ap->ops->sff_dev_select(ap, 0);
  531. /* issue bus reset */
  532. DPRINTK("about to softreset, devmask=%x\n", devmask);
  533. err_mask = scc_bus_softreset(ap, devmask, deadline);
  534. if (err_mask) {
  535. ata_port_printk(ap, KERN_ERR, "SRST failed (err_mask=0x%x)\n",
  536. err_mask);
  537. return -EIO;
  538. }
  539. /* determine by signature whether we have ATA or ATAPI devices */
  540. classes[0] = ata_sff_dev_classify(&ap->link.device[0],
  541. devmask & (1 << 0), &err);
  542. if (slave_possible && err != 0x81)
  543. classes[1] = ata_sff_dev_classify(&ap->link.device[1],
  544. devmask & (1 << 1), &err);
  545. DPRINTK("EXIT, classes[0]=%u [1]=%u\n", classes[0], classes[1]);
  546. return 0;
  547. }
  548. /**
  549. * scc_bmdma_stop - Stop PCI IDE BMDMA transfer
  550. * @qc: Command we are ending DMA for
  551. */
  552. static void scc_bmdma_stop (struct ata_queued_cmd *qc)
  553. {
  554. struct ata_port *ap = qc->ap;
  555. void __iomem *ctrl_base = ap->host->iomap[SCC_CTRL_BAR];
  556. void __iomem *bmid_base = ap->host->iomap[SCC_BMID_BAR];
  557. u32 reg;
  558. while (1) {
  559. reg = in_be32(bmid_base + SCC_DMA_INTST);
  560. if (reg & INTSTS_SERROR) {
  561. printk(KERN_WARNING "%s: SERROR\n", DRV_NAME);
  562. out_be32(bmid_base + SCC_DMA_INTST, INTSTS_SERROR|INTSTS_BMSINT);
  563. out_be32(bmid_base + SCC_DMA_CMD,
  564. in_be32(bmid_base + SCC_DMA_CMD) & ~ATA_DMA_START);
  565. continue;
  566. }
  567. if (reg & INTSTS_PRERR) {
  568. u32 maea0, maec0;
  569. maea0 = in_be32(ctrl_base + SCC_CTL_MAEA0);
  570. maec0 = in_be32(ctrl_base + SCC_CTL_MAEC0);
  571. printk(KERN_WARNING "%s: PRERR [addr:%x cmd:%x]\n", DRV_NAME, maea0, maec0);
  572. out_be32(bmid_base + SCC_DMA_INTST, INTSTS_PRERR|INTSTS_BMSINT);
  573. out_be32(bmid_base + SCC_DMA_CMD,
  574. in_be32(bmid_base + SCC_DMA_CMD) & ~ATA_DMA_START);
  575. continue;
  576. }
  577. if (reg & INTSTS_RERR) {
  578. printk(KERN_WARNING "%s: Response Error\n", DRV_NAME);
  579. out_be32(bmid_base + SCC_DMA_INTST, INTSTS_RERR|INTSTS_BMSINT);
  580. out_be32(bmid_base + SCC_DMA_CMD,
  581. in_be32(bmid_base + SCC_DMA_CMD) & ~ATA_DMA_START);
  582. continue;
  583. }
  584. if (reg & INTSTS_ICERR) {
  585. out_be32(bmid_base + SCC_DMA_CMD,
  586. in_be32(bmid_base + SCC_DMA_CMD) & ~ATA_DMA_START);
  587. printk(KERN_WARNING "%s: Illegal Configuration\n", DRV_NAME);
  588. out_be32(bmid_base + SCC_DMA_INTST, INTSTS_ICERR|INTSTS_BMSINT);
  589. continue;
  590. }
  591. if (reg & INTSTS_BMSINT) {
  592. unsigned int classes;
  593. unsigned long deadline = ata_deadline(jiffies, ATA_TMOUT_BOOT);
  594. printk(KERN_WARNING "%s: Internal Bus Error\n", DRV_NAME);
  595. out_be32(bmid_base + SCC_DMA_INTST, INTSTS_BMSINT);
  596. /* TBD: SW reset */
  597. scc_softreset(&ap->link, &classes, deadline);
  598. continue;
  599. }
  600. if (reg & INTSTS_BMHE) {
  601. out_be32(bmid_base + SCC_DMA_INTST, INTSTS_BMHE);
  602. continue;
  603. }
  604. if (reg & INTSTS_ACTEINT) {
  605. out_be32(bmid_base + SCC_DMA_INTST, INTSTS_ACTEINT);
  606. continue;
  607. }
  608. if (reg & INTSTS_IOIRQS) {
  609. out_be32(bmid_base + SCC_DMA_INTST, INTSTS_IOIRQS);
  610. continue;
  611. }
  612. break;
  613. }
  614. /* clear start/stop bit */
  615. out_be32(bmid_base + SCC_DMA_CMD,
  616. in_be32(bmid_base + SCC_DMA_CMD) & ~ATA_DMA_START);
  617. /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */
  618. ata_sff_dma_pause(ap); /* dummy read */
  619. }
  620. /**
  621. * scc_bmdma_status - Read PCI IDE BMDMA status
  622. * @ap: Port associated with this ATA transaction.
  623. */
  624. static u8 scc_bmdma_status (struct ata_port *ap)
  625. {
  626. void __iomem *mmio = ap->ioaddr.bmdma_addr;
  627. u8 host_stat = in_be32(mmio + SCC_DMA_STATUS);
  628. u32 int_status = in_be32(mmio + SCC_DMA_INTST);
  629. struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->link.active_tag);
  630. static int retry = 0;
  631. /* return if IOS_SS is cleared */
  632. if (!(in_be32(mmio + SCC_DMA_CMD) & ATA_DMA_START))
  633. return host_stat;
  634. /* errata A252,A308 workaround: Step4 */
  635. if ((scc_check_altstatus(ap) & ATA_ERR)
  636. && (int_status & INTSTS_INTRQ))
  637. return (host_stat | ATA_DMA_INTR);
  638. /* errata A308 workaround Step5 */
  639. if (int_status & INTSTS_IOIRQS) {
  640. host_stat |= ATA_DMA_INTR;
  641. /* We don't check ATAPI DMA because it is limited to UDMA4 */
  642. if ((qc->tf.protocol == ATA_PROT_DMA &&
  643. qc->dev->xfer_mode > XFER_UDMA_4)) {
  644. if (!(int_status & INTSTS_ACTEINT)) {
  645. printk(KERN_WARNING "ata%u: operation failed (transfer data loss)\n",
  646. ap->print_id);
  647. host_stat |= ATA_DMA_ERR;
  648. if (retry++)
  649. ap->udma_mask &= ~(1 << qc->dev->xfer_mode);
  650. } else
  651. retry = 0;
  652. }
  653. }
  654. return host_stat;
  655. }
  656. /**
  657. * scc_data_xfer - Transfer data by PIO
  658. * @dev: device for this I/O
  659. * @buf: data buffer
  660. * @buflen: buffer length
  661. * @rw: read/write
  662. *
  663. * Note: Original code is ata_sff_data_xfer().
  664. */
  665. static unsigned int scc_data_xfer (struct ata_device *dev, unsigned char *buf,
  666. unsigned int buflen, int rw)
  667. {
  668. struct ata_port *ap = dev->link->ap;
  669. unsigned int words = buflen >> 1;
  670. unsigned int i;
  671. __le16 *buf16 = (__le16 *) buf;
  672. void __iomem *mmio = ap->ioaddr.data_addr;
  673. /* Transfer multiple of 2 bytes */
  674. if (rw == READ)
  675. for (i = 0; i < words; i++)
  676. buf16[i] = cpu_to_le16(in_be32(mmio));
  677. else
  678. for (i = 0; i < words; i++)
  679. out_be32(mmio, le16_to_cpu(buf16[i]));
  680. /* Transfer trailing 1 byte, if any. */
  681. if (unlikely(buflen & 0x01)) {
  682. __le16 align_buf[1] = { 0 };
  683. unsigned char *trailing_buf = buf + buflen - 1;
  684. if (rw == READ) {
  685. align_buf[0] = cpu_to_le16(in_be32(mmio));
  686. memcpy(trailing_buf, align_buf, 1);
  687. } else {
  688. memcpy(align_buf, trailing_buf, 1);
  689. out_be32(mmio, le16_to_cpu(align_buf[0]));
  690. }
  691. words++;
  692. }
  693. return words << 1;
  694. }
  695. /**
  696. * scc_irq_on - Enable interrupts on a port.
  697. * @ap: Port on which interrupts are enabled.
  698. *
  699. * Note: Original code is ata_sff_irq_on().
  700. */
  701. static u8 scc_irq_on (struct ata_port *ap)
  702. {
  703. struct ata_ioports *ioaddr = &ap->ioaddr;
  704. u8 tmp;
  705. ap->ctl &= ~ATA_NIEN;
  706. ap->last_ctl = ap->ctl;
  707. out_be32(ioaddr->ctl_addr, ap->ctl);
  708. tmp = ata_wait_idle(ap);
  709. ap->ops->sff_irq_clear(ap);
  710. return tmp;
  711. }
  712. /**
  713. * scc_freeze - Freeze BMDMA controller port
  714. * @ap: port to freeze
  715. *
  716. * Note: Original code is ata_sff_freeze().
  717. */
  718. static void scc_freeze (struct ata_port *ap)
  719. {
  720. struct ata_ioports *ioaddr = &ap->ioaddr;
  721. ap->ctl |= ATA_NIEN;
  722. ap->last_ctl = ap->ctl;
  723. out_be32(ioaddr->ctl_addr, ap->ctl);
  724. /* Under certain circumstances, some controllers raise IRQ on
  725. * ATA_NIEN manipulation. Also, many controllers fail to mask
  726. * previously pending IRQ on ATA_NIEN assertion. Clear it.
  727. */
  728. ap->ops->sff_check_status(ap);
  729. ap->ops->sff_irq_clear(ap);
  730. }
  731. /**
  732. * scc_pata_prereset - prepare for reset
  733. * @ap: ATA port to be reset
  734. * @deadline: deadline jiffies for the operation
  735. */
  736. static int scc_pata_prereset(struct ata_link *link, unsigned long deadline)
  737. {
  738. link->ap->cbl = ATA_CBL_PATA80;
  739. return ata_sff_prereset(link, deadline);
  740. }
  741. /**
  742. * scc_postreset - standard postreset callback
  743. * @ap: the target ata_port
  744. * @classes: classes of attached devices
  745. *
  746. * Note: Original code is ata_sff_postreset().
  747. */
  748. static void scc_postreset(struct ata_link *link, unsigned int *classes)
  749. {
  750. struct ata_port *ap = link->ap;
  751. DPRINTK("ENTER\n");
  752. /* is double-select really necessary? */
  753. if (classes[0] != ATA_DEV_NONE)
  754. ap->ops->sff_dev_select(ap, 1);
  755. if (classes[1] != ATA_DEV_NONE)
  756. ap->ops->sff_dev_select(ap, 0);
  757. /* bail out if no device is present */
  758. if (classes[0] == ATA_DEV_NONE && classes[1] == ATA_DEV_NONE) {
  759. DPRINTK("EXIT, no device\n");
  760. return;
  761. }
  762. /* set up device control */
  763. if (ap->ioaddr.ctl_addr)
  764. out_be32(ap->ioaddr.ctl_addr, ap->ctl);
  765. DPRINTK("EXIT\n");
  766. }
  767. /**
  768. * scc_irq_clear - Clear PCI IDE BMDMA interrupt.
  769. * @ap: Port associated with this ATA transaction.
  770. *
  771. * Note: Original code is ata_sff_irq_clear().
  772. */
  773. static void scc_irq_clear (struct ata_port *ap)
  774. {
  775. void __iomem *mmio = ap->ioaddr.bmdma_addr;
  776. if (!mmio)
  777. return;
  778. out_be32(mmio + SCC_DMA_STATUS, in_be32(mmio + SCC_DMA_STATUS));
  779. }
  780. /**
  781. * scc_port_start - Set port up for dma.
  782. * @ap: Port to initialize
  783. *
  784. * Allocate space for PRD table using ata_port_start().
  785. * Set PRD table address for PTERADD. (PRD Transfer End Read)
  786. */
  787. static int scc_port_start (struct ata_port *ap)
  788. {
  789. void __iomem *mmio = ap->ioaddr.bmdma_addr;
  790. int rc;
  791. rc = ata_port_start(ap);
  792. if (rc)
  793. return rc;
  794. out_be32(mmio + SCC_DMA_PTERADD, ap->prd_dma);
  795. return 0;
  796. }
  797. /**
  798. * scc_port_stop - Undo scc_port_start()
  799. * @ap: Port to shut down
  800. *
  801. * Reset PTERADD.
  802. */
  803. static void scc_port_stop (struct ata_port *ap)
  804. {
  805. void __iomem *mmio = ap->ioaddr.bmdma_addr;
  806. out_be32(mmio + SCC_DMA_PTERADD, 0);
  807. }
  808. static struct scsi_host_template scc_sht = {
  809. ATA_BMDMA_SHT(DRV_NAME),
  810. };
  811. static struct ata_port_operations scc_pata_ops = {
  812. .inherits = &ata_bmdma_port_ops,
  813. .set_piomode = scc_set_piomode,
  814. .set_dmamode = scc_set_dmamode,
  815. .mode_filter = scc_mode_filter,
  816. .sff_tf_load = scc_tf_load,
  817. .sff_tf_read = scc_tf_read,
  818. .sff_exec_command = scc_exec_command,
  819. .sff_check_status = scc_check_status,
  820. .sff_check_altstatus = scc_check_altstatus,
  821. .sff_dev_select = scc_dev_select,
  822. .bmdma_setup = scc_bmdma_setup,
  823. .bmdma_start = scc_bmdma_start,
  824. .bmdma_stop = scc_bmdma_stop,
  825. .bmdma_status = scc_bmdma_status,
  826. .sff_data_xfer = scc_data_xfer,
  827. .freeze = scc_freeze,
  828. .prereset = scc_pata_prereset,
  829. .softreset = scc_softreset,
  830. .postreset = scc_postreset,
  831. .post_internal_cmd = scc_bmdma_stop,
  832. .sff_irq_clear = scc_irq_clear,
  833. .sff_irq_on = scc_irq_on,
  834. .port_start = scc_port_start,
  835. .port_stop = scc_port_stop,
  836. };
  837. static struct ata_port_info scc_port_info[] = {
  838. {
  839. .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY,
  840. .pio_mask = ATA_PIO4,
  841. /* No MWDMA */
  842. .udma_mask = ATA_UDMA6,
  843. .port_ops = &scc_pata_ops,
  844. },
  845. };
  846. /**
  847. * scc_reset_controller - initialize SCC PATA controller.
  848. */
  849. static int scc_reset_controller(struct ata_host *host)
  850. {
  851. void __iomem *ctrl_base = host->iomap[SCC_CTRL_BAR];
  852. void __iomem *bmid_base = host->iomap[SCC_BMID_BAR];
  853. void __iomem *cckctrl_port = ctrl_base + SCC_CTL_CCKCTRL;
  854. void __iomem *mode_port = ctrl_base + SCC_CTL_MODEREG;
  855. void __iomem *ecmode_port = ctrl_base + SCC_CTL_ECMODE;
  856. void __iomem *intmask_port = bmid_base + SCC_DMA_INTMASK;
  857. void __iomem *dmastatus_port = bmid_base + SCC_DMA_STATUS;
  858. u32 reg = 0;
  859. out_be32(cckctrl_port, reg);
  860. reg |= CCKCTRL_ATACLKOEN;
  861. out_be32(cckctrl_port, reg);
  862. reg |= CCKCTRL_LCLKEN | CCKCTRL_OCLKEN;
  863. out_be32(cckctrl_port, reg);
  864. reg |= CCKCTRL_CRST;
  865. out_be32(cckctrl_port, reg);
  866. for (;;) {
  867. reg = in_be32(cckctrl_port);
  868. if (reg & CCKCTRL_CRST)
  869. break;
  870. udelay(5000);
  871. }
  872. reg |= CCKCTRL_ATARESET;
  873. out_be32(cckctrl_port, reg);
  874. out_be32(ecmode_port, ECMODE_VALUE);
  875. out_be32(mode_port, MODE_JCUSFEN);
  876. out_be32(intmask_port, INTMASK_MSK);
  877. if (in_be32(dmastatus_port) & QCHSD_STPDIAG) {
  878. printk(KERN_WARNING "%s: failed to detect 80c cable. (PDIAG# is high)\n", DRV_NAME);
  879. return -EIO;
  880. }
  881. return 0;
  882. }
  883. /**
  884. * scc_setup_ports - initialize ioaddr with SCC PATA port offsets.
  885. * @ioaddr: IO address structure to be initialized
  886. * @base: base address of BMID region
  887. */
  888. static void scc_setup_ports (struct ata_ioports *ioaddr, void __iomem *base)
  889. {
  890. ioaddr->cmd_addr = base + SCC_REG_CMD_ADDR;
  891. ioaddr->altstatus_addr = ioaddr->cmd_addr + SCC_REG_ALTSTATUS;
  892. ioaddr->ctl_addr = ioaddr->cmd_addr + SCC_REG_ALTSTATUS;
  893. ioaddr->bmdma_addr = base;
  894. ioaddr->data_addr = ioaddr->cmd_addr + SCC_REG_DATA;
  895. ioaddr->error_addr = ioaddr->cmd_addr + SCC_REG_ERR;
  896. ioaddr->feature_addr = ioaddr->cmd_addr + SCC_REG_FEATURE;
  897. ioaddr->nsect_addr = ioaddr->cmd_addr + SCC_REG_NSECT;
  898. ioaddr->lbal_addr = ioaddr->cmd_addr + SCC_REG_LBAL;
  899. ioaddr->lbam_addr = ioaddr->cmd_addr + SCC_REG_LBAM;
  900. ioaddr->lbah_addr = ioaddr->cmd_addr + SCC_REG_LBAH;
  901. ioaddr->device_addr = ioaddr->cmd_addr + SCC_REG_DEVICE;
  902. ioaddr->status_addr = ioaddr->cmd_addr + SCC_REG_STATUS;
  903. ioaddr->command_addr = ioaddr->cmd_addr + SCC_REG_CMD;
  904. }
  905. static int scc_host_init(struct ata_host *host)
  906. {
  907. struct pci_dev *pdev = to_pci_dev(host->dev);
  908. int rc;
  909. rc = scc_reset_controller(host);
  910. if (rc)
  911. return rc;
  912. rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
  913. if (rc)
  914. return rc;
  915. rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
  916. if (rc)
  917. return rc;
  918. scc_setup_ports(&host->ports[0]->ioaddr, host->iomap[SCC_BMID_BAR]);
  919. pci_set_master(pdev);
  920. return 0;
  921. }
  922. /**
  923. * scc_init_one - Register SCC PATA device with kernel services
  924. * @pdev: PCI device to register
  925. * @ent: Entry in scc_pci_tbl matching with @pdev
  926. *
  927. * LOCKING:
  928. * Inherited from PCI layer (may sleep).
  929. *
  930. * RETURNS:
  931. * Zero on success, or -ERRNO value.
  932. */
  933. static int scc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
  934. {
  935. static int printed_version;
  936. unsigned int board_idx = (unsigned int) ent->driver_data;
  937. const struct ata_port_info *ppi[] = { &scc_port_info[board_idx], NULL };
  938. struct ata_host *host;
  939. int rc;
  940. if (!printed_version++)
  941. dev_printk(KERN_DEBUG, &pdev->dev,
  942. "version " DRV_VERSION "\n");
  943. host = ata_host_alloc_pinfo(&pdev->dev, ppi, 1);
  944. if (!host)
  945. return -ENOMEM;
  946. rc = pcim_enable_device(pdev);
  947. if (rc)
  948. return rc;
  949. rc = pcim_iomap_regions(pdev, (1 << SCC_CTRL_BAR) | (1 << SCC_BMID_BAR), DRV_NAME);
  950. if (rc == -EBUSY)
  951. pcim_pin_device(pdev);
  952. if (rc)
  953. return rc;
  954. host->iomap = pcim_iomap_table(pdev);
  955. ata_port_pbar_desc(host->ports[0], SCC_CTRL_BAR, -1, "ctrl");
  956. ata_port_pbar_desc(host->ports[0], SCC_BMID_BAR, -1, "bmid");
  957. rc = scc_host_init(host);
  958. if (rc)
  959. return rc;
  960. return ata_host_activate(host, pdev->irq, ata_sff_interrupt,
  961. IRQF_SHARED, &scc_sht);
  962. }
  963. static struct pci_driver scc_pci_driver = {
  964. .name = DRV_NAME,
  965. .id_table = scc_pci_tbl,
  966. .probe = scc_init_one,
  967. .remove = ata_pci_remove_one,
  968. #ifdef CONFIG_PM
  969. .suspend = ata_pci_device_suspend,
  970. .resume = ata_pci_device_resume,
  971. #endif
  972. };
  973. static int __init scc_init (void)
  974. {
  975. int rc;
  976. DPRINTK("pci_register_driver\n");
  977. rc = pci_register_driver(&scc_pci_driver);
  978. if (rc)
  979. return rc;
  980. DPRINTK("done\n");
  981. return 0;
  982. }
  983. static void __exit scc_exit (void)
  984. {
  985. pci_unregister_driver(&scc_pci_driver);
  986. }
  987. module_init(scc_init);
  988. module_exit(scc_exit);
  989. MODULE_AUTHOR("Toshiba corp");
  990. MODULE_DESCRIPTION("SCSI low-level driver for Toshiba SCC PATA controller");
  991. MODULE_LICENSE("GPL");
  992. MODULE_DEVICE_TABLE(pci, scc_pci_tbl);
  993. MODULE_VERSION(DRV_VERSION);