pmac.c 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674
  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. *
  7. * Copyright (C) 1998-2003 Paul Mackerras & Ben. Herrenschmidt
  8. * Copyright (C) 2007-2008 Bartlomiej Zolnierkiewicz
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version
  13. * 2 of the License, or (at your option) any later version.
  14. *
  15. * Some code taken from drivers/ide/ide-dma.c:
  16. *
  17. * Copyright (c) 1995-1998 Mark Lord
  18. *
  19. * TODO: - Use pre-calculated (kauai) timing tables all the time and
  20. * get rid of the "rounded" tables used previously, so we have the
  21. * same table format for all controllers and can then just have one
  22. * big table
  23. *
  24. */
  25. #include <linux/types.h>
  26. #include <linux/kernel.h>
  27. #include <linux/init.h>
  28. #include <linux/delay.h>
  29. #include <linux/ide.h>
  30. #include <linux/notifier.h>
  31. #include <linux/reboot.h>
  32. #include <linux/pci.h>
  33. #include <linux/adb.h>
  34. #include <linux/pmu.h>
  35. #include <linux/scatterlist.h>
  36. #include <asm/prom.h>
  37. #include <asm/io.h>
  38. #include <asm/dbdma.h>
  39. #include <asm/ide.h>
  40. #include <asm/pci-bridge.h>
  41. #include <asm/machdep.h>
  42. #include <asm/pmac_feature.h>
  43. #include <asm/sections.h>
  44. #include <asm/irq.h>
  45. #ifndef CONFIG_PPC64
  46. #include <asm/mediabay.h>
  47. #endif
  48. #define DRV_NAME "ide-pmac"
  49. #undef IDE_PMAC_DEBUG
  50. #define DMA_WAIT_TIMEOUT 50
  51. typedef struct pmac_ide_hwif {
  52. unsigned long regbase;
  53. int irq;
  54. int kind;
  55. int aapl_bus_id;
  56. unsigned mediabay : 1;
  57. unsigned broken_dma : 1;
  58. unsigned broken_dma_warn : 1;
  59. struct device_node* node;
  60. struct macio_dev *mdev;
  61. u32 timings[4];
  62. volatile u32 __iomem * *kauai_fcr;
  63. /* Those fields are duplicating what is in hwif. We currently
  64. * can't use the hwif ones because of some assumptions that are
  65. * beeing done by the generic code about the kind of dma controller
  66. * and format of the dma table. This will have to be fixed though.
  67. */
  68. volatile struct dbdma_regs __iomem * dma_regs;
  69. struct dbdma_cmd* dma_table_cpu;
  70. } pmac_ide_hwif_t;
  71. enum {
  72. controller_ohare, /* OHare based */
  73. controller_heathrow, /* Heathrow/Paddington */
  74. controller_kl_ata3, /* KeyLargo ATA-3 */
  75. controller_kl_ata4, /* KeyLargo ATA-4 */
  76. controller_un_ata6, /* UniNorth2 ATA-6 */
  77. controller_k2_ata6, /* K2 ATA-6 */
  78. controller_sh_ata6, /* Shasta ATA-6 */
  79. };
  80. static const char* model_name[] = {
  81. "OHare ATA", /* OHare based */
  82. "Heathrow ATA", /* Heathrow/Paddington */
  83. "KeyLargo ATA-3", /* KeyLargo ATA-3 (MDMA only) */
  84. "KeyLargo ATA-4", /* KeyLargo ATA-4 (UDMA/66) */
  85. "UniNorth ATA-6", /* UniNorth2 ATA-6 (UDMA/100) */
  86. "K2 ATA-6", /* K2 ATA-6 (UDMA/100) */
  87. "Shasta ATA-6", /* Shasta ATA-6 (UDMA/133) */
  88. };
  89. /*
  90. * Extra registers, both 32-bit little-endian
  91. */
  92. #define IDE_TIMING_CONFIG 0x200
  93. #define IDE_INTERRUPT 0x300
  94. /* Kauai (U2) ATA has different register setup */
  95. #define IDE_KAUAI_PIO_CONFIG 0x200
  96. #define IDE_KAUAI_ULTRA_CONFIG 0x210
  97. #define IDE_KAUAI_POLL_CONFIG 0x220
  98. /*
  99. * Timing configuration register definitions
  100. */
  101. /* Number of IDE_SYSCLK_NS ticks, argument is in nanoseconds */
  102. #define SYSCLK_TICKS(t) (((t) + IDE_SYSCLK_NS - 1) / IDE_SYSCLK_NS)
  103. #define SYSCLK_TICKS_66(t) (((t) + IDE_SYSCLK_66_NS - 1) / IDE_SYSCLK_66_NS)
  104. #define IDE_SYSCLK_NS 30 /* 33Mhz cell */
  105. #define IDE_SYSCLK_66_NS 15 /* 66Mhz cell */
  106. /* 133Mhz cell, found in shasta.
  107. * See comments about 100 Mhz Uninorth 2...
  108. * Note that PIO_MASK and MDMA_MASK seem to overlap
  109. */
  110. #define TR_133_PIOREG_PIO_MASK 0xff000fff
  111. #define TR_133_PIOREG_MDMA_MASK 0x00fff800
  112. #define TR_133_UDMAREG_UDMA_MASK 0x0003ffff
  113. #define TR_133_UDMAREG_UDMA_EN 0x00000001
  114. /* 100Mhz cell, found in Uninorth 2. I don't have much infos about
  115. * this one yet, it appears as a pci device (106b/0033) on uninorth
  116. * internal PCI bus and it's clock is controlled like gem or fw. It
  117. * appears to be an evolution of keylargo ATA4 with a timing register
  118. * extended to 2 32bits registers and a similar DBDMA channel. Other
  119. * registers seem to exist but I can't tell much about them.
  120. *
  121. * So far, I'm using pre-calculated tables for this extracted from
  122. * the values used by the MacOS X driver.
  123. *
  124. * The "PIO" register controls PIO and MDMA timings, the "ULTRA"
  125. * register controls the UDMA timings. At least, it seems bit 0
  126. * of this one enables UDMA vs. MDMA, and bits 4..7 are the
  127. * cycle time in units of 10ns. Bits 8..15 are used by I don't
  128. * know their meaning yet
  129. */
  130. #define TR_100_PIOREG_PIO_MASK 0xff000fff
  131. #define TR_100_PIOREG_MDMA_MASK 0x00fff000
  132. #define TR_100_UDMAREG_UDMA_MASK 0x0000ffff
  133. #define TR_100_UDMAREG_UDMA_EN 0x00000001
  134. /* 66Mhz cell, found in KeyLargo. Can do ultra mode 0 to 2 on
  135. * 40 connector cable and to 4 on 80 connector one.
  136. * Clock unit is 15ns (66Mhz)
  137. *
  138. * 3 Values can be programmed:
  139. * - Write data setup, which appears to match the cycle time. They
  140. * also call it DIOW setup.
  141. * - Ready to pause time (from spec)
  142. * - Address setup. That one is weird. I don't see where exactly
  143. * it fits in UDMA cycles, I got it's name from an obscure piece
  144. * of commented out code in Darwin. They leave it to 0, we do as
  145. * well, despite a comment that would lead to think it has a
  146. * min value of 45ns.
  147. * Apple also add 60ns to the write data setup (or cycle time ?) on
  148. * reads.
  149. */
  150. #define TR_66_UDMA_MASK 0xfff00000
  151. #define TR_66_UDMA_EN 0x00100000 /* Enable Ultra mode for DMA */
  152. #define TR_66_UDMA_ADDRSETUP_MASK 0xe0000000 /* Address setup */
  153. #define TR_66_UDMA_ADDRSETUP_SHIFT 29
  154. #define TR_66_UDMA_RDY2PAUS_MASK 0x1e000000 /* Ready 2 pause time */
  155. #define TR_66_UDMA_RDY2PAUS_SHIFT 25
  156. #define TR_66_UDMA_WRDATASETUP_MASK 0x01e00000 /* Write data setup time */
  157. #define TR_66_UDMA_WRDATASETUP_SHIFT 21
  158. #define TR_66_MDMA_MASK 0x000ffc00
  159. #define TR_66_MDMA_RECOVERY_MASK 0x000f8000
  160. #define TR_66_MDMA_RECOVERY_SHIFT 15
  161. #define TR_66_MDMA_ACCESS_MASK 0x00007c00
  162. #define TR_66_MDMA_ACCESS_SHIFT 10
  163. #define TR_66_PIO_MASK 0x000003ff
  164. #define TR_66_PIO_RECOVERY_MASK 0x000003e0
  165. #define TR_66_PIO_RECOVERY_SHIFT 5
  166. #define TR_66_PIO_ACCESS_MASK 0x0000001f
  167. #define TR_66_PIO_ACCESS_SHIFT 0
  168. /* 33Mhz cell, found in OHare, Heathrow (& Paddington) and KeyLargo
  169. * Can do pio & mdma modes, clock unit is 30ns (33Mhz)
  170. *
  171. * The access time and recovery time can be programmed. Some older
  172. * Darwin code base limit OHare to 150ns cycle time. I decided to do
  173. * the same here fore safety against broken old hardware ;)
  174. * The HalfTick bit, when set, adds half a clock (15ns) to the access
  175. * time and removes one from recovery. It's not supported on KeyLargo
  176. * implementation afaik. The E bit appears to be set for PIO mode 0 and
  177. * is used to reach long timings used in this mode.
  178. */
  179. #define TR_33_MDMA_MASK 0x003ff800
  180. #define TR_33_MDMA_RECOVERY_MASK 0x001f0000
  181. #define TR_33_MDMA_RECOVERY_SHIFT 16
  182. #define TR_33_MDMA_ACCESS_MASK 0x0000f800
  183. #define TR_33_MDMA_ACCESS_SHIFT 11
  184. #define TR_33_MDMA_HALFTICK 0x00200000
  185. #define TR_33_PIO_MASK 0x000007ff
  186. #define TR_33_PIO_E 0x00000400
  187. #define TR_33_PIO_RECOVERY_MASK 0x000003e0
  188. #define TR_33_PIO_RECOVERY_SHIFT 5
  189. #define TR_33_PIO_ACCESS_MASK 0x0000001f
  190. #define TR_33_PIO_ACCESS_SHIFT 0
  191. /*
  192. * Interrupt register definitions
  193. */
  194. #define IDE_INTR_DMA 0x80000000
  195. #define IDE_INTR_DEVICE 0x40000000
  196. /*
  197. * FCR Register on Kauai. Not sure what bit 0x4 is ...
  198. */
  199. #define KAUAI_FCR_UATA_MAGIC 0x00000004
  200. #define KAUAI_FCR_UATA_RESET_N 0x00000002
  201. #define KAUAI_FCR_UATA_ENABLE 0x00000001
  202. /* Rounded Multiword DMA timings
  203. *
  204. * I gave up finding a generic formula for all controller
  205. * types and instead, built tables based on timing values
  206. * used by Apple in Darwin's implementation.
  207. */
  208. struct mdma_timings_t {
  209. int accessTime;
  210. int recoveryTime;
  211. int cycleTime;
  212. };
  213. struct mdma_timings_t mdma_timings_33[] =
  214. {
  215. { 240, 240, 480 },
  216. { 180, 180, 360 },
  217. { 135, 135, 270 },
  218. { 120, 120, 240 },
  219. { 105, 105, 210 },
  220. { 90, 90, 180 },
  221. { 75, 75, 150 },
  222. { 75, 45, 120 },
  223. { 0, 0, 0 }
  224. };
  225. struct mdma_timings_t mdma_timings_33k[] =
  226. {
  227. { 240, 240, 480 },
  228. { 180, 180, 360 },
  229. { 150, 150, 300 },
  230. { 120, 120, 240 },
  231. { 90, 120, 210 },
  232. { 90, 90, 180 },
  233. { 90, 60, 150 },
  234. { 90, 30, 120 },
  235. { 0, 0, 0 }
  236. };
  237. struct mdma_timings_t mdma_timings_66[] =
  238. {
  239. { 240, 240, 480 },
  240. { 180, 180, 360 },
  241. { 135, 135, 270 },
  242. { 120, 120, 240 },
  243. { 105, 105, 210 },
  244. { 90, 90, 180 },
  245. { 90, 75, 165 },
  246. { 75, 45, 120 },
  247. { 0, 0, 0 }
  248. };
  249. /* KeyLargo ATA-4 Ultra DMA timings (rounded) */
  250. struct {
  251. int addrSetup; /* ??? */
  252. int rdy2pause;
  253. int wrDataSetup;
  254. } kl66_udma_timings[] =
  255. {
  256. { 0, 180, 120 }, /* Mode 0 */
  257. { 0, 150, 90 }, /* 1 */
  258. { 0, 120, 60 }, /* 2 */
  259. { 0, 90, 45 }, /* 3 */
  260. { 0, 90, 30 } /* 4 */
  261. };
  262. /* UniNorth 2 ATA/100 timings */
  263. struct kauai_timing {
  264. int cycle_time;
  265. u32 timing_reg;
  266. };
  267. static struct kauai_timing kauai_pio_timings[] =
  268. {
  269. { 930 , 0x08000fff },
  270. { 600 , 0x08000a92 },
  271. { 383 , 0x0800060f },
  272. { 360 , 0x08000492 },
  273. { 330 , 0x0800048f },
  274. { 300 , 0x080003cf },
  275. { 270 , 0x080003cc },
  276. { 240 , 0x0800038b },
  277. { 239 , 0x0800030c },
  278. { 180 , 0x05000249 },
  279. { 120 , 0x04000148 },
  280. { 0 , 0 },
  281. };
  282. static struct kauai_timing kauai_mdma_timings[] =
  283. {
  284. { 1260 , 0x00fff000 },
  285. { 480 , 0x00618000 },
  286. { 360 , 0x00492000 },
  287. { 270 , 0x0038e000 },
  288. { 240 , 0x0030c000 },
  289. { 210 , 0x002cb000 },
  290. { 180 , 0x00249000 },
  291. { 150 , 0x00209000 },
  292. { 120 , 0x00148000 },
  293. { 0 , 0 },
  294. };
  295. static struct kauai_timing kauai_udma_timings[] =
  296. {
  297. { 120 , 0x000070c0 },
  298. { 90 , 0x00005d80 },
  299. { 60 , 0x00004a60 },
  300. { 45 , 0x00003a50 },
  301. { 30 , 0x00002a30 },
  302. { 20 , 0x00002921 },
  303. { 0 , 0 },
  304. };
  305. static struct kauai_timing shasta_pio_timings[] =
  306. {
  307. { 930 , 0x08000fff },
  308. { 600 , 0x0A000c97 },
  309. { 383 , 0x07000712 },
  310. { 360 , 0x040003cd },
  311. { 330 , 0x040003cd },
  312. { 300 , 0x040003cd },
  313. { 270 , 0x040003cd },
  314. { 240 , 0x040003cd },
  315. { 239 , 0x040003cd },
  316. { 180 , 0x0400028b },
  317. { 120 , 0x0400010a },
  318. { 0 , 0 },
  319. };
  320. static struct kauai_timing shasta_mdma_timings[] =
  321. {
  322. { 1260 , 0x00fff000 },
  323. { 480 , 0x00820800 },
  324. { 360 , 0x00820800 },
  325. { 270 , 0x00820800 },
  326. { 240 , 0x00820800 },
  327. { 210 , 0x00820800 },
  328. { 180 , 0x00820800 },
  329. { 150 , 0x0028b000 },
  330. { 120 , 0x001ca000 },
  331. { 0 , 0 },
  332. };
  333. static struct kauai_timing shasta_udma133_timings[] =
  334. {
  335. { 120 , 0x00035901, },
  336. { 90 , 0x000348b1, },
  337. { 60 , 0x00033881, },
  338. { 45 , 0x00033861, },
  339. { 30 , 0x00033841, },
  340. { 20 , 0x00033031, },
  341. { 15 , 0x00033021, },
  342. { 0 , 0 },
  343. };
  344. static inline u32
  345. kauai_lookup_timing(struct kauai_timing* table, int cycle_time)
  346. {
  347. int i;
  348. for (i=0; table[i].cycle_time; i++)
  349. if (cycle_time > table[i+1].cycle_time)
  350. return table[i].timing_reg;
  351. BUG();
  352. return 0;
  353. }
  354. /* allow up to 256 DBDMA commands per xfer */
  355. #define MAX_DCMDS 256
  356. /*
  357. * Wait 1s for disk to answer on IDE bus after a hard reset
  358. * of the device (via GPIO/FCR).
  359. *
  360. * Some devices seem to "pollute" the bus even after dropping
  361. * the BSY bit (typically some combo drives slave on the UDMA
  362. * bus) after a hard reset. Since we hard reset all drives on
  363. * KeyLargo ATA66, we have to keep that delay around. I may end
  364. * up not hard resetting anymore on these and keep the delay only
  365. * for older interfaces instead (we have to reset when coming
  366. * from MacOS...) --BenH.
  367. */
  368. #define IDE_WAKEUP_DELAY (1*HZ)
  369. static int pmac_ide_init_dma(ide_hwif_t *, const struct ide_port_info *);
  370. static void pmac_ide_selectproc(ide_drive_t *drive);
  371. static void pmac_ide_kauai_selectproc(ide_drive_t *drive);
  372. #define PMAC_IDE_REG(x) \
  373. ((void __iomem *)((drive)->hwif->io_ports.data_addr + (x)))
  374. /*
  375. * Apply the timings of the proper unit (master/slave) to the shared
  376. * timing register when selecting that unit. This version is for
  377. * ASICs with a single timing register
  378. */
  379. static void
  380. pmac_ide_selectproc(ide_drive_t *drive)
  381. {
  382. ide_hwif_t *hwif = drive->hwif;
  383. pmac_ide_hwif_t *pmif =
  384. (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  385. if (drive->dn & 1)
  386. writel(pmif->timings[1], PMAC_IDE_REG(IDE_TIMING_CONFIG));
  387. else
  388. writel(pmif->timings[0], PMAC_IDE_REG(IDE_TIMING_CONFIG));
  389. (void)readl(PMAC_IDE_REG(IDE_TIMING_CONFIG));
  390. }
  391. /*
  392. * Apply the timings of the proper unit (master/slave) to the shared
  393. * timing register when selecting that unit. This version is for
  394. * ASICs with a dual timing register (Kauai)
  395. */
  396. static void
  397. pmac_ide_kauai_selectproc(ide_drive_t *drive)
  398. {
  399. ide_hwif_t *hwif = drive->hwif;
  400. pmac_ide_hwif_t *pmif =
  401. (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  402. if (drive->dn & 1) {
  403. writel(pmif->timings[1], PMAC_IDE_REG(IDE_KAUAI_PIO_CONFIG));
  404. writel(pmif->timings[3], PMAC_IDE_REG(IDE_KAUAI_ULTRA_CONFIG));
  405. } else {
  406. writel(pmif->timings[0], PMAC_IDE_REG(IDE_KAUAI_PIO_CONFIG));
  407. writel(pmif->timings[2], PMAC_IDE_REG(IDE_KAUAI_ULTRA_CONFIG));
  408. }
  409. (void)readl(PMAC_IDE_REG(IDE_KAUAI_PIO_CONFIG));
  410. }
  411. /*
  412. * Force an update of controller timing values for a given drive
  413. */
  414. static void
  415. pmac_ide_do_update_timings(ide_drive_t *drive)
  416. {
  417. ide_hwif_t *hwif = drive->hwif;
  418. pmac_ide_hwif_t *pmif =
  419. (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  420. if (pmif->kind == controller_sh_ata6 ||
  421. pmif->kind == controller_un_ata6 ||
  422. pmif->kind == controller_k2_ata6)
  423. pmac_ide_kauai_selectproc(drive);
  424. else
  425. pmac_ide_selectproc(drive);
  426. }
  427. static void pmac_exec_command(ide_hwif_t *hwif, u8 cmd)
  428. {
  429. writeb(cmd, (void __iomem *)hwif->io_ports.command_addr);
  430. (void)readl((void __iomem *)(hwif->io_ports.data_addr
  431. + IDE_TIMING_CONFIG));
  432. }
  433. static void pmac_write_devctl(ide_hwif_t *hwif, u8 ctl)
  434. {
  435. writeb(ctl, (void __iomem *)hwif->io_ports.ctl_addr);
  436. (void)readl((void __iomem *)(hwif->io_ports.data_addr
  437. + IDE_TIMING_CONFIG));
  438. }
  439. /*
  440. * Old tuning functions (called on hdparm -p), sets up drive PIO timings
  441. */
  442. static void
  443. pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
  444. {
  445. ide_hwif_t *hwif = drive->hwif;
  446. pmac_ide_hwif_t *pmif =
  447. (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  448. struct ide_timing *tim = ide_timing_find_mode(XFER_PIO_0 + pio);
  449. u32 *timings, t;
  450. unsigned accessTicks, recTicks;
  451. unsigned accessTime, recTime;
  452. unsigned int cycle_time;
  453. /* which drive is it ? */
  454. timings = &pmif->timings[drive->dn & 1];
  455. t = *timings;
  456. cycle_time = ide_pio_cycle_time(drive, pio);
  457. switch (pmif->kind) {
  458. case controller_sh_ata6: {
  459. /* 133Mhz cell */
  460. u32 tr = kauai_lookup_timing(shasta_pio_timings, cycle_time);
  461. t = (t & ~TR_133_PIOREG_PIO_MASK) | tr;
  462. break;
  463. }
  464. case controller_un_ata6:
  465. case controller_k2_ata6: {
  466. /* 100Mhz cell */
  467. u32 tr = kauai_lookup_timing(kauai_pio_timings, cycle_time);
  468. t = (t & ~TR_100_PIOREG_PIO_MASK) | tr;
  469. break;
  470. }
  471. case controller_kl_ata4:
  472. /* 66Mhz cell */
  473. recTime = cycle_time - tim->active - tim->setup;
  474. recTime = max(recTime, 150U);
  475. accessTime = tim->active;
  476. accessTime = max(accessTime, 150U);
  477. accessTicks = SYSCLK_TICKS_66(accessTime);
  478. accessTicks = min(accessTicks, 0x1fU);
  479. recTicks = SYSCLK_TICKS_66(recTime);
  480. recTicks = min(recTicks, 0x1fU);
  481. t = (t & ~TR_66_PIO_MASK) |
  482. (accessTicks << TR_66_PIO_ACCESS_SHIFT) |
  483. (recTicks << TR_66_PIO_RECOVERY_SHIFT);
  484. break;
  485. default: {
  486. /* 33Mhz cell */
  487. int ebit = 0;
  488. recTime = cycle_time - tim->active - tim->setup;
  489. recTime = max(recTime, 150U);
  490. accessTime = tim->active;
  491. accessTime = max(accessTime, 150U);
  492. accessTicks = SYSCLK_TICKS(accessTime);
  493. accessTicks = min(accessTicks, 0x1fU);
  494. accessTicks = max(accessTicks, 4U);
  495. recTicks = SYSCLK_TICKS(recTime);
  496. recTicks = min(recTicks, 0x1fU);
  497. recTicks = max(recTicks, 5U) - 4;
  498. if (recTicks > 9) {
  499. recTicks--; /* guess, but it's only for PIO0, so... */
  500. ebit = 1;
  501. }
  502. t = (t & ~TR_33_PIO_MASK) |
  503. (accessTicks << TR_33_PIO_ACCESS_SHIFT) |
  504. (recTicks << TR_33_PIO_RECOVERY_SHIFT);
  505. if (ebit)
  506. t |= TR_33_PIO_E;
  507. break;
  508. }
  509. }
  510. #ifdef IDE_PMAC_DEBUG
  511. printk(KERN_ERR "%s: Set PIO timing for mode %d, reg: 0x%08x\n",
  512. drive->name, pio, *timings);
  513. #endif
  514. *timings = t;
  515. pmac_ide_do_update_timings(drive);
  516. }
  517. /*
  518. * Calculate KeyLargo ATA/66 UDMA timings
  519. */
  520. static int
  521. set_timings_udma_ata4(u32 *timings, u8 speed)
  522. {
  523. unsigned rdyToPauseTicks, wrDataSetupTicks, addrTicks;
  524. if (speed > XFER_UDMA_4)
  525. return 1;
  526. rdyToPauseTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].rdy2pause);
  527. wrDataSetupTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].wrDataSetup);
  528. addrTicks = SYSCLK_TICKS_66(kl66_udma_timings[speed & 0xf].addrSetup);
  529. *timings = ((*timings) & ~(TR_66_UDMA_MASK | TR_66_MDMA_MASK)) |
  530. (wrDataSetupTicks << TR_66_UDMA_WRDATASETUP_SHIFT) |
  531. (rdyToPauseTicks << TR_66_UDMA_RDY2PAUS_SHIFT) |
  532. (addrTicks <<TR_66_UDMA_ADDRSETUP_SHIFT) |
  533. TR_66_UDMA_EN;
  534. #ifdef IDE_PMAC_DEBUG
  535. printk(KERN_ERR "ide_pmac: Set UDMA timing for mode %d, reg: 0x%08x\n",
  536. speed & 0xf, *timings);
  537. #endif
  538. return 0;
  539. }
  540. /*
  541. * Calculate Kauai ATA/100 UDMA timings
  542. */
  543. static int
  544. set_timings_udma_ata6(u32 *pio_timings, u32 *ultra_timings, u8 speed)
  545. {
  546. struct ide_timing *t = ide_timing_find_mode(speed);
  547. u32 tr;
  548. if (speed > XFER_UDMA_5 || t == NULL)
  549. return 1;
  550. tr = kauai_lookup_timing(kauai_udma_timings, (int)t->udma);
  551. *ultra_timings = ((*ultra_timings) & ~TR_100_UDMAREG_UDMA_MASK) | tr;
  552. *ultra_timings = (*ultra_timings) | TR_100_UDMAREG_UDMA_EN;
  553. return 0;
  554. }
  555. /*
  556. * Calculate Shasta ATA/133 UDMA timings
  557. */
  558. static int
  559. set_timings_udma_shasta(u32 *pio_timings, u32 *ultra_timings, u8 speed)
  560. {
  561. struct ide_timing *t = ide_timing_find_mode(speed);
  562. u32 tr;
  563. if (speed > XFER_UDMA_6 || t == NULL)
  564. return 1;
  565. tr = kauai_lookup_timing(shasta_udma133_timings, (int)t->udma);
  566. *ultra_timings = ((*ultra_timings) & ~TR_133_UDMAREG_UDMA_MASK) | tr;
  567. *ultra_timings = (*ultra_timings) | TR_133_UDMAREG_UDMA_EN;
  568. return 0;
  569. }
  570. /*
  571. * Calculate MDMA timings for all cells
  572. */
  573. static void
  574. set_timings_mdma(ide_drive_t *drive, int intf_type, u32 *timings, u32 *timings2,
  575. u8 speed)
  576. {
  577. u16 *id = drive->id;
  578. int cycleTime, accessTime = 0, recTime = 0;
  579. unsigned accessTicks, recTicks;
  580. struct mdma_timings_t* tm = NULL;
  581. int i;
  582. /* Get default cycle time for mode */
  583. switch(speed & 0xf) {
  584. case 0: cycleTime = 480; break;
  585. case 1: cycleTime = 150; break;
  586. case 2: cycleTime = 120; break;
  587. default:
  588. BUG();
  589. break;
  590. }
  591. /* Check if drive provides explicit DMA cycle time */
  592. if ((id[ATA_ID_FIELD_VALID] & 2) && id[ATA_ID_EIDE_DMA_TIME])
  593. cycleTime = max_t(int, id[ATA_ID_EIDE_DMA_TIME], cycleTime);
  594. /* OHare limits according to some old Apple sources */
  595. if ((intf_type == controller_ohare) && (cycleTime < 150))
  596. cycleTime = 150;
  597. /* Get the proper timing array for this controller */
  598. switch(intf_type) {
  599. case controller_sh_ata6:
  600. case controller_un_ata6:
  601. case controller_k2_ata6:
  602. break;
  603. case controller_kl_ata4:
  604. tm = mdma_timings_66;
  605. break;
  606. case controller_kl_ata3:
  607. tm = mdma_timings_33k;
  608. break;
  609. default:
  610. tm = mdma_timings_33;
  611. break;
  612. }
  613. if (tm != NULL) {
  614. /* Lookup matching access & recovery times */
  615. i = -1;
  616. for (;;) {
  617. if (tm[i+1].cycleTime < cycleTime)
  618. break;
  619. i++;
  620. }
  621. cycleTime = tm[i].cycleTime;
  622. accessTime = tm[i].accessTime;
  623. recTime = tm[i].recoveryTime;
  624. #ifdef IDE_PMAC_DEBUG
  625. printk(KERN_ERR "%s: MDMA, cycleTime: %d, accessTime: %d, recTime: %d\n",
  626. drive->name, cycleTime, accessTime, recTime);
  627. #endif
  628. }
  629. switch(intf_type) {
  630. case controller_sh_ata6: {
  631. /* 133Mhz cell */
  632. u32 tr = kauai_lookup_timing(shasta_mdma_timings, cycleTime);
  633. *timings = ((*timings) & ~TR_133_PIOREG_MDMA_MASK) | tr;
  634. *timings2 = (*timings2) & ~TR_133_UDMAREG_UDMA_EN;
  635. }
  636. case controller_un_ata6:
  637. case controller_k2_ata6: {
  638. /* 100Mhz cell */
  639. u32 tr = kauai_lookup_timing(kauai_mdma_timings, cycleTime);
  640. *timings = ((*timings) & ~TR_100_PIOREG_MDMA_MASK) | tr;
  641. *timings2 = (*timings2) & ~TR_100_UDMAREG_UDMA_EN;
  642. }
  643. break;
  644. case controller_kl_ata4:
  645. /* 66Mhz cell */
  646. accessTicks = SYSCLK_TICKS_66(accessTime);
  647. accessTicks = min(accessTicks, 0x1fU);
  648. accessTicks = max(accessTicks, 0x1U);
  649. recTicks = SYSCLK_TICKS_66(recTime);
  650. recTicks = min(recTicks, 0x1fU);
  651. recTicks = max(recTicks, 0x3U);
  652. /* Clear out mdma bits and disable udma */
  653. *timings = ((*timings) & ~(TR_66_MDMA_MASK | TR_66_UDMA_MASK)) |
  654. (accessTicks << TR_66_MDMA_ACCESS_SHIFT) |
  655. (recTicks << TR_66_MDMA_RECOVERY_SHIFT);
  656. break;
  657. case controller_kl_ata3:
  658. /* 33Mhz cell on KeyLargo */
  659. accessTicks = SYSCLK_TICKS(accessTime);
  660. accessTicks = max(accessTicks, 1U);
  661. accessTicks = min(accessTicks, 0x1fU);
  662. accessTime = accessTicks * IDE_SYSCLK_NS;
  663. recTicks = SYSCLK_TICKS(recTime);
  664. recTicks = max(recTicks, 1U);
  665. recTicks = min(recTicks, 0x1fU);
  666. *timings = ((*timings) & ~TR_33_MDMA_MASK) |
  667. (accessTicks << TR_33_MDMA_ACCESS_SHIFT) |
  668. (recTicks << TR_33_MDMA_RECOVERY_SHIFT);
  669. break;
  670. default: {
  671. /* 33Mhz cell on others */
  672. int halfTick = 0;
  673. int origAccessTime = accessTime;
  674. int origRecTime = recTime;
  675. accessTicks = SYSCLK_TICKS(accessTime);
  676. accessTicks = max(accessTicks, 1U);
  677. accessTicks = min(accessTicks, 0x1fU);
  678. accessTime = accessTicks * IDE_SYSCLK_NS;
  679. recTicks = SYSCLK_TICKS(recTime);
  680. recTicks = max(recTicks, 2U) - 1;
  681. recTicks = min(recTicks, 0x1fU);
  682. recTime = (recTicks + 1) * IDE_SYSCLK_NS;
  683. if ((accessTicks > 1) &&
  684. ((accessTime - IDE_SYSCLK_NS/2) >= origAccessTime) &&
  685. ((recTime - IDE_SYSCLK_NS/2) >= origRecTime)) {
  686. halfTick = 1;
  687. accessTicks--;
  688. }
  689. *timings = ((*timings) & ~TR_33_MDMA_MASK) |
  690. (accessTicks << TR_33_MDMA_ACCESS_SHIFT) |
  691. (recTicks << TR_33_MDMA_RECOVERY_SHIFT);
  692. if (halfTick)
  693. *timings |= TR_33_MDMA_HALFTICK;
  694. }
  695. }
  696. #ifdef IDE_PMAC_DEBUG
  697. printk(KERN_ERR "%s: Set MDMA timing for mode %d, reg: 0x%08x\n",
  698. drive->name, speed & 0xf, *timings);
  699. #endif
  700. }
  701. static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed)
  702. {
  703. ide_hwif_t *hwif = drive->hwif;
  704. pmac_ide_hwif_t *pmif =
  705. (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  706. int ret = 0;
  707. u32 *timings, *timings2, tl[2];
  708. u8 unit = drive->dn & 1;
  709. timings = &pmif->timings[unit];
  710. timings2 = &pmif->timings[unit+2];
  711. /* Copy timings to local image */
  712. tl[0] = *timings;
  713. tl[1] = *timings2;
  714. if (speed >= XFER_UDMA_0) {
  715. if (pmif->kind == controller_kl_ata4)
  716. ret = set_timings_udma_ata4(&tl[0], speed);
  717. else if (pmif->kind == controller_un_ata6
  718. || pmif->kind == controller_k2_ata6)
  719. ret = set_timings_udma_ata6(&tl[0], &tl[1], speed);
  720. else if (pmif->kind == controller_sh_ata6)
  721. ret = set_timings_udma_shasta(&tl[0], &tl[1], speed);
  722. else
  723. ret = -1;
  724. } else
  725. set_timings_mdma(drive, pmif->kind, &tl[0], &tl[1], speed);
  726. if (ret)
  727. return;
  728. /* Apply timings to controller */
  729. *timings = tl[0];
  730. *timings2 = tl[1];
  731. pmac_ide_do_update_timings(drive);
  732. }
  733. /*
  734. * Blast some well known "safe" values to the timing registers at init or
  735. * wakeup from sleep time, before we do real calculation
  736. */
  737. static void
  738. sanitize_timings(pmac_ide_hwif_t *pmif)
  739. {
  740. unsigned int value, value2 = 0;
  741. switch(pmif->kind) {
  742. case controller_sh_ata6:
  743. value = 0x0a820c97;
  744. value2 = 0x00033031;
  745. break;
  746. case controller_un_ata6:
  747. case controller_k2_ata6:
  748. value = 0x08618a92;
  749. value2 = 0x00002921;
  750. break;
  751. case controller_kl_ata4:
  752. value = 0x0008438c;
  753. break;
  754. case controller_kl_ata3:
  755. value = 0x00084526;
  756. break;
  757. case controller_heathrow:
  758. case controller_ohare:
  759. default:
  760. value = 0x00074526;
  761. break;
  762. }
  763. pmif->timings[0] = pmif->timings[1] = value;
  764. pmif->timings[2] = pmif->timings[3] = value2;
  765. }
  766. /* Suspend call back, should be called after the child devices
  767. * have actually been suspended
  768. */
  769. static int pmac_ide_do_suspend(pmac_ide_hwif_t *pmif)
  770. {
  771. /* We clear the timings */
  772. pmif->timings[0] = 0;
  773. pmif->timings[1] = 0;
  774. disable_irq(pmif->irq);
  775. /* The media bay will handle itself just fine */
  776. if (pmif->mediabay)
  777. return 0;
  778. /* Kauai has bus control FCRs directly here */
  779. if (pmif->kauai_fcr) {
  780. u32 fcr = readl(pmif->kauai_fcr);
  781. fcr &= ~(KAUAI_FCR_UATA_RESET_N | KAUAI_FCR_UATA_ENABLE);
  782. writel(fcr, pmif->kauai_fcr);
  783. }
  784. /* Disable the bus on older machines and the cell on kauai */
  785. ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id,
  786. 0);
  787. return 0;
  788. }
  789. /* Resume call back, should be called before the child devices
  790. * are resumed
  791. */
  792. static int pmac_ide_do_resume(pmac_ide_hwif_t *pmif)
  793. {
  794. /* Hard reset & re-enable controller (do we really need to reset ? -BenH) */
  795. if (!pmif->mediabay) {
  796. ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 1);
  797. ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 1);
  798. msleep(10);
  799. ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 0);
  800. /* Kauai has it different */
  801. if (pmif->kauai_fcr) {
  802. u32 fcr = readl(pmif->kauai_fcr);
  803. fcr |= KAUAI_FCR_UATA_RESET_N | KAUAI_FCR_UATA_ENABLE;
  804. writel(fcr, pmif->kauai_fcr);
  805. }
  806. msleep(jiffies_to_msecs(IDE_WAKEUP_DELAY));
  807. }
  808. /* Sanitize drive timings */
  809. sanitize_timings(pmif);
  810. enable_irq(pmif->irq);
  811. return 0;
  812. }
  813. static u8 pmac_ide_cable_detect(ide_hwif_t *hwif)
  814. {
  815. pmac_ide_hwif_t *pmif =
  816. (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  817. struct device_node *np = pmif->node;
  818. const char *cable = of_get_property(np, "cable-type", NULL);
  819. /* Get cable type from device-tree. */
  820. if (cable && !strncmp(cable, "80-", 3))
  821. return ATA_CBL_PATA80;
  822. /*
  823. * G5's seem to have incorrect cable type in device-tree.
  824. * Let's assume they have a 80 conductor cable, this seem
  825. * to be always the case unless the user mucked around.
  826. */
  827. if (of_device_is_compatible(np, "K2-UATA") ||
  828. of_device_is_compatible(np, "shasta-ata"))
  829. return ATA_CBL_PATA80;
  830. return ATA_CBL_PATA40;
  831. }
  832. static void pmac_ide_init_dev(ide_drive_t *drive)
  833. {
  834. ide_hwif_t *hwif = drive->hwif;
  835. pmac_ide_hwif_t *pmif =
  836. (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  837. if (pmif->mediabay) {
  838. #ifdef CONFIG_PMAC_MEDIABAY
  839. if (check_media_bay_by_base(pmif->regbase, MB_CD) == 0) {
  840. drive->dev_flags &= ~IDE_DFLAG_NOPROBE;
  841. return;
  842. }
  843. #endif
  844. drive->dev_flags |= IDE_DFLAG_NOPROBE;
  845. }
  846. }
  847. static const struct ide_tp_ops pmac_tp_ops = {
  848. .exec_command = pmac_exec_command,
  849. .read_status = ide_read_status,
  850. .read_altstatus = ide_read_altstatus,
  851. .write_devctl = pmac_write_devctl,
  852. .tf_load = ide_tf_load,
  853. .tf_read = ide_tf_read,
  854. .input_data = ide_input_data,
  855. .output_data = ide_output_data,
  856. };
  857. static const struct ide_port_ops pmac_ide_ata6_port_ops = {
  858. .init_dev = pmac_ide_init_dev,
  859. .set_pio_mode = pmac_ide_set_pio_mode,
  860. .set_dma_mode = pmac_ide_set_dma_mode,
  861. .selectproc = pmac_ide_kauai_selectproc,
  862. .cable_detect = pmac_ide_cable_detect,
  863. };
  864. static const struct ide_port_ops pmac_ide_ata4_port_ops = {
  865. .init_dev = pmac_ide_init_dev,
  866. .set_pio_mode = pmac_ide_set_pio_mode,
  867. .set_dma_mode = pmac_ide_set_dma_mode,
  868. .selectproc = pmac_ide_selectproc,
  869. .cable_detect = pmac_ide_cable_detect,
  870. };
  871. static const struct ide_port_ops pmac_ide_port_ops = {
  872. .init_dev = pmac_ide_init_dev,
  873. .set_pio_mode = pmac_ide_set_pio_mode,
  874. .set_dma_mode = pmac_ide_set_dma_mode,
  875. .selectproc = pmac_ide_selectproc,
  876. };
  877. static const struct ide_dma_ops pmac_dma_ops;
  878. static const struct ide_port_info pmac_port_info = {
  879. .name = DRV_NAME,
  880. .init_dma = pmac_ide_init_dma,
  881. .chipset = ide_pmac,
  882. .tp_ops = &pmac_tp_ops,
  883. .port_ops = &pmac_ide_port_ops,
  884. .dma_ops = &pmac_dma_ops,
  885. .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA |
  886. IDE_HFLAG_POST_SET_MODE |
  887. IDE_HFLAG_MMIO |
  888. IDE_HFLAG_UNMASK_IRQS,
  889. .pio_mask = ATA_PIO4,
  890. .mwdma_mask = ATA_MWDMA2,
  891. };
  892. /*
  893. * Setup, register & probe an IDE channel driven by this driver, this is
  894. * called by one of the 2 probe functions (macio or PCI).
  895. */
  896. static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
  897. {
  898. struct device_node *np = pmif->node;
  899. const int *bidp;
  900. struct ide_host *host;
  901. ide_hwif_t *hwif;
  902. hw_regs_t *hws[] = { hw, NULL, NULL, NULL };
  903. struct ide_port_info d = pmac_port_info;
  904. int rc;
  905. pmif->broken_dma = pmif->broken_dma_warn = 0;
  906. if (of_device_is_compatible(np, "shasta-ata")) {
  907. pmif->kind = controller_sh_ata6;
  908. d.port_ops = &pmac_ide_ata6_port_ops;
  909. d.udma_mask = ATA_UDMA6;
  910. } else if (of_device_is_compatible(np, "kauai-ata")) {
  911. pmif->kind = controller_un_ata6;
  912. d.port_ops = &pmac_ide_ata6_port_ops;
  913. d.udma_mask = ATA_UDMA5;
  914. } else if (of_device_is_compatible(np, "K2-UATA")) {
  915. pmif->kind = controller_k2_ata6;
  916. d.port_ops = &pmac_ide_ata6_port_ops;
  917. d.udma_mask = ATA_UDMA5;
  918. } else if (of_device_is_compatible(np, "keylargo-ata")) {
  919. if (strcmp(np->name, "ata-4") == 0) {
  920. pmif->kind = controller_kl_ata4;
  921. d.port_ops = &pmac_ide_ata4_port_ops;
  922. d.udma_mask = ATA_UDMA4;
  923. } else
  924. pmif->kind = controller_kl_ata3;
  925. } else if (of_device_is_compatible(np, "heathrow-ata")) {
  926. pmif->kind = controller_heathrow;
  927. } else {
  928. pmif->kind = controller_ohare;
  929. pmif->broken_dma = 1;
  930. }
  931. bidp = of_get_property(np, "AAPL,bus-id", NULL);
  932. pmif->aapl_bus_id = bidp ? *bidp : 0;
  933. /* On Kauai-type controllers, we make sure the FCR is correct */
  934. if (pmif->kauai_fcr)
  935. writel(KAUAI_FCR_UATA_MAGIC |
  936. KAUAI_FCR_UATA_RESET_N |
  937. KAUAI_FCR_UATA_ENABLE, pmif->kauai_fcr);
  938. pmif->mediabay = 0;
  939. /* Make sure we have sane timings */
  940. sanitize_timings(pmif);
  941. host = ide_host_alloc(&d, hws);
  942. if (host == NULL)
  943. return -ENOMEM;
  944. hwif = host->ports[0];
  945. #ifndef CONFIG_PPC64
  946. /* XXX FIXME: Media bay stuff need re-organizing */
  947. if (np->parent && np->parent->name
  948. && strcasecmp(np->parent->name, "media-bay") == 0) {
  949. #ifdef CONFIG_PMAC_MEDIABAY
  950. media_bay_set_ide_infos(np->parent, pmif->regbase, pmif->irq,
  951. hwif);
  952. #endif /* CONFIG_PMAC_MEDIABAY */
  953. pmif->mediabay = 1;
  954. if (!bidp)
  955. pmif->aapl_bus_id = 1;
  956. } else if (pmif->kind == controller_ohare) {
  957. /* The code below is having trouble on some ohare machines
  958. * (timing related ?). Until I can put my hand on one of these
  959. * units, I keep the old way
  960. */
  961. ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, 0, 1);
  962. } else
  963. #endif
  964. {
  965. /* This is necessary to enable IDE when net-booting */
  966. ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 1);
  967. ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, np, pmif->aapl_bus_id, 1);
  968. msleep(10);
  969. ppc_md.feature_call(PMAC_FTR_IDE_RESET, np, pmif->aapl_bus_id, 0);
  970. msleep(jiffies_to_msecs(IDE_WAKEUP_DELAY));
  971. }
  972. printk(KERN_INFO DRV_NAME ": Found Apple %s controller (%s), "
  973. "bus ID %d%s, irq %d\n", model_name[pmif->kind],
  974. pmif->mdev ? "macio" : "PCI", pmif->aapl_bus_id,
  975. pmif->mediabay ? " (mediabay)" : "", hw->irq);
  976. rc = ide_host_register(host, &d, hws);
  977. if (rc) {
  978. ide_host_free(host);
  979. return rc;
  980. }
  981. return 0;
  982. }
  983. static void __devinit pmac_ide_init_ports(hw_regs_t *hw, unsigned long base)
  984. {
  985. int i;
  986. for (i = 0; i < 8; ++i)
  987. hw->io_ports_array[i] = base + i * 0x10;
  988. hw->io_ports.ctl_addr = base + 0x160;
  989. }
  990. /*
  991. * Attach to a macio probed interface
  992. */
  993. static int __devinit
  994. pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
  995. {
  996. void __iomem *base;
  997. unsigned long regbase;
  998. pmac_ide_hwif_t *pmif;
  999. int irq, rc;
  1000. hw_regs_t hw;
  1001. pmif = kzalloc(sizeof(*pmif), GFP_KERNEL);
  1002. if (pmif == NULL)
  1003. return -ENOMEM;
  1004. if (macio_resource_count(mdev) == 0) {
  1005. printk(KERN_WARNING "ide-pmac: no address for %s\n",
  1006. mdev->ofdev.node->full_name);
  1007. rc = -ENXIO;
  1008. goto out_free_pmif;
  1009. }
  1010. /* Request memory resource for IO ports */
  1011. if (macio_request_resource(mdev, 0, "ide-pmac (ports)")) {
  1012. printk(KERN_ERR "ide-pmac: can't request MMIO resource for "
  1013. "%s!\n", mdev->ofdev.node->full_name);
  1014. rc = -EBUSY;
  1015. goto out_free_pmif;
  1016. }
  1017. /* XXX This is bogus. Should be fixed in the registry by checking
  1018. * the kind of host interrupt controller, a bit like gatwick
  1019. * fixes in irq.c. That works well enough for the single case
  1020. * where that happens though...
  1021. */
  1022. if (macio_irq_count(mdev) == 0) {
  1023. printk(KERN_WARNING "ide-pmac: no intrs for device %s, using "
  1024. "13\n", mdev->ofdev.node->full_name);
  1025. irq = irq_create_mapping(NULL, 13);
  1026. } else
  1027. irq = macio_irq(mdev, 0);
  1028. base = ioremap(macio_resource_start(mdev, 0), 0x400);
  1029. regbase = (unsigned long) base;
  1030. pmif->mdev = mdev;
  1031. pmif->node = mdev->ofdev.node;
  1032. pmif->regbase = regbase;
  1033. pmif->irq = irq;
  1034. pmif->kauai_fcr = NULL;
  1035. if (macio_resource_count(mdev) >= 2) {
  1036. if (macio_request_resource(mdev, 1, "ide-pmac (dma)"))
  1037. printk(KERN_WARNING "ide-pmac: can't request DMA "
  1038. "resource for %s!\n",
  1039. mdev->ofdev.node->full_name);
  1040. else
  1041. pmif->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x1000);
  1042. } else
  1043. pmif->dma_regs = NULL;
  1044. dev_set_drvdata(&mdev->ofdev.dev, pmif);
  1045. memset(&hw, 0, sizeof(hw));
  1046. pmac_ide_init_ports(&hw, pmif->regbase);
  1047. hw.irq = irq;
  1048. hw.dev = &mdev->bus->pdev->dev;
  1049. hw.parent = &mdev->ofdev.dev;
  1050. rc = pmac_ide_setup_device(pmif, &hw);
  1051. if (rc != 0) {
  1052. /* The inteface is released to the common IDE layer */
  1053. dev_set_drvdata(&mdev->ofdev.dev, NULL);
  1054. iounmap(base);
  1055. if (pmif->dma_regs) {
  1056. iounmap(pmif->dma_regs);
  1057. macio_release_resource(mdev, 1);
  1058. }
  1059. macio_release_resource(mdev, 0);
  1060. kfree(pmif);
  1061. }
  1062. return rc;
  1063. out_free_pmif:
  1064. kfree(pmif);
  1065. return rc;
  1066. }
  1067. static int
  1068. pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t mesg)
  1069. {
  1070. pmac_ide_hwif_t *pmif =
  1071. (pmac_ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
  1072. int rc = 0;
  1073. if (mesg.event != mdev->ofdev.dev.power.power_state.event
  1074. && (mesg.event & PM_EVENT_SLEEP)) {
  1075. rc = pmac_ide_do_suspend(pmif);
  1076. if (rc == 0)
  1077. mdev->ofdev.dev.power.power_state = mesg;
  1078. }
  1079. return rc;
  1080. }
  1081. static int
  1082. pmac_ide_macio_resume(struct macio_dev *mdev)
  1083. {
  1084. pmac_ide_hwif_t *pmif =
  1085. (pmac_ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
  1086. int rc = 0;
  1087. if (mdev->ofdev.dev.power.power_state.event != PM_EVENT_ON) {
  1088. rc = pmac_ide_do_resume(pmif);
  1089. if (rc == 0)
  1090. mdev->ofdev.dev.power.power_state = PMSG_ON;
  1091. }
  1092. return rc;
  1093. }
  1094. /*
  1095. * Attach to a PCI probed interface
  1096. */
  1097. static int __devinit
  1098. pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
  1099. {
  1100. struct device_node *np;
  1101. pmac_ide_hwif_t *pmif;
  1102. void __iomem *base;
  1103. unsigned long rbase, rlen;
  1104. int rc;
  1105. hw_regs_t hw;
  1106. np = pci_device_to_OF_node(pdev);
  1107. if (np == NULL) {
  1108. printk(KERN_ERR "ide-pmac: cannot find MacIO node for Kauai ATA interface\n");
  1109. return -ENODEV;
  1110. }
  1111. pmif = kzalloc(sizeof(*pmif), GFP_KERNEL);
  1112. if (pmif == NULL)
  1113. return -ENOMEM;
  1114. if (pci_enable_device(pdev)) {
  1115. printk(KERN_WARNING "ide-pmac: Can't enable PCI device for "
  1116. "%s\n", np->full_name);
  1117. rc = -ENXIO;
  1118. goto out_free_pmif;
  1119. }
  1120. pci_set_master(pdev);
  1121. if (pci_request_regions(pdev, "Kauai ATA")) {
  1122. printk(KERN_ERR "ide-pmac: Cannot obtain PCI resources for "
  1123. "%s\n", np->full_name);
  1124. rc = -ENXIO;
  1125. goto out_free_pmif;
  1126. }
  1127. pmif->mdev = NULL;
  1128. pmif->node = np;
  1129. rbase = pci_resource_start(pdev, 0);
  1130. rlen = pci_resource_len(pdev, 0);
  1131. base = ioremap(rbase, rlen);
  1132. pmif->regbase = (unsigned long) base + 0x2000;
  1133. pmif->dma_regs = base + 0x1000;
  1134. pmif->kauai_fcr = base;
  1135. pmif->irq = pdev->irq;
  1136. pci_set_drvdata(pdev, pmif);
  1137. memset(&hw, 0, sizeof(hw));
  1138. pmac_ide_init_ports(&hw, pmif->regbase);
  1139. hw.irq = pdev->irq;
  1140. hw.dev = &pdev->dev;
  1141. rc = pmac_ide_setup_device(pmif, &hw);
  1142. if (rc != 0) {
  1143. /* The inteface is released to the common IDE layer */
  1144. pci_set_drvdata(pdev, NULL);
  1145. iounmap(base);
  1146. pci_release_regions(pdev);
  1147. kfree(pmif);
  1148. }
  1149. return rc;
  1150. out_free_pmif:
  1151. kfree(pmif);
  1152. return rc;
  1153. }
  1154. static int
  1155. pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
  1156. {
  1157. pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)pci_get_drvdata(pdev);
  1158. int rc = 0;
  1159. if (mesg.event != pdev->dev.power.power_state.event
  1160. && (mesg.event & PM_EVENT_SLEEP)) {
  1161. rc = pmac_ide_do_suspend(pmif);
  1162. if (rc == 0)
  1163. pdev->dev.power.power_state = mesg;
  1164. }
  1165. return rc;
  1166. }
  1167. static int
  1168. pmac_ide_pci_resume(struct pci_dev *pdev)
  1169. {
  1170. pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)pci_get_drvdata(pdev);
  1171. int rc = 0;
  1172. if (pdev->dev.power.power_state.event != PM_EVENT_ON) {
  1173. rc = pmac_ide_do_resume(pmif);
  1174. if (rc == 0)
  1175. pdev->dev.power.power_state = PMSG_ON;
  1176. }
  1177. return rc;
  1178. }
  1179. static struct of_device_id pmac_ide_macio_match[] =
  1180. {
  1181. {
  1182. .name = "IDE",
  1183. },
  1184. {
  1185. .name = "ATA",
  1186. },
  1187. {
  1188. .type = "ide",
  1189. },
  1190. {
  1191. .type = "ata",
  1192. },
  1193. {},
  1194. };
  1195. static struct macio_driver pmac_ide_macio_driver =
  1196. {
  1197. .name = "ide-pmac",
  1198. .match_table = pmac_ide_macio_match,
  1199. .probe = pmac_ide_macio_attach,
  1200. .suspend = pmac_ide_macio_suspend,
  1201. .resume = pmac_ide_macio_resume,
  1202. };
  1203. static const struct pci_device_id pmac_ide_pci_match[] = {
  1204. { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_UNI_N_ATA), 0 },
  1205. { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_IPID_ATA100), 0 },
  1206. { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_K2_ATA100), 0 },
  1207. { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_SH_ATA), 0 },
  1208. { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_IPID2_ATA), 0 },
  1209. {},
  1210. };
  1211. static struct pci_driver pmac_ide_pci_driver = {
  1212. .name = "ide-pmac",
  1213. .id_table = pmac_ide_pci_match,
  1214. .probe = pmac_ide_pci_attach,
  1215. .suspend = pmac_ide_pci_suspend,
  1216. .resume = pmac_ide_pci_resume,
  1217. };
  1218. MODULE_DEVICE_TABLE(pci, pmac_ide_pci_match);
  1219. int __init pmac_ide_probe(void)
  1220. {
  1221. int error;
  1222. if (!machine_is(powermac))
  1223. return -ENODEV;
  1224. #ifdef CONFIG_BLK_DEV_IDE_PMAC_ATA100FIRST
  1225. error = pci_register_driver(&pmac_ide_pci_driver);
  1226. if (error)
  1227. goto out;
  1228. error = macio_register_driver(&pmac_ide_macio_driver);
  1229. if (error) {
  1230. pci_unregister_driver(&pmac_ide_pci_driver);
  1231. goto out;
  1232. }
  1233. #else
  1234. error = macio_register_driver(&pmac_ide_macio_driver);
  1235. if (error)
  1236. goto out;
  1237. error = pci_register_driver(&pmac_ide_pci_driver);
  1238. if (error) {
  1239. macio_unregister_driver(&pmac_ide_macio_driver);
  1240. goto out;
  1241. }
  1242. #endif
  1243. out:
  1244. return error;
  1245. }
  1246. /*
  1247. * pmac_ide_build_dmatable builds the DBDMA command list
  1248. * for a transfer and sets the DBDMA channel to point to it.
  1249. */
  1250. static int pmac_ide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd)
  1251. {
  1252. ide_hwif_t *hwif = drive->hwif;
  1253. pmac_ide_hwif_t *pmif =
  1254. (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  1255. struct dbdma_cmd *table;
  1256. volatile struct dbdma_regs __iomem *dma = pmif->dma_regs;
  1257. struct scatterlist *sg;
  1258. int wr = !!(cmd->tf_flags & IDE_TFLAG_WRITE);
  1259. int i = cmd->sg_nents, count = 0;
  1260. /* DMA table is already aligned */
  1261. table = (struct dbdma_cmd *) pmif->dma_table_cpu;
  1262. /* Make sure DMA controller is stopped (necessary ?) */
  1263. writel((RUN|PAUSE|FLUSH|WAKE|DEAD) << 16, &dma->control);
  1264. while (readl(&dma->status) & RUN)
  1265. udelay(1);
  1266. /* Build DBDMA commands list */
  1267. sg = hwif->sg_table;
  1268. while (i && sg_dma_len(sg)) {
  1269. u32 cur_addr;
  1270. u32 cur_len;
  1271. cur_addr = sg_dma_address(sg);
  1272. cur_len = sg_dma_len(sg);
  1273. if (pmif->broken_dma && cur_addr & (L1_CACHE_BYTES - 1)) {
  1274. if (pmif->broken_dma_warn == 0) {
  1275. printk(KERN_WARNING "%s: DMA on non aligned address, "
  1276. "switching to PIO on Ohare chipset\n", drive->name);
  1277. pmif->broken_dma_warn = 1;
  1278. }
  1279. return 0;
  1280. }
  1281. while (cur_len) {
  1282. unsigned int tc = (cur_len < 0xfe00)? cur_len: 0xfe00;
  1283. if (count++ >= MAX_DCMDS) {
  1284. printk(KERN_WARNING "%s: DMA table too small\n",
  1285. drive->name);
  1286. return 0;
  1287. }
  1288. st_le16(&table->command, wr? OUTPUT_MORE: INPUT_MORE);
  1289. st_le16(&table->req_count, tc);
  1290. st_le32(&table->phy_addr, cur_addr);
  1291. table->cmd_dep = 0;
  1292. table->xfer_status = 0;
  1293. table->res_count = 0;
  1294. cur_addr += tc;
  1295. cur_len -= tc;
  1296. ++table;
  1297. }
  1298. sg = sg_next(sg);
  1299. i--;
  1300. }
  1301. /* convert the last command to an input/output last command */
  1302. if (count) {
  1303. st_le16(&table[-1].command, wr? OUTPUT_LAST: INPUT_LAST);
  1304. /* add the stop command to the end of the list */
  1305. memset(table, 0, sizeof(struct dbdma_cmd));
  1306. st_le16(&table->command, DBDMA_STOP);
  1307. mb();
  1308. writel(hwif->dmatable_dma, &dma->cmdptr);
  1309. return 1;
  1310. }
  1311. printk(KERN_DEBUG "%s: empty DMA table?\n", drive->name);
  1312. return 0; /* revert to PIO for this request */
  1313. }
  1314. /*
  1315. * Prepare a DMA transfer. We build the DMA table, adjust the timings for
  1316. * a read on KeyLargo ATA/66 and mark us as waiting for DMA completion
  1317. */
  1318. static int pmac_ide_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
  1319. {
  1320. ide_hwif_t *hwif = drive->hwif;
  1321. pmac_ide_hwif_t *pmif =
  1322. (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  1323. u8 unit = drive->dn & 1, ata4 = (pmif->kind == controller_kl_ata4);
  1324. u8 write = !!(cmd->tf_flags & IDE_TFLAG_WRITE);
  1325. if (pmac_ide_build_dmatable(drive, cmd) == 0)
  1326. return 1;
  1327. /* Apple adds 60ns to wrDataSetup on reads */
  1328. if (ata4 && (pmif->timings[unit] & TR_66_UDMA_EN)) {
  1329. writel(pmif->timings[unit] + (write ? 0 : 0x00800000UL),
  1330. PMAC_IDE_REG(IDE_TIMING_CONFIG));
  1331. (void)readl(PMAC_IDE_REG(IDE_TIMING_CONFIG));
  1332. }
  1333. return 0;
  1334. }
  1335. /*
  1336. * Kick the DMA controller into life after the DMA command has been issued
  1337. * to the drive.
  1338. */
  1339. static void
  1340. pmac_ide_dma_start(ide_drive_t *drive)
  1341. {
  1342. ide_hwif_t *hwif = drive->hwif;
  1343. pmac_ide_hwif_t *pmif =
  1344. (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  1345. volatile struct dbdma_regs __iomem *dma;
  1346. dma = pmif->dma_regs;
  1347. writel((RUN << 16) | RUN, &dma->control);
  1348. /* Make sure it gets to the controller right now */
  1349. (void)readl(&dma->control);
  1350. }
  1351. /*
  1352. * After a DMA transfer, make sure the controller is stopped
  1353. */
  1354. static int
  1355. pmac_ide_dma_end (ide_drive_t *drive)
  1356. {
  1357. ide_hwif_t *hwif = drive->hwif;
  1358. pmac_ide_hwif_t *pmif =
  1359. (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  1360. volatile struct dbdma_regs __iomem *dma = pmif->dma_regs;
  1361. u32 dstat;
  1362. dstat = readl(&dma->status);
  1363. writel(((RUN|WAKE|DEAD) << 16), &dma->control);
  1364. /* verify good dma status. we don't check for ACTIVE beeing 0. We should...
  1365. * in theory, but with ATAPI decices doing buffer underruns, that would
  1366. * cause us to disable DMA, which isn't what we want
  1367. */
  1368. return (dstat & (RUN|DEAD)) != RUN;
  1369. }
  1370. /*
  1371. * Check out that the interrupt we got was for us. We can't always know this
  1372. * for sure with those Apple interfaces (well, we could on the recent ones but
  1373. * that's not implemented yet), on the other hand, we don't have shared interrupts
  1374. * so it's not really a problem
  1375. */
  1376. static int
  1377. pmac_ide_dma_test_irq (ide_drive_t *drive)
  1378. {
  1379. ide_hwif_t *hwif = drive->hwif;
  1380. pmac_ide_hwif_t *pmif =
  1381. (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  1382. volatile struct dbdma_regs __iomem *dma = pmif->dma_regs;
  1383. unsigned long status, timeout;
  1384. /* We have to things to deal with here:
  1385. *
  1386. * - The dbdma won't stop if the command was started
  1387. * but completed with an error without transferring all
  1388. * datas. This happens when bad blocks are met during
  1389. * a multi-block transfer.
  1390. *
  1391. * - The dbdma fifo hasn't yet finished flushing to
  1392. * to system memory when the disk interrupt occurs.
  1393. *
  1394. */
  1395. /* If ACTIVE is cleared, the STOP command have passed and
  1396. * transfer is complete.
  1397. */
  1398. status = readl(&dma->status);
  1399. if (!(status & ACTIVE))
  1400. return 1;
  1401. /* If dbdma didn't execute the STOP command yet, the
  1402. * active bit is still set. We consider that we aren't
  1403. * sharing interrupts (which is hopefully the case with
  1404. * those controllers) and so we just try to flush the
  1405. * channel for pending data in the fifo
  1406. */
  1407. udelay(1);
  1408. writel((FLUSH << 16) | FLUSH, &dma->control);
  1409. timeout = 0;
  1410. for (;;) {
  1411. udelay(1);
  1412. status = readl(&dma->status);
  1413. if ((status & FLUSH) == 0)
  1414. break;
  1415. if (++timeout > 100) {
  1416. printk(KERN_WARNING "ide%d, ide_dma_test_irq \
  1417. timeout flushing channel\n", hwif->index);
  1418. break;
  1419. }
  1420. }
  1421. return 1;
  1422. }
  1423. static void pmac_ide_dma_host_set(ide_drive_t *drive, int on)
  1424. {
  1425. }
  1426. static void
  1427. pmac_ide_dma_lost_irq (ide_drive_t *drive)
  1428. {
  1429. ide_hwif_t *hwif = drive->hwif;
  1430. pmac_ide_hwif_t *pmif =
  1431. (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  1432. volatile struct dbdma_regs __iomem *dma = pmif->dma_regs;
  1433. unsigned long status = readl(&dma->status);
  1434. printk(KERN_ERR "ide-pmac lost interrupt, dma status: %lx\n", status);
  1435. }
  1436. static const struct ide_dma_ops pmac_dma_ops = {
  1437. .dma_host_set = pmac_ide_dma_host_set,
  1438. .dma_setup = pmac_ide_dma_setup,
  1439. .dma_start = pmac_ide_dma_start,
  1440. .dma_end = pmac_ide_dma_end,
  1441. .dma_test_irq = pmac_ide_dma_test_irq,
  1442. .dma_lost_irq = pmac_ide_dma_lost_irq,
  1443. };
  1444. /*
  1445. * Allocate the data structures needed for using DMA with an interface
  1446. * and fill the proper list of functions pointers
  1447. */
  1448. static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif,
  1449. const struct ide_port_info *d)
  1450. {
  1451. pmac_ide_hwif_t *pmif =
  1452. (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  1453. struct pci_dev *dev = to_pci_dev(hwif->dev);
  1454. /* We won't need pci_dev if we switch to generic consistent
  1455. * DMA routines ...
  1456. */
  1457. if (dev == NULL || pmif->dma_regs == 0)
  1458. return -ENODEV;
  1459. /*
  1460. * Allocate space for the DBDMA commands.
  1461. * The +2 is +1 for the stop command and +1 to allow for
  1462. * aligning the start address to a multiple of 16 bytes.
  1463. */
  1464. pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent(
  1465. dev,
  1466. (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd),
  1467. &hwif->dmatable_dma);
  1468. if (pmif->dma_table_cpu == NULL) {
  1469. printk(KERN_ERR "%s: unable to allocate DMA command list\n",
  1470. hwif->name);
  1471. return -ENOMEM;
  1472. }
  1473. hwif->sg_max_nents = MAX_DCMDS;
  1474. return 0;
  1475. }
  1476. module_init(pmac_ide_probe);
  1477. MODULE_LICENSE("GPL");