feature.c 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063
  1. /*
  2. * arch/ppc/platforms/pmac_feature.c
  3. *
  4. * Copyright (C) 1996-2001 Paul Mackerras (paulus@cs.anu.edu.au)
  5. * Ben. Herrenschmidt (benh@kernel.crashing.org)
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. *
  12. * TODO:
  13. *
  14. * - Replace mdelay with some schedule loop if possible
  15. * - Shorten some obfuscated delays on some routines (like modem
  16. * power)
  17. * - Refcount some clocks (see darwin)
  18. * - Split split split...
  19. *
  20. */
  21. #include <linux/config.h>
  22. #include <linux/types.h>
  23. #include <linux/init.h>
  24. #include <linux/delay.h>
  25. #include <linux/kernel.h>
  26. #include <linux/sched.h>
  27. #include <linux/spinlock.h>
  28. #include <linux/adb.h>
  29. #include <linux/pmu.h>
  30. #include <linux/ioport.h>
  31. #include <linux/pci.h>
  32. #include <asm/sections.h>
  33. #include <asm/errno.h>
  34. #include <asm/ohare.h>
  35. #include <asm/heathrow.h>
  36. #include <asm/keylargo.h>
  37. #include <asm/uninorth.h>
  38. #include <asm/io.h>
  39. #include <asm/prom.h>
  40. #include <asm/machdep.h>
  41. #include <asm/pmac_feature.h>
  42. #include <asm/dbdma.h>
  43. #include <asm/pci-bridge.h>
  44. #include <asm/pmac_low_i2c.h>
  45. #undef DEBUG_FEATURE
  46. #ifdef DEBUG_FEATURE
  47. #define DBG(fmt...) printk(KERN_DEBUG fmt)
  48. #else
  49. #define DBG(fmt...)
  50. #endif
  51. #ifdef CONFIG_6xx
  52. extern int powersave_lowspeed;
  53. #endif
  54. extern int powersave_nap;
  55. extern struct device_node *k2_skiplist[2];
  56. /*
  57. * We use a single global lock to protect accesses. Each driver has
  58. * to take care of its own locking
  59. */
  60. static DEFINE_SPINLOCK(feature_lock);
  61. #define LOCK(flags) spin_lock_irqsave(&feature_lock, flags);
  62. #define UNLOCK(flags) spin_unlock_irqrestore(&feature_lock, flags);
  63. /*
  64. * Instance of some macio stuffs
  65. */
  66. struct macio_chip macio_chips[MAX_MACIO_CHIPS];
  67. struct macio_chip *macio_find(struct device_node *child, int type)
  68. {
  69. while(child) {
  70. int i;
  71. for (i=0; i < MAX_MACIO_CHIPS && macio_chips[i].of_node; i++)
  72. if (child == macio_chips[i].of_node &&
  73. (!type || macio_chips[i].type == type))
  74. return &macio_chips[i];
  75. child = child->parent;
  76. }
  77. return NULL;
  78. }
  79. EXPORT_SYMBOL_GPL(macio_find);
  80. static const char *macio_names[] =
  81. {
  82. "Unknown",
  83. "Grand Central",
  84. "OHare",
  85. "OHareII",
  86. "Heathrow",
  87. "Gatwick",
  88. "Paddington",
  89. "Keylargo",
  90. "Pangea",
  91. "Intrepid",
  92. "K2"
  93. };
  94. /*
  95. * Uninorth reg. access. Note that Uni-N regs are big endian
  96. */
  97. #define UN_REG(r) (uninorth_base + ((r) >> 2))
  98. #define UN_IN(r) (in_be32(UN_REG(r)))
  99. #define UN_OUT(r,v) (out_be32(UN_REG(r), (v)))
  100. #define UN_BIS(r,v) (UN_OUT((r), UN_IN(r) | (v)))
  101. #define UN_BIC(r,v) (UN_OUT((r), UN_IN(r) & ~(v)))
  102. static struct device_node *uninorth_node;
  103. static u32 __iomem *uninorth_base;
  104. static u32 uninorth_rev;
  105. static int uninorth_u3;
  106. static void __iomem *u3_ht;
  107. /*
  108. * For each motherboard family, we have a table of functions pointers
  109. * that handle the various features.
  110. */
  111. typedef long (*feature_call)(struct device_node *node, long param, long value);
  112. struct feature_table_entry {
  113. unsigned int selector;
  114. feature_call function;
  115. };
  116. struct pmac_mb_def
  117. {
  118. const char* model_string;
  119. const char* model_name;
  120. int model_id;
  121. struct feature_table_entry* features;
  122. unsigned long board_flags;
  123. };
  124. static struct pmac_mb_def pmac_mb;
  125. /*
  126. * Here are the chip specific feature functions
  127. */
  128. static inline int simple_feature_tweak(struct device_node *node, int type,
  129. int reg, u32 mask, int value)
  130. {
  131. struct macio_chip* macio;
  132. unsigned long flags;
  133. macio = macio_find(node, type);
  134. if (!macio)
  135. return -ENODEV;
  136. LOCK(flags);
  137. if (value)
  138. MACIO_BIS(reg, mask);
  139. else
  140. MACIO_BIC(reg, mask);
  141. (void)MACIO_IN32(reg);
  142. UNLOCK(flags);
  143. return 0;
  144. }
  145. #ifndef CONFIG_POWER4
  146. static long ohare_htw_scc_enable(struct device_node *node, long param,
  147. long value)
  148. {
  149. struct macio_chip* macio;
  150. unsigned long chan_mask;
  151. unsigned long fcr;
  152. unsigned long flags;
  153. int htw, trans;
  154. unsigned long rmask;
  155. macio = macio_find(node, 0);
  156. if (!macio)
  157. return -ENODEV;
  158. if (!strcmp(node->name, "ch-a"))
  159. chan_mask = MACIO_FLAG_SCCA_ON;
  160. else if (!strcmp(node->name, "ch-b"))
  161. chan_mask = MACIO_FLAG_SCCB_ON;
  162. else
  163. return -ENODEV;
  164. htw = (macio->type == macio_heathrow || macio->type == macio_paddington
  165. || macio->type == macio_gatwick);
  166. /* On these machines, the HRW_SCC_TRANS_EN_N bit mustn't be touched */
  167. trans = (pmac_mb.model_id != PMAC_TYPE_YOSEMITE &&
  168. pmac_mb.model_id != PMAC_TYPE_YIKES);
  169. if (value) {
  170. #ifdef CONFIG_ADB_PMU
  171. if ((param & 0xfff) == PMAC_SCC_IRDA)
  172. pmu_enable_irled(1);
  173. #endif /* CONFIG_ADB_PMU */
  174. LOCK(flags);
  175. fcr = MACIO_IN32(OHARE_FCR);
  176. /* Check if scc cell need enabling */
  177. if (!(fcr & OH_SCC_ENABLE)) {
  178. fcr |= OH_SCC_ENABLE;
  179. if (htw) {
  180. /* Side effect: this will also power up the
  181. * modem, but it's too messy to figure out on which
  182. * ports this controls the tranceiver and on which
  183. * it controls the modem
  184. */
  185. if (trans)
  186. fcr &= ~HRW_SCC_TRANS_EN_N;
  187. MACIO_OUT32(OHARE_FCR, fcr);
  188. fcr |= (rmask = HRW_RESET_SCC);
  189. MACIO_OUT32(OHARE_FCR, fcr);
  190. } else {
  191. fcr |= (rmask = OH_SCC_RESET);
  192. MACIO_OUT32(OHARE_FCR, fcr);
  193. }
  194. UNLOCK(flags);
  195. (void)MACIO_IN32(OHARE_FCR);
  196. mdelay(15);
  197. LOCK(flags);
  198. fcr &= ~rmask;
  199. MACIO_OUT32(OHARE_FCR, fcr);
  200. }
  201. if (chan_mask & MACIO_FLAG_SCCA_ON)
  202. fcr |= OH_SCCA_IO;
  203. if (chan_mask & MACIO_FLAG_SCCB_ON)
  204. fcr |= OH_SCCB_IO;
  205. MACIO_OUT32(OHARE_FCR, fcr);
  206. macio->flags |= chan_mask;
  207. UNLOCK(flags);
  208. if (param & PMAC_SCC_FLAG_XMON)
  209. macio->flags |= MACIO_FLAG_SCC_LOCKED;
  210. } else {
  211. if (macio->flags & MACIO_FLAG_SCC_LOCKED)
  212. return -EPERM;
  213. LOCK(flags);
  214. fcr = MACIO_IN32(OHARE_FCR);
  215. if (chan_mask & MACIO_FLAG_SCCA_ON)
  216. fcr &= ~OH_SCCA_IO;
  217. if (chan_mask & MACIO_FLAG_SCCB_ON)
  218. fcr &= ~OH_SCCB_IO;
  219. MACIO_OUT32(OHARE_FCR, fcr);
  220. if ((fcr & (OH_SCCA_IO | OH_SCCB_IO)) == 0) {
  221. fcr &= ~OH_SCC_ENABLE;
  222. if (htw && trans)
  223. fcr |= HRW_SCC_TRANS_EN_N;
  224. MACIO_OUT32(OHARE_FCR, fcr);
  225. }
  226. macio->flags &= ~(chan_mask);
  227. UNLOCK(flags);
  228. mdelay(10);
  229. #ifdef CONFIG_ADB_PMU
  230. if ((param & 0xfff) == PMAC_SCC_IRDA)
  231. pmu_enable_irled(0);
  232. #endif /* CONFIG_ADB_PMU */
  233. }
  234. return 0;
  235. }
  236. static long ohare_floppy_enable(struct device_node *node, long param,
  237. long value)
  238. {
  239. return simple_feature_tweak(node, macio_ohare,
  240. OHARE_FCR, OH_FLOPPY_ENABLE, value);
  241. }
  242. static long ohare_mesh_enable(struct device_node *node, long param, long value)
  243. {
  244. return simple_feature_tweak(node, macio_ohare,
  245. OHARE_FCR, OH_MESH_ENABLE, value);
  246. }
  247. static long ohare_ide_enable(struct device_node *node, long param, long value)
  248. {
  249. switch(param) {
  250. case 0:
  251. /* For some reason, setting the bit in set_initial_features()
  252. * doesn't stick. I'm still investigating... --BenH.
  253. */
  254. if (value)
  255. simple_feature_tweak(node, macio_ohare,
  256. OHARE_FCR, OH_IOBUS_ENABLE, 1);
  257. return simple_feature_tweak(node, macio_ohare,
  258. OHARE_FCR, OH_IDE0_ENABLE, value);
  259. case 1:
  260. return simple_feature_tweak(node, macio_ohare,
  261. OHARE_FCR, OH_BAY_IDE_ENABLE, value);
  262. default:
  263. return -ENODEV;
  264. }
  265. }
  266. static long ohare_ide_reset(struct device_node *node, long param, long value)
  267. {
  268. switch(param) {
  269. case 0:
  270. return simple_feature_tweak(node, macio_ohare,
  271. OHARE_FCR, OH_IDE0_RESET_N, !value);
  272. case 1:
  273. return simple_feature_tweak(node, macio_ohare,
  274. OHARE_FCR, OH_IDE1_RESET_N, !value);
  275. default:
  276. return -ENODEV;
  277. }
  278. }
  279. static long ohare_sleep_state(struct device_node *node, long param, long value)
  280. {
  281. struct macio_chip* macio = &macio_chips[0];
  282. if ((pmac_mb.board_flags & PMAC_MB_CAN_SLEEP) == 0)
  283. return -EPERM;
  284. if (value == 1) {
  285. MACIO_BIC(OHARE_FCR, OH_IOBUS_ENABLE);
  286. } else if (value == 0) {
  287. MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);
  288. }
  289. return 0;
  290. }
  291. static long heathrow_modem_enable(struct device_node *node, long param,
  292. long value)
  293. {
  294. struct macio_chip* macio;
  295. u8 gpio;
  296. unsigned long flags;
  297. macio = macio_find(node, macio_unknown);
  298. if (!macio)
  299. return -ENODEV;
  300. gpio = MACIO_IN8(HRW_GPIO_MODEM_RESET) & ~1;
  301. if (!value) {
  302. LOCK(flags);
  303. MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio);
  304. UNLOCK(flags);
  305. (void)MACIO_IN8(HRW_GPIO_MODEM_RESET);
  306. mdelay(250);
  307. }
  308. if (pmac_mb.model_id != PMAC_TYPE_YOSEMITE &&
  309. pmac_mb.model_id != PMAC_TYPE_YIKES) {
  310. LOCK(flags);
  311. if (value)
  312. MACIO_BIC(HEATHROW_FCR, HRW_SCC_TRANS_EN_N);
  313. else
  314. MACIO_BIS(HEATHROW_FCR, HRW_SCC_TRANS_EN_N);
  315. UNLOCK(flags);
  316. (void)MACIO_IN32(HEATHROW_FCR);
  317. mdelay(250);
  318. }
  319. if (value) {
  320. LOCK(flags);
  321. MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio | 1);
  322. (void)MACIO_IN8(HRW_GPIO_MODEM_RESET);
  323. UNLOCK(flags); mdelay(250); LOCK(flags);
  324. MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio);
  325. (void)MACIO_IN8(HRW_GPIO_MODEM_RESET);
  326. UNLOCK(flags); mdelay(250); LOCK(flags);
  327. MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio | 1);
  328. (void)MACIO_IN8(HRW_GPIO_MODEM_RESET);
  329. UNLOCK(flags); mdelay(250);
  330. }
  331. return 0;
  332. }
  333. static long heathrow_floppy_enable(struct device_node *node, long param,
  334. long value)
  335. {
  336. return simple_feature_tweak(node, macio_unknown,
  337. HEATHROW_FCR,
  338. HRW_SWIM_ENABLE|HRW_BAY_FLOPPY_ENABLE,
  339. value);
  340. }
  341. static long heathrow_mesh_enable(struct device_node *node, long param,
  342. long value)
  343. {
  344. struct macio_chip* macio;
  345. unsigned long flags;
  346. macio = macio_find(node, macio_unknown);
  347. if (!macio)
  348. return -ENODEV;
  349. LOCK(flags);
  350. /* Set clear mesh cell enable */
  351. if (value)
  352. MACIO_BIS(HEATHROW_FCR, HRW_MESH_ENABLE);
  353. else
  354. MACIO_BIC(HEATHROW_FCR, HRW_MESH_ENABLE);
  355. (void)MACIO_IN32(HEATHROW_FCR);
  356. udelay(10);
  357. /* Set/Clear termination power */
  358. if (value)
  359. MACIO_BIC(HEATHROW_MBCR, 0x04000000);
  360. else
  361. MACIO_BIS(HEATHROW_MBCR, 0x04000000);
  362. (void)MACIO_IN32(HEATHROW_MBCR);
  363. udelay(10);
  364. UNLOCK(flags);
  365. return 0;
  366. }
  367. static long heathrow_ide_enable(struct device_node *node, long param,
  368. long value)
  369. {
  370. switch(param) {
  371. case 0:
  372. return simple_feature_tweak(node, macio_unknown,
  373. HEATHROW_FCR, HRW_IDE0_ENABLE, value);
  374. case 1:
  375. return simple_feature_tweak(node, macio_unknown,
  376. HEATHROW_FCR, HRW_BAY_IDE_ENABLE, value);
  377. default:
  378. return -ENODEV;
  379. }
  380. }
  381. static long heathrow_ide_reset(struct device_node *node, long param,
  382. long value)
  383. {
  384. switch(param) {
  385. case 0:
  386. return simple_feature_tweak(node, macio_unknown,
  387. HEATHROW_FCR, HRW_IDE0_RESET_N, !value);
  388. case 1:
  389. return simple_feature_tweak(node, macio_unknown,
  390. HEATHROW_FCR, HRW_IDE1_RESET_N, !value);
  391. default:
  392. return -ENODEV;
  393. }
  394. }
  395. static long heathrow_bmac_enable(struct device_node *node, long param,
  396. long value)
  397. {
  398. struct macio_chip* macio;
  399. unsigned long flags;
  400. macio = macio_find(node, 0);
  401. if (!macio)
  402. return -ENODEV;
  403. if (value) {
  404. LOCK(flags);
  405. MACIO_BIS(HEATHROW_FCR, HRW_BMAC_IO_ENABLE);
  406. MACIO_BIS(HEATHROW_FCR, HRW_BMAC_RESET);
  407. UNLOCK(flags);
  408. (void)MACIO_IN32(HEATHROW_FCR);
  409. mdelay(10);
  410. LOCK(flags);
  411. MACIO_BIC(HEATHROW_FCR, HRW_BMAC_RESET);
  412. UNLOCK(flags);
  413. (void)MACIO_IN32(HEATHROW_FCR);
  414. mdelay(10);
  415. } else {
  416. LOCK(flags);
  417. MACIO_BIC(HEATHROW_FCR, HRW_BMAC_IO_ENABLE);
  418. UNLOCK(flags);
  419. }
  420. return 0;
  421. }
  422. static long heathrow_sound_enable(struct device_node *node, long param,
  423. long value)
  424. {
  425. struct macio_chip* macio;
  426. unsigned long flags;
  427. /* B&W G3 and Yikes don't support that properly (the
  428. * sound appear to never come back after beeing shut down).
  429. */
  430. if (pmac_mb.model_id == PMAC_TYPE_YOSEMITE ||
  431. pmac_mb.model_id == PMAC_TYPE_YIKES)
  432. return 0;
  433. macio = macio_find(node, 0);
  434. if (!macio)
  435. return -ENODEV;
  436. if (value) {
  437. LOCK(flags);
  438. MACIO_BIS(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE);
  439. MACIO_BIC(HEATHROW_FCR, HRW_SOUND_POWER_N);
  440. UNLOCK(flags);
  441. (void)MACIO_IN32(HEATHROW_FCR);
  442. } else {
  443. LOCK(flags);
  444. MACIO_BIS(HEATHROW_FCR, HRW_SOUND_POWER_N);
  445. MACIO_BIC(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE);
  446. UNLOCK(flags);
  447. }
  448. return 0;
  449. }
  450. static u32 save_fcr[6];
  451. static u32 save_mbcr;
  452. static u32 save_gpio_levels[2];
  453. static u8 save_gpio_extint[KEYLARGO_GPIO_EXTINT_CNT];
  454. static u8 save_gpio_normal[KEYLARGO_GPIO_CNT];
  455. static u32 save_unin_clock_ctl;
  456. static struct dbdma_regs save_dbdma[13];
  457. static struct dbdma_regs save_alt_dbdma[13];
  458. static void dbdma_save(struct macio_chip *macio, struct dbdma_regs *save)
  459. {
  460. int i;
  461. /* Save state & config of DBDMA channels */
  462. for (i = 0; i < 13; i++) {
  463. volatile struct dbdma_regs __iomem * chan = (void __iomem *)
  464. (macio->base + ((0x8000+i*0x100)>>2));
  465. save[i].cmdptr_hi = in_le32(&chan->cmdptr_hi);
  466. save[i].cmdptr = in_le32(&chan->cmdptr);
  467. save[i].intr_sel = in_le32(&chan->intr_sel);
  468. save[i].br_sel = in_le32(&chan->br_sel);
  469. save[i].wait_sel = in_le32(&chan->wait_sel);
  470. }
  471. }
  472. static void dbdma_restore(struct macio_chip *macio, struct dbdma_regs *save)
  473. {
  474. int i;
  475. /* Save state & config of DBDMA channels */
  476. for (i = 0; i < 13; i++) {
  477. volatile struct dbdma_regs __iomem * chan = (void __iomem *)
  478. (macio->base + ((0x8000+i*0x100)>>2));
  479. out_le32(&chan->control, (ACTIVE|DEAD|WAKE|FLUSH|PAUSE|RUN)<<16);
  480. while (in_le32(&chan->status) & ACTIVE)
  481. mb();
  482. out_le32(&chan->cmdptr_hi, save[i].cmdptr_hi);
  483. out_le32(&chan->cmdptr, save[i].cmdptr);
  484. out_le32(&chan->intr_sel, save[i].intr_sel);
  485. out_le32(&chan->br_sel, save[i].br_sel);
  486. out_le32(&chan->wait_sel, save[i].wait_sel);
  487. }
  488. }
  489. static void heathrow_sleep(struct macio_chip *macio, int secondary)
  490. {
  491. if (secondary) {
  492. dbdma_save(macio, save_alt_dbdma);
  493. save_fcr[2] = MACIO_IN32(0x38);
  494. save_fcr[3] = MACIO_IN32(0x3c);
  495. } else {
  496. dbdma_save(macio, save_dbdma);
  497. save_fcr[0] = MACIO_IN32(0x38);
  498. save_fcr[1] = MACIO_IN32(0x3c);
  499. save_mbcr = MACIO_IN32(0x34);
  500. /* Make sure sound is shut down */
  501. MACIO_BIS(HEATHROW_FCR, HRW_SOUND_POWER_N);
  502. MACIO_BIC(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE);
  503. /* This seems to be necessary as well or the fan
  504. * keeps coming up and battery drains fast */
  505. MACIO_BIC(HEATHROW_FCR, HRW_IOBUS_ENABLE);
  506. MACIO_BIC(HEATHROW_FCR, HRW_IDE0_RESET_N);
  507. /* Make sure eth is down even if module or sleep
  508. * won't work properly */
  509. MACIO_BIC(HEATHROW_FCR, HRW_BMAC_IO_ENABLE | HRW_BMAC_RESET);
  510. }
  511. /* Make sure modem is shut down */
  512. MACIO_OUT8(HRW_GPIO_MODEM_RESET,
  513. MACIO_IN8(HRW_GPIO_MODEM_RESET) & ~1);
  514. MACIO_BIS(HEATHROW_FCR, HRW_SCC_TRANS_EN_N);
  515. MACIO_BIC(HEATHROW_FCR, OH_SCCA_IO|OH_SCCB_IO|HRW_SCC_ENABLE);
  516. /* Let things settle */
  517. (void)MACIO_IN32(HEATHROW_FCR);
  518. }
  519. static void heathrow_wakeup(struct macio_chip *macio, int secondary)
  520. {
  521. if (secondary) {
  522. MACIO_OUT32(0x38, save_fcr[2]);
  523. (void)MACIO_IN32(0x38);
  524. mdelay(1);
  525. MACIO_OUT32(0x3c, save_fcr[3]);
  526. (void)MACIO_IN32(0x38);
  527. mdelay(10);
  528. dbdma_restore(macio, save_alt_dbdma);
  529. } else {
  530. MACIO_OUT32(0x38, save_fcr[0] | HRW_IOBUS_ENABLE);
  531. (void)MACIO_IN32(0x38);
  532. mdelay(1);
  533. MACIO_OUT32(0x3c, save_fcr[1]);
  534. (void)MACIO_IN32(0x38);
  535. mdelay(1);
  536. MACIO_OUT32(0x34, save_mbcr);
  537. (void)MACIO_IN32(0x38);
  538. mdelay(10);
  539. dbdma_restore(macio, save_dbdma);
  540. }
  541. }
  542. static long heathrow_sleep_state(struct device_node *node, long param,
  543. long value)
  544. {
  545. if ((pmac_mb.board_flags & PMAC_MB_CAN_SLEEP) == 0)
  546. return -EPERM;
  547. if (value == 1) {
  548. if (macio_chips[1].type == macio_gatwick)
  549. heathrow_sleep(&macio_chips[0], 1);
  550. heathrow_sleep(&macio_chips[0], 0);
  551. } else if (value == 0) {
  552. heathrow_wakeup(&macio_chips[0], 0);
  553. if (macio_chips[1].type == macio_gatwick)
  554. heathrow_wakeup(&macio_chips[0], 1);
  555. }
  556. return 0;
  557. }
  558. static long core99_scc_enable(struct device_node *node, long param, long value)
  559. {
  560. struct macio_chip* macio;
  561. unsigned long flags;
  562. unsigned long chan_mask;
  563. u32 fcr;
  564. macio = macio_find(node, 0);
  565. if (!macio)
  566. return -ENODEV;
  567. if (!strcmp(node->name, "ch-a"))
  568. chan_mask = MACIO_FLAG_SCCA_ON;
  569. else if (!strcmp(node->name, "ch-b"))
  570. chan_mask = MACIO_FLAG_SCCB_ON;
  571. else
  572. return -ENODEV;
  573. if (value) {
  574. int need_reset_scc = 0;
  575. int need_reset_irda = 0;
  576. LOCK(flags);
  577. fcr = MACIO_IN32(KEYLARGO_FCR0);
  578. /* Check if scc cell need enabling */
  579. if (!(fcr & KL0_SCC_CELL_ENABLE)) {
  580. fcr |= KL0_SCC_CELL_ENABLE;
  581. need_reset_scc = 1;
  582. }
  583. if (chan_mask & MACIO_FLAG_SCCA_ON) {
  584. fcr |= KL0_SCCA_ENABLE;
  585. /* Don't enable line drivers for I2S modem */
  586. if ((param & 0xfff) == PMAC_SCC_I2S1)
  587. fcr &= ~KL0_SCC_A_INTF_ENABLE;
  588. else
  589. fcr |= KL0_SCC_A_INTF_ENABLE;
  590. }
  591. if (chan_mask & MACIO_FLAG_SCCB_ON) {
  592. fcr |= KL0_SCCB_ENABLE;
  593. /* Perform irda specific inits */
  594. if ((param & 0xfff) == PMAC_SCC_IRDA) {
  595. fcr &= ~KL0_SCC_B_INTF_ENABLE;
  596. fcr |= KL0_IRDA_ENABLE;
  597. fcr |= KL0_IRDA_CLK32_ENABLE | KL0_IRDA_CLK19_ENABLE;
  598. fcr |= KL0_IRDA_SOURCE1_SEL;
  599. fcr &= ~(KL0_IRDA_FAST_CONNECT|KL0_IRDA_DEFAULT1|KL0_IRDA_DEFAULT0);
  600. fcr &= ~(KL0_IRDA_SOURCE2_SEL|KL0_IRDA_HIGH_BAND);
  601. need_reset_irda = 1;
  602. } else
  603. fcr |= KL0_SCC_B_INTF_ENABLE;
  604. }
  605. MACIO_OUT32(KEYLARGO_FCR0, fcr);
  606. macio->flags |= chan_mask;
  607. if (need_reset_scc) {
  608. MACIO_BIS(KEYLARGO_FCR0, KL0_SCC_RESET);
  609. (void)MACIO_IN32(KEYLARGO_FCR0);
  610. UNLOCK(flags);
  611. mdelay(15);
  612. LOCK(flags);
  613. MACIO_BIC(KEYLARGO_FCR0, KL0_SCC_RESET);
  614. }
  615. if (need_reset_irda) {
  616. MACIO_BIS(KEYLARGO_FCR0, KL0_IRDA_RESET);
  617. (void)MACIO_IN32(KEYLARGO_FCR0);
  618. UNLOCK(flags);
  619. mdelay(15);
  620. LOCK(flags);
  621. MACIO_BIC(KEYLARGO_FCR0, KL0_IRDA_RESET);
  622. }
  623. UNLOCK(flags);
  624. if (param & PMAC_SCC_FLAG_XMON)
  625. macio->flags |= MACIO_FLAG_SCC_LOCKED;
  626. } else {
  627. if (macio->flags & MACIO_FLAG_SCC_LOCKED)
  628. return -EPERM;
  629. LOCK(flags);
  630. fcr = MACIO_IN32(KEYLARGO_FCR0);
  631. if (chan_mask & MACIO_FLAG_SCCA_ON)
  632. fcr &= ~KL0_SCCA_ENABLE;
  633. if (chan_mask & MACIO_FLAG_SCCB_ON) {
  634. fcr &= ~KL0_SCCB_ENABLE;
  635. /* Perform irda specific clears */
  636. if ((param & 0xfff) == PMAC_SCC_IRDA) {
  637. fcr &= ~KL0_IRDA_ENABLE;
  638. fcr &= ~(KL0_IRDA_CLK32_ENABLE | KL0_IRDA_CLK19_ENABLE);
  639. fcr &= ~(KL0_IRDA_FAST_CONNECT|KL0_IRDA_DEFAULT1|KL0_IRDA_DEFAULT0);
  640. fcr &= ~(KL0_IRDA_SOURCE1_SEL|KL0_IRDA_SOURCE2_SEL|KL0_IRDA_HIGH_BAND);
  641. }
  642. }
  643. MACIO_OUT32(KEYLARGO_FCR0, fcr);
  644. if ((fcr & (KL0_SCCA_ENABLE | KL0_SCCB_ENABLE)) == 0) {
  645. fcr &= ~KL0_SCC_CELL_ENABLE;
  646. MACIO_OUT32(KEYLARGO_FCR0, fcr);
  647. }
  648. macio->flags &= ~(chan_mask);
  649. UNLOCK(flags);
  650. mdelay(10);
  651. }
  652. return 0;
  653. }
  654. static long
  655. core99_modem_enable(struct device_node *node, long param, long value)
  656. {
  657. struct macio_chip* macio;
  658. u8 gpio;
  659. unsigned long flags;
  660. /* Hack for internal USB modem */
  661. if (node == NULL) {
  662. if (macio_chips[0].type != macio_keylargo)
  663. return -ENODEV;
  664. node = macio_chips[0].of_node;
  665. }
  666. macio = macio_find(node, 0);
  667. if (!macio)
  668. return -ENODEV;
  669. gpio = MACIO_IN8(KL_GPIO_MODEM_RESET);
  670. gpio |= KEYLARGO_GPIO_OUTPUT_ENABLE;
  671. gpio &= ~KEYLARGO_GPIO_OUTOUT_DATA;
  672. if (!value) {
  673. LOCK(flags);
  674. MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio);
  675. UNLOCK(flags);
  676. (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
  677. mdelay(250);
  678. }
  679. LOCK(flags);
  680. if (value) {
  681. MACIO_BIC(KEYLARGO_FCR2, KL2_ALT_DATA_OUT);
  682. UNLOCK(flags);
  683. (void)MACIO_IN32(KEYLARGO_FCR2);
  684. mdelay(250);
  685. } else {
  686. MACIO_BIS(KEYLARGO_FCR2, KL2_ALT_DATA_OUT);
  687. UNLOCK(flags);
  688. }
  689. if (value) {
  690. LOCK(flags);
  691. MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA);
  692. (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
  693. UNLOCK(flags); mdelay(250); LOCK(flags);
  694. MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio);
  695. (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
  696. UNLOCK(flags); mdelay(250); LOCK(flags);
  697. MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA);
  698. (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
  699. UNLOCK(flags); mdelay(250);
  700. }
  701. return 0;
  702. }
  703. static long
  704. pangea_modem_enable(struct device_node *node, long param, long value)
  705. {
  706. struct macio_chip* macio;
  707. u8 gpio;
  708. unsigned long flags;
  709. /* Hack for internal USB modem */
  710. if (node == NULL) {
  711. if (macio_chips[0].type != macio_pangea &&
  712. macio_chips[0].type != macio_intrepid)
  713. return -ENODEV;
  714. node = macio_chips[0].of_node;
  715. }
  716. macio = macio_find(node, 0);
  717. if (!macio)
  718. return -ENODEV;
  719. gpio = MACIO_IN8(KL_GPIO_MODEM_RESET);
  720. gpio |= KEYLARGO_GPIO_OUTPUT_ENABLE;
  721. gpio &= ~KEYLARGO_GPIO_OUTOUT_DATA;
  722. if (!value) {
  723. LOCK(flags);
  724. MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio);
  725. UNLOCK(flags);
  726. (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
  727. mdelay(250);
  728. }
  729. LOCK(flags);
  730. if (value) {
  731. MACIO_OUT8(KL_GPIO_MODEM_POWER,
  732. KEYLARGO_GPIO_OUTPUT_ENABLE);
  733. UNLOCK(flags);
  734. (void)MACIO_IN32(KEYLARGO_FCR2);
  735. mdelay(250);
  736. } else {
  737. MACIO_OUT8(KL_GPIO_MODEM_POWER,
  738. KEYLARGO_GPIO_OUTPUT_ENABLE | KEYLARGO_GPIO_OUTOUT_DATA);
  739. UNLOCK(flags);
  740. }
  741. if (value) {
  742. LOCK(flags);
  743. MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA);
  744. (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
  745. UNLOCK(flags); mdelay(250); LOCK(flags);
  746. MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio);
  747. (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
  748. UNLOCK(flags); mdelay(250); LOCK(flags);
  749. MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA);
  750. (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
  751. UNLOCK(flags); mdelay(250);
  752. }
  753. return 0;
  754. }
  755. static long
  756. core99_ata100_enable(struct device_node *node, long value)
  757. {
  758. unsigned long flags;
  759. struct pci_dev *pdev = NULL;
  760. u8 pbus, pid;
  761. if (uninorth_rev < 0x24)
  762. return -ENODEV;
  763. LOCK(flags);
  764. if (value)
  765. UN_BIS(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_ATA100);
  766. else
  767. UN_BIC(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_ATA100);
  768. (void)UN_IN(UNI_N_CLOCK_CNTL);
  769. UNLOCK(flags);
  770. udelay(20);
  771. if (value) {
  772. if (pci_device_from_OF_node(node, &pbus, &pid) == 0)
  773. pdev = pci_find_slot(pbus, pid);
  774. if (pdev == NULL)
  775. return 0;
  776. pci_enable_device(pdev);
  777. pci_set_master(pdev);
  778. }
  779. return 0;
  780. }
  781. static long
  782. core99_ide_enable(struct device_node *node, long param, long value)
  783. {
  784. /* Bus ID 0 to 2 are KeyLargo based IDE, busID 3 is U2
  785. * based ata-100
  786. */
  787. switch(param) {
  788. case 0:
  789. return simple_feature_tweak(node, macio_unknown,
  790. KEYLARGO_FCR1, KL1_EIDE0_ENABLE, value);
  791. case 1:
  792. return simple_feature_tweak(node, macio_unknown,
  793. KEYLARGO_FCR1, KL1_EIDE1_ENABLE, value);
  794. case 2:
  795. return simple_feature_tweak(node, macio_unknown,
  796. KEYLARGO_FCR1, KL1_UIDE_ENABLE, value);
  797. case 3:
  798. return core99_ata100_enable(node, value);
  799. default:
  800. return -ENODEV;
  801. }
  802. }
  803. static long
  804. core99_ide_reset(struct device_node *node, long param, long value)
  805. {
  806. switch(param) {
  807. case 0:
  808. return simple_feature_tweak(node, macio_unknown,
  809. KEYLARGO_FCR1, KL1_EIDE0_RESET_N, !value);
  810. case 1:
  811. return simple_feature_tweak(node, macio_unknown,
  812. KEYLARGO_FCR1, KL1_EIDE1_RESET_N, !value);
  813. case 2:
  814. return simple_feature_tweak(node, macio_unknown,
  815. KEYLARGO_FCR1, KL1_UIDE_RESET_N, !value);
  816. default:
  817. return -ENODEV;
  818. }
  819. }
  820. static long
  821. core99_gmac_enable(struct device_node *node, long param, long value)
  822. {
  823. unsigned long flags;
  824. LOCK(flags);
  825. if (value)
  826. UN_BIS(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_GMAC);
  827. else
  828. UN_BIC(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_GMAC);
  829. (void)UN_IN(UNI_N_CLOCK_CNTL);
  830. UNLOCK(flags);
  831. udelay(20);
  832. return 0;
  833. }
  834. static long
  835. core99_gmac_phy_reset(struct device_node *node, long param, long value)
  836. {
  837. unsigned long flags;
  838. struct macio_chip *macio;
  839. macio = &macio_chips[0];
  840. if (macio->type != macio_keylargo && macio->type != macio_pangea &&
  841. macio->type != macio_intrepid)
  842. return -ENODEV;
  843. LOCK(flags);
  844. MACIO_OUT8(KL_GPIO_ETH_PHY_RESET, KEYLARGO_GPIO_OUTPUT_ENABLE);
  845. (void)MACIO_IN8(KL_GPIO_ETH_PHY_RESET);
  846. UNLOCK(flags);
  847. mdelay(10);
  848. LOCK(flags);
  849. MACIO_OUT8(KL_GPIO_ETH_PHY_RESET, /*KEYLARGO_GPIO_OUTPUT_ENABLE | */
  850. KEYLARGO_GPIO_OUTOUT_DATA);
  851. UNLOCK(flags);
  852. mdelay(10);
  853. return 0;
  854. }
  855. static long
  856. core99_sound_chip_enable(struct device_node *node, long param, long value)
  857. {
  858. struct macio_chip* macio;
  859. unsigned long flags;
  860. macio = macio_find(node, 0);
  861. if (!macio)
  862. return -ENODEV;
  863. /* Do a better probe code, screamer G4 desktops &
  864. * iMacs can do that too, add a recalibrate in
  865. * the driver as well
  866. */
  867. if (pmac_mb.model_id == PMAC_TYPE_PISMO ||
  868. pmac_mb.model_id == PMAC_TYPE_TITANIUM) {
  869. LOCK(flags);
  870. if (value)
  871. MACIO_OUT8(KL_GPIO_SOUND_POWER,
  872. KEYLARGO_GPIO_OUTPUT_ENABLE |
  873. KEYLARGO_GPIO_OUTOUT_DATA);
  874. else
  875. MACIO_OUT8(KL_GPIO_SOUND_POWER,
  876. KEYLARGO_GPIO_OUTPUT_ENABLE);
  877. (void)MACIO_IN8(KL_GPIO_SOUND_POWER);
  878. UNLOCK(flags);
  879. }
  880. return 0;
  881. }
  882. static long
  883. core99_airport_enable(struct device_node *node, long param, long value)
  884. {
  885. struct macio_chip* macio;
  886. unsigned long flags;
  887. int state;
  888. macio = macio_find(node, 0);
  889. if (!macio)
  890. return -ENODEV;
  891. /* Hint: we allow passing of macio itself for the sake of the
  892. * sleep code
  893. */
  894. if (node != macio->of_node &&
  895. (!node->parent || node->parent != macio->of_node))
  896. return -ENODEV;
  897. state = (macio->flags & MACIO_FLAG_AIRPORT_ON) != 0;
  898. if (value == state)
  899. return 0;
  900. if (value) {
  901. /* This code is a reproduction of OF enable-cardslot
  902. * and init-wireless methods, slightly hacked until
  903. * I got it working.
  904. */
  905. LOCK(flags);
  906. MACIO_OUT8(KEYLARGO_GPIO_0+0xf, 5);
  907. (void)MACIO_IN8(KEYLARGO_GPIO_0+0xf);
  908. UNLOCK(flags);
  909. mdelay(10);
  910. LOCK(flags);
  911. MACIO_OUT8(KEYLARGO_GPIO_0+0xf, 4);
  912. (void)MACIO_IN8(KEYLARGO_GPIO_0+0xf);
  913. UNLOCK(flags);
  914. mdelay(10);
  915. LOCK(flags);
  916. MACIO_BIC(KEYLARGO_FCR2, KL2_CARDSEL_16);
  917. (void)MACIO_IN32(KEYLARGO_FCR2);
  918. udelay(10);
  919. MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0+0xb, 0);
  920. (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0+0xb);
  921. udelay(10);
  922. MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0+0xa, 0x28);
  923. (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0+0xa);
  924. udelay(10);
  925. MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0+0xd, 0x28);
  926. (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0+0xd);
  927. udelay(10);
  928. MACIO_OUT8(KEYLARGO_GPIO_0+0xd, 0x28);
  929. (void)MACIO_IN8(KEYLARGO_GPIO_0+0xd);
  930. udelay(10);
  931. MACIO_OUT8(KEYLARGO_GPIO_0+0xe, 0x28);
  932. (void)MACIO_IN8(KEYLARGO_GPIO_0+0xe);
  933. UNLOCK(flags);
  934. udelay(10);
  935. MACIO_OUT32(0x1c000, 0);
  936. mdelay(1);
  937. MACIO_OUT8(0x1a3e0, 0x41);
  938. (void)MACIO_IN8(0x1a3e0);
  939. udelay(10);
  940. LOCK(flags);
  941. MACIO_BIS(KEYLARGO_FCR2, KL2_CARDSEL_16);
  942. (void)MACIO_IN32(KEYLARGO_FCR2);
  943. UNLOCK(flags);
  944. mdelay(100);
  945. macio->flags |= MACIO_FLAG_AIRPORT_ON;
  946. } else {
  947. LOCK(flags);
  948. MACIO_BIC(KEYLARGO_FCR2, KL2_CARDSEL_16);
  949. (void)MACIO_IN32(KEYLARGO_FCR2);
  950. MACIO_OUT8(KL_GPIO_AIRPORT_0, 0);
  951. MACIO_OUT8(KL_GPIO_AIRPORT_1, 0);
  952. MACIO_OUT8(KL_GPIO_AIRPORT_2, 0);
  953. MACIO_OUT8(KL_GPIO_AIRPORT_3, 0);
  954. MACIO_OUT8(KL_GPIO_AIRPORT_4, 0);
  955. (void)MACIO_IN8(KL_GPIO_AIRPORT_4);
  956. UNLOCK(flags);
  957. macio->flags &= ~MACIO_FLAG_AIRPORT_ON;
  958. }
  959. return 0;
  960. }
  961. #ifdef CONFIG_SMP
  962. static long
  963. core99_reset_cpu(struct device_node *node, long param, long value)
  964. {
  965. unsigned int reset_io = 0;
  966. unsigned long flags;
  967. struct macio_chip *macio;
  968. struct device_node *np;
  969. const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0,
  970. KL_GPIO_RESET_CPU1,
  971. KL_GPIO_RESET_CPU2,
  972. KL_GPIO_RESET_CPU3 };
  973. macio = &macio_chips[0];
  974. if (macio->type != macio_keylargo)
  975. return -ENODEV;
  976. np = find_path_device("/cpus");
  977. if (np == NULL)
  978. return -ENODEV;
  979. for (np = np->child; np != NULL; np = np->sibling) {
  980. u32 *num = (u32 *)get_property(np, "reg", NULL);
  981. u32 *rst = (u32 *)get_property(np, "soft-reset", NULL);
  982. if (num == NULL || rst == NULL)
  983. continue;
  984. if (param == *num) {
  985. reset_io = *rst;
  986. break;
  987. }
  988. }
  989. if (np == NULL || reset_io == 0)
  990. reset_io = dflt_reset_lines[param];
  991. LOCK(flags);
  992. MACIO_OUT8(reset_io, KEYLARGO_GPIO_OUTPUT_ENABLE);
  993. (void)MACIO_IN8(reset_io);
  994. udelay(1);
  995. MACIO_OUT8(reset_io, 0);
  996. (void)MACIO_IN8(reset_io);
  997. UNLOCK(flags);
  998. return 0;
  999. }
  1000. #endif /* CONFIG_SMP */
  1001. static long
  1002. core99_usb_enable(struct device_node *node, long param, long value)
  1003. {
  1004. struct macio_chip *macio;
  1005. unsigned long flags;
  1006. char *prop;
  1007. int number;
  1008. u32 reg;
  1009. macio = &macio_chips[0];
  1010. if (macio->type != macio_keylargo && macio->type != macio_pangea &&
  1011. macio->type != macio_intrepid)
  1012. return -ENODEV;
  1013. prop = (char *)get_property(node, "AAPL,clock-id", NULL);
  1014. if (!prop)
  1015. return -ENODEV;
  1016. if (strncmp(prop, "usb0u048", 8) == 0)
  1017. number = 0;
  1018. else if (strncmp(prop, "usb1u148", 8) == 0)
  1019. number = 2;
  1020. else if (strncmp(prop, "usb2u248", 8) == 0)
  1021. number = 4;
  1022. else
  1023. return -ENODEV;
  1024. /* Sorry for the brute-force locking, but this is only used during
  1025. * sleep and the timing seem to be critical
  1026. */
  1027. LOCK(flags);
  1028. if (value) {
  1029. /* Turn ON */
  1030. if (number == 0) {
  1031. MACIO_BIC(KEYLARGO_FCR0, (KL0_USB0_PAD_SUSPEND0 | KL0_USB0_PAD_SUSPEND1));
  1032. (void)MACIO_IN32(KEYLARGO_FCR0);
  1033. UNLOCK(flags);
  1034. mdelay(1);
  1035. LOCK(flags);
  1036. MACIO_BIS(KEYLARGO_FCR0, KL0_USB0_CELL_ENABLE);
  1037. } else if (number == 2) {
  1038. MACIO_BIC(KEYLARGO_FCR0, (KL0_USB1_PAD_SUSPEND0 | KL0_USB1_PAD_SUSPEND1));
  1039. UNLOCK(flags);
  1040. (void)MACIO_IN32(KEYLARGO_FCR0);
  1041. mdelay(1);
  1042. LOCK(flags);
  1043. MACIO_BIS(KEYLARGO_FCR0, KL0_USB1_CELL_ENABLE);
  1044. } else if (number == 4) {
  1045. MACIO_BIC(KEYLARGO_FCR1, (KL1_USB2_PAD_SUSPEND0 | KL1_USB2_PAD_SUSPEND1));
  1046. UNLOCK(flags);
  1047. (void)MACIO_IN32(KEYLARGO_FCR1);
  1048. mdelay(1);
  1049. LOCK(flags);
  1050. MACIO_BIS(KEYLARGO_FCR1, KL1_USB2_CELL_ENABLE);
  1051. }
  1052. if (number < 4) {
  1053. reg = MACIO_IN32(KEYLARGO_FCR4);
  1054. reg &= ~(KL4_PORT_WAKEUP_ENABLE(number) | KL4_PORT_RESUME_WAKE_EN(number) |
  1055. KL4_PORT_CONNECT_WAKE_EN(number) | KL4_PORT_DISCONNECT_WAKE_EN(number));
  1056. reg &= ~(KL4_PORT_WAKEUP_ENABLE(number+1) | KL4_PORT_RESUME_WAKE_EN(number+1) |
  1057. KL4_PORT_CONNECT_WAKE_EN(number+1) | KL4_PORT_DISCONNECT_WAKE_EN(number+1));
  1058. MACIO_OUT32(KEYLARGO_FCR4, reg);
  1059. (void)MACIO_IN32(KEYLARGO_FCR4);
  1060. udelay(10);
  1061. } else {
  1062. reg = MACIO_IN32(KEYLARGO_FCR3);
  1063. reg &= ~(KL3_IT_PORT_WAKEUP_ENABLE(0) | KL3_IT_PORT_RESUME_WAKE_EN(0) |
  1064. KL3_IT_PORT_CONNECT_WAKE_EN(0) | KL3_IT_PORT_DISCONNECT_WAKE_EN(0));
  1065. reg &= ~(KL3_IT_PORT_WAKEUP_ENABLE(1) | KL3_IT_PORT_RESUME_WAKE_EN(1) |
  1066. KL3_IT_PORT_CONNECT_WAKE_EN(1) | KL3_IT_PORT_DISCONNECT_WAKE_EN(1));
  1067. MACIO_OUT32(KEYLARGO_FCR3, reg);
  1068. (void)MACIO_IN32(KEYLARGO_FCR3);
  1069. udelay(10);
  1070. }
  1071. if (macio->type == macio_intrepid) {
  1072. /* wait for clock stopped bits to clear */
  1073. u32 test0 = 0, test1 = 0;
  1074. u32 status0, status1;
  1075. int timeout = 1000;
  1076. UNLOCK(flags);
  1077. switch (number) {
  1078. case 0:
  1079. test0 = UNI_N_CLOCK_STOPPED_USB0;
  1080. test1 = UNI_N_CLOCK_STOPPED_USB0PCI;
  1081. break;
  1082. case 2:
  1083. test0 = UNI_N_CLOCK_STOPPED_USB1;
  1084. test1 = UNI_N_CLOCK_STOPPED_USB1PCI;
  1085. break;
  1086. case 4:
  1087. test0 = UNI_N_CLOCK_STOPPED_USB2;
  1088. test1 = UNI_N_CLOCK_STOPPED_USB2PCI;
  1089. break;
  1090. }
  1091. do {
  1092. if (--timeout <= 0) {
  1093. printk(KERN_ERR "core99_usb_enable: "
  1094. "Timeout waiting for clocks\n");
  1095. break;
  1096. }
  1097. mdelay(1);
  1098. status0 = UN_IN(UNI_N_CLOCK_STOP_STATUS0);
  1099. status1 = UN_IN(UNI_N_CLOCK_STOP_STATUS1);
  1100. } while ((status0 & test0) | (status1 & test1));
  1101. LOCK(flags);
  1102. }
  1103. } else {
  1104. /* Turn OFF */
  1105. if (number < 4) {
  1106. reg = MACIO_IN32(KEYLARGO_FCR4);
  1107. reg |= KL4_PORT_WAKEUP_ENABLE(number) | KL4_PORT_RESUME_WAKE_EN(number) |
  1108. KL4_PORT_CONNECT_WAKE_EN(number) | KL4_PORT_DISCONNECT_WAKE_EN(number);
  1109. reg |= KL4_PORT_WAKEUP_ENABLE(number+1) | KL4_PORT_RESUME_WAKE_EN(number+1) |
  1110. KL4_PORT_CONNECT_WAKE_EN(number+1) | KL4_PORT_DISCONNECT_WAKE_EN(number+1);
  1111. MACIO_OUT32(KEYLARGO_FCR4, reg);
  1112. (void)MACIO_IN32(KEYLARGO_FCR4);
  1113. udelay(1);
  1114. } else {
  1115. reg = MACIO_IN32(KEYLARGO_FCR3);
  1116. reg |= KL3_IT_PORT_WAKEUP_ENABLE(0) | KL3_IT_PORT_RESUME_WAKE_EN(0) |
  1117. KL3_IT_PORT_CONNECT_WAKE_EN(0) | KL3_IT_PORT_DISCONNECT_WAKE_EN(0);
  1118. reg |= KL3_IT_PORT_WAKEUP_ENABLE(1) | KL3_IT_PORT_RESUME_WAKE_EN(1) |
  1119. KL3_IT_PORT_CONNECT_WAKE_EN(1) | KL3_IT_PORT_DISCONNECT_WAKE_EN(1);
  1120. MACIO_OUT32(KEYLARGO_FCR3, reg);
  1121. (void)MACIO_IN32(KEYLARGO_FCR3);
  1122. udelay(1);
  1123. }
  1124. if (number == 0) {
  1125. if (macio->type != macio_intrepid)
  1126. MACIO_BIC(KEYLARGO_FCR0, KL0_USB0_CELL_ENABLE);
  1127. (void)MACIO_IN32(KEYLARGO_FCR0);
  1128. udelay(1);
  1129. MACIO_BIS(KEYLARGO_FCR0, (KL0_USB0_PAD_SUSPEND0 | KL0_USB0_PAD_SUSPEND1));
  1130. (void)MACIO_IN32(KEYLARGO_FCR0);
  1131. } else if (number == 2) {
  1132. if (macio->type != macio_intrepid)
  1133. MACIO_BIC(KEYLARGO_FCR0, KL0_USB1_CELL_ENABLE);
  1134. (void)MACIO_IN32(KEYLARGO_FCR0);
  1135. udelay(1);
  1136. MACIO_BIS(KEYLARGO_FCR0, (KL0_USB1_PAD_SUSPEND0 | KL0_USB1_PAD_SUSPEND1));
  1137. (void)MACIO_IN32(KEYLARGO_FCR0);
  1138. } else if (number == 4) {
  1139. udelay(1);
  1140. MACIO_BIS(KEYLARGO_FCR1, (KL1_USB2_PAD_SUSPEND0 | KL1_USB2_PAD_SUSPEND1));
  1141. (void)MACIO_IN32(KEYLARGO_FCR1);
  1142. }
  1143. udelay(1);
  1144. }
  1145. UNLOCK(flags);
  1146. return 0;
  1147. }
  1148. static long
  1149. core99_firewire_enable(struct device_node *node, long param, long value)
  1150. {
  1151. unsigned long flags;
  1152. struct macio_chip *macio;
  1153. macio = &macio_chips[0];
  1154. if (macio->type != macio_keylargo && macio->type != macio_pangea &&
  1155. macio->type != macio_intrepid)
  1156. return -ENODEV;
  1157. if (!(macio->flags & MACIO_FLAG_FW_SUPPORTED))
  1158. return -ENODEV;
  1159. LOCK(flags);
  1160. if (value) {
  1161. UN_BIS(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_FW);
  1162. (void)UN_IN(UNI_N_CLOCK_CNTL);
  1163. } else {
  1164. UN_BIC(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_FW);
  1165. (void)UN_IN(UNI_N_CLOCK_CNTL);
  1166. }
  1167. UNLOCK(flags);
  1168. mdelay(1);
  1169. return 0;
  1170. }
  1171. static long
  1172. core99_firewire_cable_power(struct device_node *node, long param, long value)
  1173. {
  1174. unsigned long flags;
  1175. struct macio_chip *macio;
  1176. /* Trick: we allow NULL node */
  1177. if ((pmac_mb.board_flags & PMAC_MB_HAS_FW_POWER) == 0)
  1178. return -ENODEV;
  1179. macio = &macio_chips[0];
  1180. if (macio->type != macio_keylargo && macio->type != macio_pangea &&
  1181. macio->type != macio_intrepid)
  1182. return -ENODEV;
  1183. if (!(macio->flags & MACIO_FLAG_FW_SUPPORTED))
  1184. return -ENODEV;
  1185. LOCK(flags);
  1186. if (value) {
  1187. MACIO_OUT8(KL_GPIO_FW_CABLE_POWER , 0);
  1188. MACIO_IN8(KL_GPIO_FW_CABLE_POWER);
  1189. udelay(10);
  1190. } else {
  1191. MACIO_OUT8(KL_GPIO_FW_CABLE_POWER , 4);
  1192. MACIO_IN8(KL_GPIO_FW_CABLE_POWER); udelay(10);
  1193. }
  1194. UNLOCK(flags);
  1195. mdelay(1);
  1196. return 0;
  1197. }
  1198. static long
  1199. intrepid_aack_delay_enable(struct device_node *node, long param, long value)
  1200. {
  1201. unsigned long flags;
  1202. if (uninorth_rev < 0xd2)
  1203. return -ENODEV;
  1204. LOCK(flags);
  1205. if (param)
  1206. UN_BIS(UNI_N_AACK_DELAY, UNI_N_AACK_DELAY_ENABLE);
  1207. else
  1208. UN_BIC(UNI_N_AACK_DELAY, UNI_N_AACK_DELAY_ENABLE);
  1209. UNLOCK(flags);
  1210. return 0;
  1211. }
  1212. #endif /* CONFIG_POWER4 */
  1213. static long
  1214. core99_read_gpio(struct device_node *node, long param, long value)
  1215. {
  1216. struct macio_chip *macio = &macio_chips[0];
  1217. return MACIO_IN8(param);
  1218. }
  1219. static long
  1220. core99_write_gpio(struct device_node *node, long param, long value)
  1221. {
  1222. struct macio_chip *macio = &macio_chips[0];
  1223. MACIO_OUT8(param, (u8)(value & 0xff));
  1224. return 0;
  1225. }
  1226. #ifdef CONFIG_POWER4
  1227. static long g5_gmac_enable(struct device_node *node, long param, long value)
  1228. {
  1229. struct macio_chip *macio = &macio_chips[0];
  1230. unsigned long flags;
  1231. if (node == NULL)
  1232. return -ENODEV;
  1233. LOCK(flags);
  1234. if (value) {
  1235. MACIO_BIS(KEYLARGO_FCR1, K2_FCR1_GMAC_CLK_ENABLE);
  1236. mb();
  1237. k2_skiplist[0] = NULL;
  1238. } else {
  1239. k2_skiplist[0] = node;
  1240. mb();
  1241. MACIO_BIC(KEYLARGO_FCR1, K2_FCR1_GMAC_CLK_ENABLE);
  1242. }
  1243. UNLOCK(flags);
  1244. mdelay(1);
  1245. return 0;
  1246. }
  1247. static long g5_fw_enable(struct device_node *node, long param, long value)
  1248. {
  1249. struct macio_chip *macio = &macio_chips[0];
  1250. unsigned long flags;
  1251. if (node == NULL)
  1252. return -ENODEV;
  1253. LOCK(flags);
  1254. if (value) {
  1255. MACIO_BIS(KEYLARGO_FCR1, K2_FCR1_FW_CLK_ENABLE);
  1256. mb();
  1257. k2_skiplist[1] = NULL;
  1258. } else {
  1259. k2_skiplist[1] = node;
  1260. mb();
  1261. MACIO_BIC(KEYLARGO_FCR1, K2_FCR1_FW_CLK_ENABLE);
  1262. }
  1263. UNLOCK(flags);
  1264. mdelay(1);
  1265. return 0;
  1266. }
  1267. static long g5_mpic_enable(struct device_node *node, long param, long value)
  1268. {
  1269. unsigned long flags;
  1270. if (node->parent == NULL || strcmp(node->parent->name, "u3"))
  1271. return 0;
  1272. LOCK(flags);
  1273. UN_BIS(U3_TOGGLE_REG, U3_MPIC_RESET | U3_MPIC_OUTPUT_ENABLE);
  1274. UNLOCK(flags);
  1275. return 0;
  1276. }
  1277. static long g5_eth_phy_reset(struct device_node *node, long param, long value)
  1278. {
  1279. struct macio_chip *macio = &macio_chips[0];
  1280. struct device_node *phy;
  1281. int need_reset;
  1282. /*
  1283. * We must not reset the combo PHYs, only the BCM5221 found in
  1284. * the iMac G5.
  1285. */
  1286. phy = of_get_next_child(node, NULL);
  1287. if (!phy)
  1288. return -ENODEV;
  1289. need_reset = device_is_compatible(phy, "B5221");
  1290. of_node_put(phy);
  1291. if (!need_reset)
  1292. return 0;
  1293. /* PHY reset is GPIO 29, not in device-tree unfortunately */
  1294. MACIO_OUT8(K2_GPIO_EXTINT_0 + 29,
  1295. KEYLARGO_GPIO_OUTPUT_ENABLE | KEYLARGO_GPIO_OUTOUT_DATA);
  1296. /* Thankfully, this is now always called at a time when we can
  1297. * schedule by sungem.
  1298. */
  1299. msleep(10);
  1300. MACIO_OUT8(K2_GPIO_EXTINT_0 + 29, 0);
  1301. return 0;
  1302. }
  1303. static long g5_i2s_enable(struct device_node *node, long param, long value)
  1304. {
  1305. /* Very crude implementation for now */
  1306. struct macio_chip *macio = &macio_chips[0];
  1307. unsigned long flags;
  1308. if (value == 0)
  1309. return 0; /* don't disable yet */
  1310. LOCK(flags);
  1311. MACIO_BIS(KEYLARGO_FCR3, KL3_CLK45_ENABLE | KL3_CLK49_ENABLE |
  1312. KL3_I2S0_CLK18_ENABLE);
  1313. udelay(10);
  1314. MACIO_BIS(KEYLARGO_FCR1, K2_FCR1_I2S0_CELL_ENABLE |
  1315. K2_FCR1_I2S0_CLK_ENABLE_BIT | K2_FCR1_I2S0_ENABLE);
  1316. udelay(10);
  1317. MACIO_BIC(KEYLARGO_FCR1, K2_FCR1_I2S0_RESET);
  1318. UNLOCK(flags);
  1319. udelay(10);
  1320. return 0;
  1321. }
  1322. #ifdef CONFIG_SMP
  1323. static long g5_reset_cpu(struct device_node *node, long param, long value)
  1324. {
  1325. unsigned int reset_io = 0;
  1326. unsigned long flags;
  1327. struct macio_chip *macio;
  1328. struct device_node *np;
  1329. macio = &macio_chips[0];
  1330. if (macio->type != macio_keylargo2)
  1331. return -ENODEV;
  1332. np = find_path_device("/cpus");
  1333. if (np == NULL)
  1334. return -ENODEV;
  1335. for (np = np->child; np != NULL; np = np->sibling) {
  1336. u32 *num = (u32 *)get_property(np, "reg", NULL);
  1337. u32 *rst = (u32 *)get_property(np, "soft-reset", NULL);
  1338. if (num == NULL || rst == NULL)
  1339. continue;
  1340. if (param == *num) {
  1341. reset_io = *rst;
  1342. break;
  1343. }
  1344. }
  1345. if (np == NULL || reset_io == 0)
  1346. return -ENODEV;
  1347. LOCK(flags);
  1348. MACIO_OUT8(reset_io, KEYLARGO_GPIO_OUTPUT_ENABLE);
  1349. (void)MACIO_IN8(reset_io);
  1350. udelay(1);
  1351. MACIO_OUT8(reset_io, 0);
  1352. (void)MACIO_IN8(reset_io);
  1353. UNLOCK(flags);
  1354. return 0;
  1355. }
  1356. #endif /* CONFIG_SMP */
  1357. /*
  1358. * This can be called from pmac_smp so isn't static
  1359. *
  1360. * This takes the second CPU off the bus on dual CPU machines
  1361. * running UP
  1362. */
  1363. void g5_phy_disable_cpu1(void)
  1364. {
  1365. UN_OUT(U3_API_PHY_CONFIG_1, 0);
  1366. }
  1367. #endif /* CONFIG_POWER4 */
  1368. #ifndef CONFIG_POWER4
  1369. static void
  1370. keylargo_shutdown(struct macio_chip *macio, int sleep_mode)
  1371. {
  1372. u32 temp;
  1373. if (sleep_mode) {
  1374. mdelay(1);
  1375. MACIO_BIS(KEYLARGO_FCR0, KL0_USB_REF_SUSPEND);
  1376. (void)MACIO_IN32(KEYLARGO_FCR0);
  1377. mdelay(1);
  1378. }
  1379. MACIO_BIC(KEYLARGO_FCR0,KL0_SCCA_ENABLE | KL0_SCCB_ENABLE |
  1380. KL0_SCC_CELL_ENABLE |
  1381. KL0_IRDA_ENABLE | KL0_IRDA_CLK32_ENABLE |
  1382. KL0_IRDA_CLK19_ENABLE);
  1383. MACIO_BIC(KEYLARGO_MBCR, KL_MBCR_MB0_DEV_MASK);
  1384. MACIO_BIS(KEYLARGO_MBCR, KL_MBCR_MB0_IDE_ENABLE);
  1385. MACIO_BIC(KEYLARGO_FCR1,
  1386. KL1_AUDIO_SEL_22MCLK | KL1_AUDIO_CLK_ENABLE_BIT |
  1387. KL1_AUDIO_CLK_OUT_ENABLE | KL1_AUDIO_CELL_ENABLE |
  1388. KL1_I2S0_CELL_ENABLE | KL1_I2S0_CLK_ENABLE_BIT |
  1389. KL1_I2S0_ENABLE | KL1_I2S1_CELL_ENABLE |
  1390. KL1_I2S1_CLK_ENABLE_BIT | KL1_I2S1_ENABLE |
  1391. KL1_EIDE0_ENABLE | KL1_EIDE0_RESET_N |
  1392. KL1_EIDE1_ENABLE | KL1_EIDE1_RESET_N |
  1393. KL1_UIDE_ENABLE);
  1394. MACIO_BIS(KEYLARGO_FCR2, KL2_ALT_DATA_OUT);
  1395. MACIO_BIC(KEYLARGO_FCR2, KL2_IOBUS_ENABLE);
  1396. temp = MACIO_IN32(KEYLARGO_FCR3);
  1397. if (macio->rev >= 2) {
  1398. temp |= KL3_SHUTDOWN_PLL2X;
  1399. if (sleep_mode)
  1400. temp |= KL3_SHUTDOWN_PLL_TOTAL;
  1401. }
  1402. temp |= KL3_SHUTDOWN_PLLKW6 | KL3_SHUTDOWN_PLLKW4 |
  1403. KL3_SHUTDOWN_PLLKW35;
  1404. if (sleep_mode)
  1405. temp |= KL3_SHUTDOWN_PLLKW12;
  1406. temp &= ~(KL3_CLK66_ENABLE | KL3_CLK49_ENABLE | KL3_CLK45_ENABLE
  1407. | KL3_CLK31_ENABLE | KL3_I2S1_CLK18_ENABLE | KL3_I2S0_CLK18_ENABLE);
  1408. if (sleep_mode)
  1409. temp &= ~(KL3_TIMER_CLK18_ENABLE | KL3_VIA_CLK16_ENABLE);
  1410. MACIO_OUT32(KEYLARGO_FCR3, temp);
  1411. /* Flush posted writes & wait a bit */
  1412. (void)MACIO_IN32(KEYLARGO_FCR0); mdelay(1);
  1413. }
  1414. static void
  1415. pangea_shutdown(struct macio_chip *macio, int sleep_mode)
  1416. {
  1417. u32 temp;
  1418. MACIO_BIC(KEYLARGO_FCR0,KL0_SCCA_ENABLE | KL0_SCCB_ENABLE |
  1419. KL0_SCC_CELL_ENABLE |
  1420. KL0_USB0_CELL_ENABLE | KL0_USB1_CELL_ENABLE);
  1421. MACIO_BIC(KEYLARGO_FCR1,
  1422. KL1_AUDIO_SEL_22MCLK | KL1_AUDIO_CLK_ENABLE_BIT |
  1423. KL1_AUDIO_CLK_OUT_ENABLE | KL1_AUDIO_CELL_ENABLE |
  1424. KL1_I2S0_CELL_ENABLE | KL1_I2S0_CLK_ENABLE_BIT |
  1425. KL1_I2S0_ENABLE | KL1_I2S1_CELL_ENABLE |
  1426. KL1_I2S1_CLK_ENABLE_BIT | KL1_I2S1_ENABLE |
  1427. KL1_UIDE_ENABLE);
  1428. if (pmac_mb.board_flags & PMAC_MB_MOBILE)
  1429. MACIO_BIC(KEYLARGO_FCR1, KL1_UIDE_RESET_N);
  1430. MACIO_BIS(KEYLARGO_FCR2, KL2_ALT_DATA_OUT);
  1431. temp = MACIO_IN32(KEYLARGO_FCR3);
  1432. temp |= KL3_SHUTDOWN_PLLKW6 | KL3_SHUTDOWN_PLLKW4 |
  1433. KL3_SHUTDOWN_PLLKW35;
  1434. temp &= ~(KL3_CLK49_ENABLE | KL3_CLK45_ENABLE | KL3_CLK31_ENABLE
  1435. | KL3_I2S0_CLK18_ENABLE | KL3_I2S1_CLK18_ENABLE);
  1436. if (sleep_mode)
  1437. temp &= ~(KL3_VIA_CLK16_ENABLE | KL3_TIMER_CLK18_ENABLE);
  1438. MACIO_OUT32(KEYLARGO_FCR3, temp);
  1439. /* Flush posted writes & wait a bit */
  1440. (void)MACIO_IN32(KEYLARGO_FCR0); mdelay(1);
  1441. }
  1442. static void
  1443. intrepid_shutdown(struct macio_chip *macio, int sleep_mode)
  1444. {
  1445. u32 temp;
  1446. MACIO_BIC(KEYLARGO_FCR0,KL0_SCCA_ENABLE | KL0_SCCB_ENABLE |
  1447. KL0_SCC_CELL_ENABLE);
  1448. MACIO_BIC(KEYLARGO_FCR1,
  1449. /*KL1_USB2_CELL_ENABLE |*/
  1450. KL1_I2S0_CELL_ENABLE | KL1_I2S0_CLK_ENABLE_BIT |
  1451. KL1_I2S0_ENABLE | KL1_I2S1_CELL_ENABLE |
  1452. KL1_I2S1_CLK_ENABLE_BIT | KL1_I2S1_ENABLE);
  1453. if (pmac_mb.board_flags & PMAC_MB_MOBILE)
  1454. MACIO_BIC(KEYLARGO_FCR1, KL1_UIDE_RESET_N);
  1455. temp = MACIO_IN32(KEYLARGO_FCR3);
  1456. temp &= ~(KL3_CLK49_ENABLE | KL3_CLK45_ENABLE |
  1457. KL3_I2S1_CLK18_ENABLE | KL3_I2S0_CLK18_ENABLE);
  1458. if (sleep_mode)
  1459. temp &= ~(KL3_TIMER_CLK18_ENABLE | KL3_IT_VIA_CLK32_ENABLE);
  1460. MACIO_OUT32(KEYLARGO_FCR3, temp);
  1461. /* Flush posted writes & wait a bit */
  1462. (void)MACIO_IN32(KEYLARGO_FCR0);
  1463. mdelay(10);
  1464. }
  1465. void pmac_tweak_clock_spreading(int enable)
  1466. {
  1467. struct macio_chip *macio = &macio_chips[0];
  1468. /* Hack for doing clock spreading on some machines PowerBooks and
  1469. * iBooks. This implements the "platform-do-clockspreading" OF
  1470. * property as decoded manually on various models. For safety, we also
  1471. * check the product ID in the device-tree in cases we'll whack the i2c
  1472. * chip to make reasonably sure we won't set wrong values in there
  1473. *
  1474. * Of course, ultimately, we have to implement a real parser for
  1475. * the platform-do-* stuff...
  1476. */
  1477. if (macio->type == macio_intrepid) {
  1478. if (enable)
  1479. UN_OUT(UNI_N_CLOCK_SPREADING, 2);
  1480. else
  1481. UN_OUT(UNI_N_CLOCK_SPREADING, 0);
  1482. mdelay(40);
  1483. }
  1484. while (machine_is_compatible("PowerBook5,2") ||
  1485. machine_is_compatible("PowerBook5,3") ||
  1486. machine_is_compatible("PowerBook6,2") ||
  1487. machine_is_compatible("PowerBook6,3")) {
  1488. struct device_node *ui2c = of_find_node_by_type(NULL, "i2c");
  1489. struct device_node *dt = of_find_node_by_name(NULL, "device-tree");
  1490. u8 buffer[9];
  1491. u32 *productID;
  1492. int i, rc, changed = 0;
  1493. if (dt == NULL)
  1494. break;
  1495. productID = (u32 *)get_property(dt, "pid#", NULL);
  1496. if (productID == NULL)
  1497. break;
  1498. while(ui2c) {
  1499. struct device_node *p = of_get_parent(ui2c);
  1500. if (p && !strcmp(p->name, "uni-n"))
  1501. break;
  1502. ui2c = of_find_node_by_type(ui2c, "i2c");
  1503. }
  1504. if (ui2c == NULL)
  1505. break;
  1506. DBG("Trying to bump clock speed for PID: %08x...\n", *productID);
  1507. rc = pmac_low_i2c_open(ui2c, 1);
  1508. if (rc != 0)
  1509. break;
  1510. pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_combined);
  1511. rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_read, 0x80, buffer, 9);
  1512. DBG("read result: %d,", rc);
  1513. if (rc != 0) {
  1514. pmac_low_i2c_close(ui2c);
  1515. break;
  1516. }
  1517. for (i=0; i<9; i++)
  1518. DBG(" %02x", buffer[i]);
  1519. DBG("\n");
  1520. switch(*productID) {
  1521. case 0x1182: /* AlBook 12" rev 2 */
  1522. case 0x1183: /* iBook G4 12" */
  1523. buffer[0] = (buffer[0] & 0x8f) | 0x70;
  1524. buffer[2] = (buffer[2] & 0x7f) | 0x00;
  1525. buffer[5] = (buffer[5] & 0x80) | 0x31;
  1526. buffer[6] = (buffer[6] & 0x40) | 0xb0;
  1527. buffer[7] = (buffer[7] & 0x00) | (enable ? 0xc0 : 0xba);
  1528. buffer[8] = (buffer[8] & 0x00) | 0x30;
  1529. changed = 1;
  1530. break;
  1531. case 0x3142: /* AlBook 15" (ATI M10) */
  1532. case 0x3143: /* AlBook 17" (ATI M10) */
  1533. buffer[0] = (buffer[0] & 0xaf) | 0x50;
  1534. buffer[2] = (buffer[2] & 0x7f) | 0x00;
  1535. buffer[5] = (buffer[5] & 0x80) | 0x31;
  1536. buffer[6] = (buffer[6] & 0x40) | 0xb0;
  1537. buffer[7] = (buffer[7] & 0x00) | (enable ? 0xd0 : 0xc0);
  1538. buffer[8] = (buffer[8] & 0x00) | 0x30;
  1539. changed = 1;
  1540. break;
  1541. default:
  1542. DBG("i2c-hwclock: Machine model not handled\n");
  1543. break;
  1544. }
  1545. if (!changed) {
  1546. pmac_low_i2c_close(ui2c);
  1547. break;
  1548. }
  1549. pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_stdsub);
  1550. rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_write, 0x80, buffer, 9);
  1551. DBG("write result: %d,", rc);
  1552. pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_combined);
  1553. rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_read, 0x80, buffer, 9);
  1554. DBG("read result: %d,", rc);
  1555. if (rc != 0) {
  1556. pmac_low_i2c_close(ui2c);
  1557. break;
  1558. }
  1559. for (i=0; i<9; i++)
  1560. DBG(" %02x", buffer[i]);
  1561. pmac_low_i2c_close(ui2c);
  1562. break;
  1563. }
  1564. }
  1565. static int
  1566. core99_sleep(void)
  1567. {
  1568. struct macio_chip *macio;
  1569. int i;
  1570. macio = &macio_chips[0];
  1571. if (macio->type != macio_keylargo && macio->type != macio_pangea &&
  1572. macio->type != macio_intrepid)
  1573. return -ENODEV;
  1574. /* We power off the wireless slot in case it was not done
  1575. * by the driver. We don't power it on automatically however
  1576. */
  1577. if (macio->flags & MACIO_FLAG_AIRPORT_ON)
  1578. core99_airport_enable(macio->of_node, 0, 0);
  1579. /* We power off the FW cable. Should be done by the driver... */
  1580. if (macio->flags & MACIO_FLAG_FW_SUPPORTED) {
  1581. core99_firewire_enable(NULL, 0, 0);
  1582. core99_firewire_cable_power(NULL, 0, 0);
  1583. }
  1584. /* We make sure int. modem is off (in case driver lost it) */
  1585. if (macio->type == macio_keylargo)
  1586. core99_modem_enable(macio->of_node, 0, 0);
  1587. else
  1588. pangea_modem_enable(macio->of_node, 0, 0);
  1589. /* We make sure the sound is off as well */
  1590. core99_sound_chip_enable(macio->of_node, 0, 0);
  1591. /*
  1592. * Save various bits of KeyLargo
  1593. */
  1594. /* Save the state of the various GPIOs */
  1595. save_gpio_levels[0] = MACIO_IN32(KEYLARGO_GPIO_LEVELS0);
  1596. save_gpio_levels[1] = MACIO_IN32(KEYLARGO_GPIO_LEVELS1);
  1597. for (i=0; i<KEYLARGO_GPIO_EXTINT_CNT; i++)
  1598. save_gpio_extint[i] = MACIO_IN8(KEYLARGO_GPIO_EXTINT_0+i);
  1599. for (i=0; i<KEYLARGO_GPIO_CNT; i++)
  1600. save_gpio_normal[i] = MACIO_IN8(KEYLARGO_GPIO_0+i);
  1601. /* Save the FCRs */
  1602. if (macio->type == macio_keylargo)
  1603. save_mbcr = MACIO_IN32(KEYLARGO_MBCR);
  1604. save_fcr[0] = MACIO_IN32(KEYLARGO_FCR0);
  1605. save_fcr[1] = MACIO_IN32(KEYLARGO_FCR1);
  1606. save_fcr[2] = MACIO_IN32(KEYLARGO_FCR2);
  1607. save_fcr[3] = MACIO_IN32(KEYLARGO_FCR3);
  1608. save_fcr[4] = MACIO_IN32(KEYLARGO_FCR4);
  1609. if (macio->type == macio_pangea || macio->type == macio_intrepid)
  1610. save_fcr[5] = MACIO_IN32(KEYLARGO_FCR5);
  1611. /* Save state & config of DBDMA channels */
  1612. dbdma_save(macio, save_dbdma);
  1613. /*
  1614. * Turn off as much as we can
  1615. */
  1616. if (macio->type == macio_pangea)
  1617. pangea_shutdown(macio, 1);
  1618. else if (macio->type == macio_intrepid)
  1619. intrepid_shutdown(macio, 1);
  1620. else if (macio->type == macio_keylargo)
  1621. keylargo_shutdown(macio, 1);
  1622. /*
  1623. * Put the host bridge to sleep
  1624. */
  1625. save_unin_clock_ctl = UN_IN(UNI_N_CLOCK_CNTL);
  1626. /* Note: do not switch GMAC off, driver does it when necessary, WOL must keep it
  1627. * enabled !
  1628. */
  1629. UN_OUT(UNI_N_CLOCK_CNTL, save_unin_clock_ctl &
  1630. ~(/*UNI_N_CLOCK_CNTL_GMAC|*/UNI_N_CLOCK_CNTL_FW/*|UNI_N_CLOCK_CNTL_PCI*/));
  1631. udelay(100);
  1632. UN_OUT(UNI_N_HWINIT_STATE, UNI_N_HWINIT_STATE_SLEEPING);
  1633. UN_OUT(UNI_N_POWER_MGT, UNI_N_POWER_MGT_SLEEP);
  1634. mdelay(10);
  1635. /*
  1636. * FIXME: A bit of black magic with OpenPIC (don't ask me why)
  1637. */
  1638. if (pmac_mb.model_id == PMAC_TYPE_SAWTOOTH) {
  1639. MACIO_BIS(0x506e0, 0x00400000);
  1640. MACIO_BIS(0x506e0, 0x80000000);
  1641. }
  1642. return 0;
  1643. }
  1644. static int
  1645. core99_wake_up(void)
  1646. {
  1647. struct macio_chip *macio;
  1648. int i;
  1649. macio = &macio_chips[0];
  1650. if (macio->type != macio_keylargo && macio->type != macio_pangea &&
  1651. macio->type != macio_intrepid)
  1652. return -ENODEV;
  1653. /*
  1654. * Wakeup the host bridge
  1655. */
  1656. UN_OUT(UNI_N_POWER_MGT, UNI_N_POWER_MGT_NORMAL);
  1657. udelay(10);
  1658. UN_OUT(UNI_N_HWINIT_STATE, UNI_N_HWINIT_STATE_RUNNING);
  1659. udelay(10);
  1660. /*
  1661. * Restore KeyLargo
  1662. */
  1663. if (macio->type == macio_keylargo) {
  1664. MACIO_OUT32(KEYLARGO_MBCR, save_mbcr);
  1665. (void)MACIO_IN32(KEYLARGO_MBCR); udelay(10);
  1666. }
  1667. MACIO_OUT32(KEYLARGO_FCR0, save_fcr[0]);
  1668. (void)MACIO_IN32(KEYLARGO_FCR0); udelay(10);
  1669. MACIO_OUT32(KEYLARGO_FCR1, save_fcr[1]);
  1670. (void)MACIO_IN32(KEYLARGO_FCR1); udelay(10);
  1671. MACIO_OUT32(KEYLARGO_FCR2, save_fcr[2]);
  1672. (void)MACIO_IN32(KEYLARGO_FCR2); udelay(10);
  1673. MACIO_OUT32(KEYLARGO_FCR3, save_fcr[3]);
  1674. (void)MACIO_IN32(KEYLARGO_FCR3); udelay(10);
  1675. MACIO_OUT32(KEYLARGO_FCR4, save_fcr[4]);
  1676. (void)MACIO_IN32(KEYLARGO_FCR4); udelay(10);
  1677. if (macio->type == macio_pangea || macio->type == macio_intrepid) {
  1678. MACIO_OUT32(KEYLARGO_FCR5, save_fcr[5]);
  1679. (void)MACIO_IN32(KEYLARGO_FCR5); udelay(10);
  1680. }
  1681. dbdma_restore(macio, save_dbdma);
  1682. MACIO_OUT32(KEYLARGO_GPIO_LEVELS0, save_gpio_levels[0]);
  1683. MACIO_OUT32(KEYLARGO_GPIO_LEVELS1, save_gpio_levels[1]);
  1684. for (i=0; i<KEYLARGO_GPIO_EXTINT_CNT; i++)
  1685. MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0+i, save_gpio_extint[i]);
  1686. for (i=0; i<KEYLARGO_GPIO_CNT; i++)
  1687. MACIO_OUT8(KEYLARGO_GPIO_0+i, save_gpio_normal[i]);
  1688. /* FIXME more black magic with OpenPIC ... */
  1689. if (pmac_mb.model_id == PMAC_TYPE_SAWTOOTH) {
  1690. MACIO_BIC(0x506e0, 0x00400000);
  1691. MACIO_BIC(0x506e0, 0x80000000);
  1692. }
  1693. UN_OUT(UNI_N_CLOCK_CNTL, save_unin_clock_ctl);
  1694. udelay(100);
  1695. return 0;
  1696. }
  1697. static long
  1698. core99_sleep_state(struct device_node *node, long param, long value)
  1699. {
  1700. /* Param == 1 means to enter the "fake sleep" mode that is
  1701. * used for CPU speed switch
  1702. */
  1703. if (param == 1) {
  1704. if (value == 1) {
  1705. UN_OUT(UNI_N_HWINIT_STATE, UNI_N_HWINIT_STATE_SLEEPING);
  1706. UN_OUT(UNI_N_POWER_MGT, UNI_N_POWER_MGT_IDLE2);
  1707. } else {
  1708. UN_OUT(UNI_N_POWER_MGT, UNI_N_POWER_MGT_NORMAL);
  1709. udelay(10);
  1710. UN_OUT(UNI_N_HWINIT_STATE, UNI_N_HWINIT_STATE_RUNNING);
  1711. udelay(10);
  1712. }
  1713. return 0;
  1714. }
  1715. if ((pmac_mb.board_flags & PMAC_MB_CAN_SLEEP) == 0)
  1716. return -EPERM;
  1717. if (value == 1)
  1718. return core99_sleep();
  1719. else if (value == 0)
  1720. return core99_wake_up();
  1721. return 0;
  1722. }
  1723. #endif /* CONFIG_POWER4 */
  1724. static long
  1725. generic_dev_can_wake(struct device_node *node, long param, long value)
  1726. {
  1727. /* Todo: eventually check we are really dealing with on-board
  1728. * video device ...
  1729. */
  1730. if (pmac_mb.board_flags & PMAC_MB_MAY_SLEEP)
  1731. pmac_mb.board_flags |= PMAC_MB_CAN_SLEEP;
  1732. return 0;
  1733. }
  1734. static long generic_get_mb_info(struct device_node *node, long param, long value)
  1735. {
  1736. switch(param) {
  1737. case PMAC_MB_INFO_MODEL:
  1738. return pmac_mb.model_id;
  1739. case PMAC_MB_INFO_FLAGS:
  1740. return pmac_mb.board_flags;
  1741. case PMAC_MB_INFO_NAME:
  1742. /* hack hack hack... but should work */
  1743. *((const char **)value) = pmac_mb.model_name;
  1744. return 0;
  1745. }
  1746. return -EINVAL;
  1747. }
  1748. /*
  1749. * Table definitions
  1750. */
  1751. /* Used on any machine
  1752. */
  1753. static struct feature_table_entry any_features[] = {
  1754. { PMAC_FTR_GET_MB_INFO, generic_get_mb_info },
  1755. { PMAC_FTR_DEVICE_CAN_WAKE, generic_dev_can_wake },
  1756. { 0, NULL }
  1757. };
  1758. #ifndef CONFIG_POWER4
  1759. /* OHare based motherboards. Currently, we only use these on the
  1760. * 2400,3400 and 3500 series powerbooks. Some older desktops seem
  1761. * to have issues with turning on/off those asic cells
  1762. */
  1763. static struct feature_table_entry ohare_features[] = {
  1764. { PMAC_FTR_SCC_ENABLE, ohare_htw_scc_enable },
  1765. { PMAC_FTR_SWIM3_ENABLE, ohare_floppy_enable },
  1766. { PMAC_FTR_MESH_ENABLE, ohare_mesh_enable },
  1767. { PMAC_FTR_IDE_ENABLE, ohare_ide_enable},
  1768. { PMAC_FTR_IDE_RESET, ohare_ide_reset},
  1769. { PMAC_FTR_SLEEP_STATE, ohare_sleep_state },
  1770. { 0, NULL }
  1771. };
  1772. /* Heathrow desktop machines (Beige G3).
  1773. * Separated as some features couldn't be properly tested
  1774. * and the serial port control bits appear to confuse it.
  1775. */
  1776. static struct feature_table_entry heathrow_desktop_features[] = {
  1777. { PMAC_FTR_SWIM3_ENABLE, heathrow_floppy_enable },
  1778. { PMAC_FTR_MESH_ENABLE, heathrow_mesh_enable },
  1779. { PMAC_FTR_IDE_ENABLE, heathrow_ide_enable },
  1780. { PMAC_FTR_IDE_RESET, heathrow_ide_reset },
  1781. { PMAC_FTR_BMAC_ENABLE, heathrow_bmac_enable },
  1782. { 0, NULL }
  1783. };
  1784. /* Heathrow based laptop, that is the Wallstreet and mainstreet
  1785. * powerbooks.
  1786. */
  1787. static struct feature_table_entry heathrow_laptop_features[] = {
  1788. { PMAC_FTR_SCC_ENABLE, ohare_htw_scc_enable },
  1789. { PMAC_FTR_MODEM_ENABLE, heathrow_modem_enable },
  1790. { PMAC_FTR_SWIM3_ENABLE, heathrow_floppy_enable },
  1791. { PMAC_FTR_MESH_ENABLE, heathrow_mesh_enable },
  1792. { PMAC_FTR_IDE_ENABLE, heathrow_ide_enable },
  1793. { PMAC_FTR_IDE_RESET, heathrow_ide_reset },
  1794. { PMAC_FTR_BMAC_ENABLE, heathrow_bmac_enable },
  1795. { PMAC_FTR_SOUND_CHIP_ENABLE, heathrow_sound_enable },
  1796. { PMAC_FTR_SLEEP_STATE, heathrow_sleep_state },
  1797. { 0, NULL }
  1798. };
  1799. /* Paddington based machines
  1800. * The lombard (101) powerbook, first iMac models, B&W G3 and Yikes G4.
  1801. */
  1802. static struct feature_table_entry paddington_features[] = {
  1803. { PMAC_FTR_SCC_ENABLE, ohare_htw_scc_enable },
  1804. { PMAC_FTR_MODEM_ENABLE, heathrow_modem_enable },
  1805. { PMAC_FTR_SWIM3_ENABLE, heathrow_floppy_enable },
  1806. { PMAC_FTR_MESH_ENABLE, heathrow_mesh_enable },
  1807. { PMAC_FTR_IDE_ENABLE, heathrow_ide_enable },
  1808. { PMAC_FTR_IDE_RESET, heathrow_ide_reset },
  1809. { PMAC_FTR_BMAC_ENABLE, heathrow_bmac_enable },
  1810. { PMAC_FTR_SOUND_CHIP_ENABLE, heathrow_sound_enable },
  1811. { PMAC_FTR_SLEEP_STATE, heathrow_sleep_state },
  1812. { 0, NULL }
  1813. };
  1814. /* Core99 & MacRISC 2 machines (all machines released since the
  1815. * iBook (included), that is all AGP machines, except pangea
  1816. * chipset. The pangea chipset is the "combo" UniNorth/KeyLargo
  1817. * used on iBook2 & iMac "flow power".
  1818. */
  1819. static struct feature_table_entry core99_features[] = {
  1820. { PMAC_FTR_SCC_ENABLE, core99_scc_enable },
  1821. { PMAC_FTR_MODEM_ENABLE, core99_modem_enable },
  1822. { PMAC_FTR_IDE_ENABLE, core99_ide_enable },
  1823. { PMAC_FTR_IDE_RESET, core99_ide_reset },
  1824. { PMAC_FTR_GMAC_ENABLE, core99_gmac_enable },
  1825. { PMAC_FTR_GMAC_PHY_RESET, core99_gmac_phy_reset },
  1826. { PMAC_FTR_SOUND_CHIP_ENABLE, core99_sound_chip_enable },
  1827. { PMAC_FTR_AIRPORT_ENABLE, core99_airport_enable },
  1828. { PMAC_FTR_USB_ENABLE, core99_usb_enable },
  1829. { PMAC_FTR_1394_ENABLE, core99_firewire_enable },
  1830. { PMAC_FTR_1394_CABLE_POWER, core99_firewire_cable_power },
  1831. { PMAC_FTR_SLEEP_STATE, core99_sleep_state },
  1832. #ifdef CONFIG_SMP
  1833. { PMAC_FTR_RESET_CPU, core99_reset_cpu },
  1834. #endif /* CONFIG_SMP */
  1835. { PMAC_FTR_READ_GPIO, core99_read_gpio },
  1836. { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
  1837. { 0, NULL }
  1838. };
  1839. /* RackMac
  1840. */
  1841. static struct feature_table_entry rackmac_features[] = {
  1842. { PMAC_FTR_SCC_ENABLE, core99_scc_enable },
  1843. { PMAC_FTR_IDE_ENABLE, core99_ide_enable },
  1844. { PMAC_FTR_IDE_RESET, core99_ide_reset },
  1845. { PMAC_FTR_GMAC_ENABLE, core99_gmac_enable },
  1846. { PMAC_FTR_GMAC_PHY_RESET, core99_gmac_phy_reset },
  1847. { PMAC_FTR_USB_ENABLE, core99_usb_enable },
  1848. { PMAC_FTR_1394_ENABLE, core99_firewire_enable },
  1849. { PMAC_FTR_1394_CABLE_POWER, core99_firewire_cable_power },
  1850. { PMAC_FTR_SLEEP_STATE, core99_sleep_state },
  1851. #ifdef CONFIG_SMP
  1852. { PMAC_FTR_RESET_CPU, core99_reset_cpu },
  1853. #endif /* CONFIG_SMP */
  1854. { PMAC_FTR_READ_GPIO, core99_read_gpio },
  1855. { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
  1856. { 0, NULL }
  1857. };
  1858. /* Pangea features
  1859. */
  1860. static struct feature_table_entry pangea_features[] = {
  1861. { PMAC_FTR_SCC_ENABLE, core99_scc_enable },
  1862. { PMAC_FTR_MODEM_ENABLE, pangea_modem_enable },
  1863. { PMAC_FTR_IDE_ENABLE, core99_ide_enable },
  1864. { PMAC_FTR_IDE_RESET, core99_ide_reset },
  1865. { PMAC_FTR_GMAC_ENABLE, core99_gmac_enable },
  1866. { PMAC_FTR_GMAC_PHY_RESET, core99_gmac_phy_reset },
  1867. { PMAC_FTR_SOUND_CHIP_ENABLE, core99_sound_chip_enable },
  1868. { PMAC_FTR_AIRPORT_ENABLE, core99_airport_enable },
  1869. { PMAC_FTR_USB_ENABLE, core99_usb_enable },
  1870. { PMAC_FTR_1394_ENABLE, core99_firewire_enable },
  1871. { PMAC_FTR_1394_CABLE_POWER, core99_firewire_cable_power },
  1872. { PMAC_FTR_SLEEP_STATE, core99_sleep_state },
  1873. { PMAC_FTR_READ_GPIO, core99_read_gpio },
  1874. { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
  1875. { 0, NULL }
  1876. };
  1877. /* Intrepid features
  1878. */
  1879. static struct feature_table_entry intrepid_features[] = {
  1880. { PMAC_FTR_SCC_ENABLE, core99_scc_enable },
  1881. { PMAC_FTR_MODEM_ENABLE, pangea_modem_enable },
  1882. { PMAC_FTR_IDE_ENABLE, core99_ide_enable },
  1883. { PMAC_FTR_IDE_RESET, core99_ide_reset },
  1884. { PMAC_FTR_GMAC_ENABLE, core99_gmac_enable },
  1885. { PMAC_FTR_GMAC_PHY_RESET, core99_gmac_phy_reset },
  1886. { PMAC_FTR_SOUND_CHIP_ENABLE, core99_sound_chip_enable },
  1887. { PMAC_FTR_AIRPORT_ENABLE, core99_airport_enable },
  1888. { PMAC_FTR_USB_ENABLE, core99_usb_enable },
  1889. { PMAC_FTR_1394_ENABLE, core99_firewire_enable },
  1890. { PMAC_FTR_1394_CABLE_POWER, core99_firewire_cable_power },
  1891. { PMAC_FTR_SLEEP_STATE, core99_sleep_state },
  1892. { PMAC_FTR_READ_GPIO, core99_read_gpio },
  1893. { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
  1894. { PMAC_FTR_AACK_DELAY_ENABLE, intrepid_aack_delay_enable },
  1895. { 0, NULL }
  1896. };
  1897. #else /* CONFIG_POWER4 */
  1898. /* G5 features
  1899. */
  1900. static struct feature_table_entry g5_features[] = {
  1901. { PMAC_FTR_GMAC_ENABLE, g5_gmac_enable },
  1902. { PMAC_FTR_1394_ENABLE, g5_fw_enable },
  1903. { PMAC_FTR_ENABLE_MPIC, g5_mpic_enable },
  1904. { PMAC_FTR_GMAC_PHY_RESET, g5_eth_phy_reset },
  1905. { PMAC_FTR_SOUND_CHIP_ENABLE, g5_i2s_enable },
  1906. #ifdef CONFIG_SMP
  1907. { PMAC_FTR_RESET_CPU, g5_reset_cpu },
  1908. #endif /* CONFIG_SMP */
  1909. { PMAC_FTR_READ_GPIO, core99_read_gpio },
  1910. { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
  1911. { 0, NULL }
  1912. };
  1913. #endif /* CONFIG_POWER4 */
  1914. static struct pmac_mb_def pmac_mb_defs[] = {
  1915. #ifndef CONFIG_POWER4
  1916. /*
  1917. * Desktops
  1918. */
  1919. { "AAPL,8500", "PowerMac 8500/8600",
  1920. PMAC_TYPE_PSURGE, NULL,
  1921. 0
  1922. },
  1923. { "AAPL,9500", "PowerMac 9500/9600",
  1924. PMAC_TYPE_PSURGE, NULL,
  1925. 0
  1926. },
  1927. { "AAPL,7200", "PowerMac 7200",
  1928. PMAC_TYPE_PSURGE, NULL,
  1929. 0
  1930. },
  1931. { "AAPL,7300", "PowerMac 7200/7300",
  1932. PMAC_TYPE_PSURGE, NULL,
  1933. 0
  1934. },
  1935. { "AAPL,7500", "PowerMac 7500",
  1936. PMAC_TYPE_PSURGE, NULL,
  1937. 0
  1938. },
  1939. { "AAPL,ShinerESB", "Apple Network Server",
  1940. PMAC_TYPE_ANS, NULL,
  1941. 0
  1942. },
  1943. { "AAPL,e407", "Alchemy",
  1944. PMAC_TYPE_ALCHEMY, NULL,
  1945. 0
  1946. },
  1947. { "AAPL,e411", "Gazelle",
  1948. PMAC_TYPE_GAZELLE, NULL,
  1949. 0
  1950. },
  1951. { "AAPL,Gossamer", "PowerMac G3 (Gossamer)",
  1952. PMAC_TYPE_GOSSAMER, heathrow_desktop_features,
  1953. 0
  1954. },
  1955. { "AAPL,PowerMac G3", "PowerMac G3 (Silk)",
  1956. PMAC_TYPE_SILK, heathrow_desktop_features,
  1957. 0
  1958. },
  1959. { "PowerMac1,1", "Blue&White G3",
  1960. PMAC_TYPE_YOSEMITE, paddington_features,
  1961. 0
  1962. },
  1963. { "PowerMac1,2", "PowerMac G4 PCI Graphics",
  1964. PMAC_TYPE_YIKES, paddington_features,
  1965. 0
  1966. },
  1967. { "PowerMac2,1", "iMac FireWire",
  1968. PMAC_TYPE_FW_IMAC, core99_features,
  1969. PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
  1970. },
  1971. { "PowerMac2,2", "iMac FireWire",
  1972. PMAC_TYPE_FW_IMAC, core99_features,
  1973. PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
  1974. },
  1975. { "PowerMac3,1", "PowerMac G4 AGP Graphics",
  1976. PMAC_TYPE_SAWTOOTH, core99_features,
  1977. PMAC_MB_OLD_CORE99
  1978. },
  1979. { "PowerMac3,2", "PowerMac G4 AGP Graphics",
  1980. PMAC_TYPE_SAWTOOTH, core99_features,
  1981. PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
  1982. },
  1983. { "PowerMac3,3", "PowerMac G4 AGP Graphics",
  1984. PMAC_TYPE_SAWTOOTH, core99_features,
  1985. PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
  1986. },
  1987. { "PowerMac3,4", "PowerMac G4 Silver",
  1988. PMAC_TYPE_QUICKSILVER, core99_features,
  1989. PMAC_MB_MAY_SLEEP
  1990. },
  1991. { "PowerMac3,5", "PowerMac G4 Silver",
  1992. PMAC_TYPE_QUICKSILVER, core99_features,
  1993. PMAC_MB_MAY_SLEEP
  1994. },
  1995. { "PowerMac3,6", "PowerMac G4 Windtunnel",
  1996. PMAC_TYPE_WINDTUNNEL, core99_features,
  1997. PMAC_MB_MAY_SLEEP,
  1998. },
  1999. { "PowerMac4,1", "iMac \"Flower Power\"",
  2000. PMAC_TYPE_PANGEA_IMAC, pangea_features,
  2001. PMAC_MB_MAY_SLEEP
  2002. },
  2003. { "PowerMac4,2", "Flat panel iMac",
  2004. PMAC_TYPE_FLAT_PANEL_IMAC, pangea_features,
  2005. PMAC_MB_CAN_SLEEP
  2006. },
  2007. { "PowerMac4,4", "eMac",
  2008. PMAC_TYPE_EMAC, core99_features,
  2009. PMAC_MB_MAY_SLEEP
  2010. },
  2011. { "PowerMac5,1", "PowerMac G4 Cube",
  2012. PMAC_TYPE_CUBE, core99_features,
  2013. PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
  2014. },
  2015. { "PowerMac6,1", "Flat panel iMac",
  2016. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2017. PMAC_MB_MAY_SLEEP,
  2018. },
  2019. { "PowerMac6,3", "Flat panel iMac",
  2020. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2021. PMAC_MB_MAY_SLEEP,
  2022. },
  2023. { "PowerMac6,4", "eMac",
  2024. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2025. PMAC_MB_MAY_SLEEP,
  2026. },
  2027. { "PowerMac10,1", "Mac mini",
  2028. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2029. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER,
  2030. },
  2031. { "iMac,1", "iMac (first generation)",
  2032. PMAC_TYPE_ORIG_IMAC, paddington_features,
  2033. 0
  2034. },
  2035. /*
  2036. * Xserve's
  2037. */
  2038. { "RackMac1,1", "XServe",
  2039. PMAC_TYPE_RACKMAC, rackmac_features,
  2040. 0,
  2041. },
  2042. { "RackMac1,2", "XServe rev. 2",
  2043. PMAC_TYPE_RACKMAC, rackmac_features,
  2044. 0,
  2045. },
  2046. /*
  2047. * Laptops
  2048. */
  2049. { "AAPL,3400/2400", "PowerBook 3400",
  2050. PMAC_TYPE_HOOPER, ohare_features,
  2051. PMAC_MB_CAN_SLEEP | PMAC_MB_MOBILE
  2052. },
  2053. { "AAPL,3500", "PowerBook 3500",
  2054. PMAC_TYPE_KANGA, ohare_features,
  2055. PMAC_MB_CAN_SLEEP | PMAC_MB_MOBILE
  2056. },
  2057. { "AAPL,PowerBook1998", "PowerBook Wallstreet",
  2058. PMAC_TYPE_WALLSTREET, heathrow_laptop_features,
  2059. PMAC_MB_CAN_SLEEP | PMAC_MB_MOBILE
  2060. },
  2061. { "PowerBook1,1", "PowerBook 101 (Lombard)",
  2062. PMAC_TYPE_101_PBOOK, paddington_features,
  2063. PMAC_MB_CAN_SLEEP | PMAC_MB_MOBILE
  2064. },
  2065. { "PowerBook2,1", "iBook (first generation)",
  2066. PMAC_TYPE_ORIG_IBOOK, core99_features,
  2067. PMAC_MB_CAN_SLEEP | PMAC_MB_OLD_CORE99 | PMAC_MB_MOBILE
  2068. },
  2069. { "PowerBook2,2", "iBook FireWire",
  2070. PMAC_TYPE_FW_IBOOK, core99_features,
  2071. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER |
  2072. PMAC_MB_OLD_CORE99 | PMAC_MB_MOBILE
  2073. },
  2074. { "PowerBook3,1", "PowerBook Pismo",
  2075. PMAC_TYPE_PISMO, core99_features,
  2076. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER |
  2077. PMAC_MB_OLD_CORE99 | PMAC_MB_MOBILE
  2078. },
  2079. { "PowerBook3,2", "PowerBook Titanium",
  2080. PMAC_TYPE_TITANIUM, core99_features,
  2081. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
  2082. },
  2083. { "PowerBook3,3", "PowerBook Titanium II",
  2084. PMAC_TYPE_TITANIUM2, core99_features,
  2085. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
  2086. },
  2087. { "PowerBook3,4", "PowerBook Titanium III",
  2088. PMAC_TYPE_TITANIUM3, core99_features,
  2089. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
  2090. },
  2091. { "PowerBook3,5", "PowerBook Titanium IV",
  2092. PMAC_TYPE_TITANIUM4, core99_features,
  2093. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
  2094. },
  2095. { "PowerBook4,1", "iBook 2",
  2096. PMAC_TYPE_IBOOK2, pangea_features,
  2097. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
  2098. },
  2099. { "PowerBook4,2", "iBook 2",
  2100. PMAC_TYPE_IBOOK2, pangea_features,
  2101. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
  2102. },
  2103. { "PowerBook4,3", "iBook 2 rev. 2",
  2104. PMAC_TYPE_IBOOK2, pangea_features,
  2105. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
  2106. },
  2107. { "PowerBook5,1", "PowerBook G4 17\"",
  2108. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2109. PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
  2110. },
  2111. { "PowerBook5,2", "PowerBook G4 15\"",
  2112. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2113. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
  2114. },
  2115. { "PowerBook5,3", "PowerBook G4 17\"",
  2116. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2117. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
  2118. },
  2119. { "PowerBook5,4", "PowerBook G4 15\"",
  2120. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2121. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
  2122. },
  2123. { "PowerBook5,5", "PowerBook G4 17\"",
  2124. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2125. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
  2126. },
  2127. { "PowerBook5,6", "PowerBook G4 15\"",
  2128. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2129. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
  2130. },
  2131. { "PowerBook5,7", "PowerBook G4 17\"",
  2132. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2133. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
  2134. },
  2135. { "PowerBook6,1", "PowerBook G4 12\"",
  2136. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2137. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
  2138. },
  2139. { "PowerBook6,2", "PowerBook G4",
  2140. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2141. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
  2142. },
  2143. { "PowerBook6,3", "iBook G4",
  2144. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2145. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
  2146. },
  2147. { "PowerBook6,4", "PowerBook G4 12\"",
  2148. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2149. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
  2150. },
  2151. { "PowerBook6,5", "iBook G4",
  2152. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2153. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
  2154. },
  2155. { "PowerBook6,7", "iBook G4",
  2156. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2157. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
  2158. },
  2159. { "PowerBook6,8", "PowerBook G4 12\"",
  2160. PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
  2161. PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
  2162. },
  2163. #else /* CONFIG_POWER4 */
  2164. { "PowerMac7,2", "PowerMac G5",
  2165. PMAC_TYPE_POWERMAC_G5, g5_features,
  2166. 0,
  2167. },
  2168. #ifdef CONFIG_PPC64
  2169. { "PowerMac7,3", "PowerMac G5",
  2170. PMAC_TYPE_POWERMAC_G5, g5_features,
  2171. 0,
  2172. },
  2173. { "PowerMac8,1", "iMac G5",
  2174. PMAC_TYPE_IMAC_G5, g5_features,
  2175. 0,
  2176. },
  2177. { "PowerMac9,1", "PowerMac G5",
  2178. PMAC_TYPE_POWERMAC_G5_U3L, g5_features,
  2179. 0,
  2180. },
  2181. { "RackMac3,1", "XServe G5",
  2182. PMAC_TYPE_XSERVE_G5, g5_features,
  2183. 0,
  2184. },
  2185. #endif /* CONFIG_PPC64 */
  2186. #endif /* CONFIG_POWER4 */
  2187. };
  2188. /*
  2189. * The toplevel feature_call callback
  2190. */
  2191. long pmac_do_feature_call(unsigned int selector, ...)
  2192. {
  2193. struct device_node *node;
  2194. long param, value;
  2195. int i;
  2196. feature_call func = NULL;
  2197. va_list args;
  2198. if (pmac_mb.features)
  2199. for (i=0; pmac_mb.features[i].function; i++)
  2200. if (pmac_mb.features[i].selector == selector) {
  2201. func = pmac_mb.features[i].function;
  2202. break;
  2203. }
  2204. if (!func)
  2205. for (i=0; any_features[i].function; i++)
  2206. if (any_features[i].selector == selector) {
  2207. func = any_features[i].function;
  2208. break;
  2209. }
  2210. if (!func)
  2211. return -ENODEV;
  2212. va_start(args, selector);
  2213. node = (struct device_node*)va_arg(args, void*);
  2214. param = va_arg(args, long);
  2215. value = va_arg(args, long);
  2216. va_end(args);
  2217. return func(node, param, value);
  2218. }
  2219. static int __init probe_motherboard(void)
  2220. {
  2221. int i;
  2222. struct macio_chip *macio = &macio_chips[0];
  2223. const char *model = NULL;
  2224. struct device_node *dt;
  2225. /* Lookup known motherboard type in device-tree. First try an
  2226. * exact match on the "model" property, then try a "compatible"
  2227. * match is none is found.
  2228. */
  2229. dt = find_devices("device-tree");
  2230. if (dt != NULL)
  2231. model = (const char *) get_property(dt, "model", NULL);
  2232. for(i=0; model && i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) {
  2233. if (strcmp(model, pmac_mb_defs[i].model_string) == 0) {
  2234. pmac_mb = pmac_mb_defs[i];
  2235. goto found;
  2236. }
  2237. }
  2238. for(i=0; i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) {
  2239. if (machine_is_compatible(pmac_mb_defs[i].model_string)) {
  2240. pmac_mb = pmac_mb_defs[i];
  2241. goto found;
  2242. }
  2243. }
  2244. /* Fallback to selection depending on mac-io chip type */
  2245. switch(macio->type) {
  2246. #ifndef CONFIG_POWER4
  2247. case macio_grand_central:
  2248. pmac_mb.model_id = PMAC_TYPE_PSURGE;
  2249. pmac_mb.model_name = "Unknown PowerSurge";
  2250. break;
  2251. case macio_ohare:
  2252. pmac_mb.model_id = PMAC_TYPE_UNKNOWN_OHARE;
  2253. pmac_mb.model_name = "Unknown OHare-based";
  2254. break;
  2255. case macio_heathrow:
  2256. pmac_mb.model_id = PMAC_TYPE_UNKNOWN_HEATHROW;
  2257. pmac_mb.model_name = "Unknown Heathrow-based";
  2258. pmac_mb.features = heathrow_desktop_features;
  2259. break;
  2260. case macio_paddington:
  2261. pmac_mb.model_id = PMAC_TYPE_UNKNOWN_PADDINGTON;
  2262. pmac_mb.model_name = "Unknown Paddington-based";
  2263. pmac_mb.features = paddington_features;
  2264. break;
  2265. case macio_keylargo:
  2266. pmac_mb.model_id = PMAC_TYPE_UNKNOWN_CORE99;
  2267. pmac_mb.model_name = "Unknown Keylargo-based";
  2268. pmac_mb.features = core99_features;
  2269. break;
  2270. case macio_pangea:
  2271. pmac_mb.model_id = PMAC_TYPE_UNKNOWN_PANGEA;
  2272. pmac_mb.model_name = "Unknown Pangea-based";
  2273. pmac_mb.features = pangea_features;
  2274. break;
  2275. case macio_intrepid:
  2276. pmac_mb.model_id = PMAC_TYPE_UNKNOWN_INTREPID;
  2277. pmac_mb.model_name = "Unknown Intrepid-based";
  2278. pmac_mb.features = intrepid_features;
  2279. break;
  2280. #else /* CONFIG_POWER4 */
  2281. case macio_keylargo2:
  2282. pmac_mb.model_id = PMAC_TYPE_UNKNOWN_K2;
  2283. pmac_mb.model_name = "Unknown K2-based";
  2284. pmac_mb.features = g5_features;
  2285. break;
  2286. #endif /* CONFIG_POWER4 */
  2287. default:
  2288. return -ENODEV;
  2289. }
  2290. found:
  2291. #ifndef CONFIG_POWER4
  2292. /* Fixup Hooper vs. Comet */
  2293. if (pmac_mb.model_id == PMAC_TYPE_HOOPER) {
  2294. u32 __iomem * mach_id_ptr = ioremap(0xf3000034, 4);
  2295. if (!mach_id_ptr)
  2296. return -ENODEV;
  2297. /* Here, I used to disable the media-bay on comet. It
  2298. * appears this is wrong, the floppy connector is actually
  2299. * a kind of media-bay and works with the current driver.
  2300. */
  2301. if (__raw_readl(mach_id_ptr) & 0x20000000UL)
  2302. pmac_mb.model_id = PMAC_TYPE_COMET;
  2303. iounmap(mach_id_ptr);
  2304. }
  2305. #endif /* CONFIG_POWER4 */
  2306. #ifdef CONFIG_6xx
  2307. /* Set default value of powersave_nap on machines that support it.
  2308. * It appears that uninorth rev 3 has a problem with it, we don't
  2309. * enable it on those. In theory, the flush-on-lock property is
  2310. * supposed to be set when not supported, but I'm not very confident
  2311. * that all Apple OF revs did it properly, I do it the paranoid way.
  2312. */
  2313. while (uninorth_base && uninorth_rev > 3) {
  2314. struct device_node *np = find_path_device("/cpus");
  2315. if (!np || !np->child) {
  2316. printk(KERN_WARNING "Can't find CPU(s) in device tree !\n");
  2317. break;
  2318. }
  2319. np = np->child;
  2320. /* Nap mode not supported on SMP */
  2321. if (np->sibling)
  2322. break;
  2323. /* Nap mode not supported if flush-on-lock property is present */
  2324. if (get_property(np, "flush-on-lock", NULL))
  2325. break;
  2326. powersave_nap = 1;
  2327. printk(KERN_INFO "Processor NAP mode on idle enabled.\n");
  2328. break;
  2329. }
  2330. /* On CPUs that support it (750FX), lowspeed by default during
  2331. * NAP mode
  2332. */
  2333. powersave_lowspeed = 1;
  2334. #endif /* CONFIG_6xx */
  2335. #ifdef CONFIG_POWER4
  2336. powersave_nap = 1;
  2337. #endif
  2338. /* Check for "mobile" machine */
  2339. if (model && (strncmp(model, "PowerBook", 9) == 0
  2340. || strncmp(model, "iBook", 5) == 0))
  2341. pmac_mb.board_flags |= PMAC_MB_MOBILE;
  2342. printk(KERN_INFO "PowerMac motherboard: %s\n", pmac_mb.model_name);
  2343. return 0;
  2344. }
  2345. /* Initialize the Core99 UniNorth host bridge and memory controller
  2346. */
  2347. static void __init probe_uninorth(void)
  2348. {
  2349. unsigned long actrl;
  2350. /* Locate core99 Uni-N */
  2351. uninorth_node = of_find_node_by_name(NULL, "uni-n");
  2352. /* Locate G5 u3 */
  2353. if (uninorth_node == NULL) {
  2354. uninorth_node = of_find_node_by_name(NULL, "u3");
  2355. uninorth_u3 = 1;
  2356. }
  2357. if (uninorth_node && uninorth_node->n_addrs > 0) {
  2358. unsigned long address = uninorth_node->addrs[0].address;
  2359. uninorth_base = ioremap(address, 0x40000);
  2360. uninorth_rev = in_be32(UN_REG(UNI_N_VERSION));
  2361. if (uninorth_u3)
  2362. u3_ht = ioremap(address + U3_HT_CONFIG_BASE, 0x1000);
  2363. } else
  2364. uninorth_node = NULL;
  2365. if (!uninorth_node)
  2366. return;
  2367. printk(KERN_INFO "Found %s memory controller & host bridge, revision: %d\n",
  2368. uninorth_u3 ? "U3" : "UniNorth", uninorth_rev);
  2369. printk(KERN_INFO "Mapped at 0x%08lx\n", (unsigned long)uninorth_base);
  2370. /* Set the arbitrer QAck delay according to what Apple does
  2371. */
  2372. if (uninorth_rev < 0x11) {
  2373. actrl = UN_IN(UNI_N_ARB_CTRL) & ~UNI_N_ARB_CTRL_QACK_DELAY_MASK;
  2374. actrl |= ((uninorth_rev < 3) ? UNI_N_ARB_CTRL_QACK_DELAY105 :
  2375. UNI_N_ARB_CTRL_QACK_DELAY) << UNI_N_ARB_CTRL_QACK_DELAY_SHIFT;
  2376. UN_OUT(UNI_N_ARB_CTRL, actrl);
  2377. }
  2378. /* Some more magic as done by them in recent MacOS X on UniNorth
  2379. * revs 1.5 to 2.O and Pangea. Seem to toggle the UniN Maxbus/PCI
  2380. * memory timeout
  2381. */
  2382. if ((uninorth_rev >= 0x11 && uninorth_rev <= 0x24) || uninorth_rev == 0xc0)
  2383. UN_OUT(0x2160, UN_IN(0x2160) & 0x00ffffff);
  2384. }
  2385. static void __init probe_one_macio(const char *name, const char *compat, int type)
  2386. {
  2387. struct device_node* node;
  2388. int i;
  2389. volatile u32 __iomem * base;
  2390. u32* revp;
  2391. node = find_devices(name);
  2392. if (!node || !node->n_addrs)
  2393. return;
  2394. if (compat)
  2395. do {
  2396. if (device_is_compatible(node, compat))
  2397. break;
  2398. node = node->next;
  2399. } while (node);
  2400. if (!node)
  2401. return;
  2402. for(i=0; i<MAX_MACIO_CHIPS; i++) {
  2403. if (!macio_chips[i].of_node)
  2404. break;
  2405. if (macio_chips[i].of_node == node)
  2406. return;
  2407. }
  2408. if (i >= MAX_MACIO_CHIPS) {
  2409. printk(KERN_ERR "pmac_feature: Please increase MAX_MACIO_CHIPS !\n");
  2410. printk(KERN_ERR "pmac_feature: %s skipped\n", node->full_name);
  2411. return;
  2412. }
  2413. base = ioremap(node->addrs[0].address, node->addrs[0].size);
  2414. if (!base) {
  2415. printk(KERN_ERR "pmac_feature: Can't map mac-io chip !\n");
  2416. return;
  2417. }
  2418. if (type == macio_keylargo) {
  2419. u32 *did = (u32 *)get_property(node, "device-id", NULL);
  2420. if (*did == 0x00000025)
  2421. type = macio_pangea;
  2422. if (*did == 0x0000003e)
  2423. type = macio_intrepid;
  2424. }
  2425. macio_chips[i].of_node = node;
  2426. macio_chips[i].type = type;
  2427. macio_chips[i].base = base;
  2428. macio_chips[i].flags = MACIO_FLAG_SCCB_ON | MACIO_FLAG_SCCB_ON;
  2429. macio_chips[i].name = macio_names[type];
  2430. revp = (u32 *)get_property(node, "revision-id", NULL);
  2431. if (revp)
  2432. macio_chips[i].rev = *revp;
  2433. printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n",
  2434. macio_names[type], macio_chips[i].rev, macio_chips[i].base);
  2435. }
  2436. static int __init
  2437. probe_macios(void)
  2438. {
  2439. /* Warning, ordering is important */
  2440. probe_one_macio("gc", NULL, macio_grand_central);
  2441. probe_one_macio("ohare", NULL, macio_ohare);
  2442. probe_one_macio("pci106b,7", NULL, macio_ohareII);
  2443. probe_one_macio("mac-io", "keylargo", macio_keylargo);
  2444. probe_one_macio("mac-io", "paddington", macio_paddington);
  2445. probe_one_macio("mac-io", "gatwick", macio_gatwick);
  2446. probe_one_macio("mac-io", "heathrow", macio_heathrow);
  2447. probe_one_macio("mac-io", "K2-Keylargo", macio_keylargo2);
  2448. /* Make sure the "main" macio chip appear first */
  2449. if (macio_chips[0].type == macio_gatwick
  2450. && macio_chips[1].type == macio_heathrow) {
  2451. struct macio_chip temp = macio_chips[0];
  2452. macio_chips[0] = macio_chips[1];
  2453. macio_chips[1] = temp;
  2454. }
  2455. if (macio_chips[0].type == macio_ohareII
  2456. && macio_chips[1].type == macio_ohare) {
  2457. struct macio_chip temp = macio_chips[0];
  2458. macio_chips[0] = macio_chips[1];
  2459. macio_chips[1] = temp;
  2460. }
  2461. macio_chips[0].lbus.index = 0;
  2462. macio_chips[1].lbus.index = 1;
  2463. return (macio_chips[0].of_node == NULL) ? -ENODEV : 0;
  2464. }
  2465. static void __init
  2466. initial_serial_shutdown(struct device_node *np)
  2467. {
  2468. int len;
  2469. struct slot_names_prop {
  2470. int count;
  2471. char name[1];
  2472. } *slots;
  2473. char *conn;
  2474. int port_type = PMAC_SCC_ASYNC;
  2475. int modem = 0;
  2476. slots = (struct slot_names_prop *)get_property(np, "slot-names", &len);
  2477. conn = get_property(np, "AAPL,connector", &len);
  2478. if (conn && (strcmp(conn, "infrared") == 0))
  2479. port_type = PMAC_SCC_IRDA;
  2480. else if (device_is_compatible(np, "cobalt"))
  2481. modem = 1;
  2482. else if (slots && slots->count > 0) {
  2483. if (strcmp(slots->name, "IrDA") == 0)
  2484. port_type = PMAC_SCC_IRDA;
  2485. else if (strcmp(slots->name, "Modem") == 0)
  2486. modem = 1;
  2487. }
  2488. if (modem)
  2489. pmac_call_feature(PMAC_FTR_MODEM_ENABLE, np, 0, 0);
  2490. pmac_call_feature(PMAC_FTR_SCC_ENABLE, np, port_type, 0);
  2491. }
  2492. static void __init
  2493. set_initial_features(void)
  2494. {
  2495. struct device_node *np;
  2496. /* That hack appears to be necessary for some StarMax motherboards
  2497. * but I'm not too sure it was audited for side-effects on other
  2498. * ohare based machines...
  2499. * Since I still have difficulties figuring the right way to
  2500. * differenciate them all and since that hack was there for a long
  2501. * time, I'll keep it around
  2502. */
  2503. if (macio_chips[0].type == macio_ohare && !find_devices("via-pmu")) {
  2504. struct macio_chip *macio = &macio_chips[0];
  2505. MACIO_OUT32(OHARE_FCR, STARMAX_FEATURES);
  2506. } else if (macio_chips[0].type == macio_ohare) {
  2507. struct macio_chip *macio = &macio_chips[0];
  2508. MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);
  2509. } else if (macio_chips[1].type == macio_ohare) {
  2510. struct macio_chip *macio = &macio_chips[1];
  2511. MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);
  2512. }
  2513. #ifdef CONFIG_POWER4
  2514. if (macio_chips[0].type == macio_keylargo2) {
  2515. #ifndef CONFIG_SMP
  2516. /* On SMP machines running UP, we have the second CPU eating
  2517. * bus cycles. We need to take it off the bus. This is done
  2518. * from pmac_smp for SMP kernels running on one CPU
  2519. */
  2520. np = of_find_node_by_type(NULL, "cpu");
  2521. if (np != NULL)
  2522. np = of_find_node_by_type(np, "cpu");
  2523. if (np != NULL) {
  2524. g5_phy_disable_cpu1();
  2525. of_node_put(np);
  2526. }
  2527. #endif /* CONFIG_SMP */
  2528. /* Enable GMAC for now for PCI probing. It will be disabled
  2529. * later on after PCI probe
  2530. */
  2531. np = of_find_node_by_name(NULL, "ethernet");
  2532. while(np) {
  2533. if (device_is_compatible(np, "K2-GMAC"))
  2534. g5_gmac_enable(np, 0, 1);
  2535. np = of_find_node_by_name(np, "ethernet");
  2536. }
  2537. /* Enable FW before PCI probe. Will be disabled later on
  2538. * Note: We should have a batter way to check that we are
  2539. * dealing with uninorth internal cell and not a PCI cell
  2540. * on the external PCI. The code below works though.
  2541. */
  2542. np = of_find_node_by_name(NULL, "firewire");
  2543. while(np) {
  2544. if (device_is_compatible(np, "pci106b,5811")) {
  2545. macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;
  2546. g5_fw_enable(np, 0, 1);
  2547. }
  2548. np = of_find_node_by_name(np, "firewire");
  2549. }
  2550. }
  2551. #else /* CONFIG_POWER4 */
  2552. if (macio_chips[0].type == macio_keylargo ||
  2553. macio_chips[0].type == macio_pangea ||
  2554. macio_chips[0].type == macio_intrepid) {
  2555. /* Enable GMAC for now for PCI probing. It will be disabled
  2556. * later on after PCI probe
  2557. */
  2558. np = of_find_node_by_name(NULL, "ethernet");
  2559. while(np) {
  2560. if (np->parent
  2561. && device_is_compatible(np->parent, "uni-north")
  2562. && device_is_compatible(np, "gmac"))
  2563. core99_gmac_enable(np, 0, 1);
  2564. np = of_find_node_by_name(np, "ethernet");
  2565. }
  2566. /* Enable FW before PCI probe. Will be disabled later on
  2567. * Note: We should have a batter way to check that we are
  2568. * dealing with uninorth internal cell and not a PCI cell
  2569. * on the external PCI. The code below works though.
  2570. */
  2571. np = of_find_node_by_name(NULL, "firewire");
  2572. while(np) {
  2573. if (np->parent
  2574. && device_is_compatible(np->parent, "uni-north")
  2575. && (device_is_compatible(np, "pci106b,18") ||
  2576. device_is_compatible(np, "pci106b,30") ||
  2577. device_is_compatible(np, "pci11c1,5811"))) {
  2578. macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;
  2579. core99_firewire_enable(np, 0, 1);
  2580. }
  2581. np = of_find_node_by_name(np, "firewire");
  2582. }
  2583. /* Enable ATA-100 before PCI probe. */
  2584. np = of_find_node_by_name(NULL, "ata-6");
  2585. while(np) {
  2586. if (np->parent
  2587. && device_is_compatible(np->parent, "uni-north")
  2588. && device_is_compatible(np, "kauai-ata")) {
  2589. core99_ata100_enable(np, 1);
  2590. }
  2591. np = of_find_node_by_name(np, "ata-6");
  2592. }
  2593. /* Switch airport off */
  2594. np = find_devices("radio");
  2595. while(np) {
  2596. if (np && np->parent == macio_chips[0].of_node) {
  2597. macio_chips[0].flags |= MACIO_FLAG_AIRPORT_ON;
  2598. core99_airport_enable(np, 0, 0);
  2599. }
  2600. np = np->next;
  2601. }
  2602. }
  2603. /* On all machines that support sound PM, switch sound off */
  2604. if (macio_chips[0].of_node)
  2605. pmac_do_feature_call(PMAC_FTR_SOUND_CHIP_ENABLE,
  2606. macio_chips[0].of_node, 0, 0);
  2607. /* While on some desktop G3s, we turn it back on */
  2608. if (macio_chips[0].of_node && macio_chips[0].type == macio_heathrow
  2609. && (pmac_mb.model_id == PMAC_TYPE_GOSSAMER ||
  2610. pmac_mb.model_id == PMAC_TYPE_SILK)) {
  2611. struct macio_chip *macio = &macio_chips[0];
  2612. MACIO_BIS(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE);
  2613. MACIO_BIC(HEATHROW_FCR, HRW_SOUND_POWER_N);
  2614. }
  2615. /* Some machine models need the clock chip to be properly setup for
  2616. * clock spreading now. This should be a platform function but we
  2617. * don't do these at the moment
  2618. */
  2619. pmac_tweak_clock_spreading(1);
  2620. #endif /* CONFIG_POWER4 */
  2621. /* On all machines, switch modem & serial ports off */
  2622. np = find_devices("ch-a");
  2623. while(np) {
  2624. initial_serial_shutdown(np);
  2625. np = np->next;
  2626. }
  2627. np = find_devices("ch-b");
  2628. while(np) {
  2629. initial_serial_shutdown(np);
  2630. np = np->next;
  2631. }
  2632. }
  2633. void __init
  2634. pmac_feature_init(void)
  2635. {
  2636. /* Detect the UniNorth memory controller */
  2637. probe_uninorth();
  2638. /* Probe mac-io controllers */
  2639. if (probe_macios()) {
  2640. printk(KERN_WARNING "No mac-io chip found\n");
  2641. return;
  2642. }
  2643. /* Setup low-level i2c stuffs */
  2644. pmac_init_low_i2c();
  2645. /* Probe machine type */
  2646. if (probe_motherboard())
  2647. printk(KERN_WARNING "Unknown PowerMac !\n");
  2648. /* Set some initial features (turn off some chips that will
  2649. * be later turned on)
  2650. */
  2651. set_initial_features();
  2652. }
  2653. int __init pmac_feature_late_init(void)
  2654. {
  2655. #if 0
  2656. struct device_node *np;
  2657. /* Request some resources late */
  2658. if (uninorth_node)
  2659. request_OF_resource(uninorth_node, 0, NULL);
  2660. np = find_devices("hammerhead");
  2661. if (np)
  2662. request_OF_resource(np, 0, NULL);
  2663. np = find_devices("interrupt-controller");
  2664. if (np)
  2665. request_OF_resource(np, 0, NULL);
  2666. #endif
  2667. return 0;
  2668. }
  2669. device_initcall(pmac_feature_late_init);
  2670. #if 0
  2671. static void dump_HT_speeds(char *name, u32 cfg, u32 frq)
  2672. {
  2673. int freqs[16] = { 200,300,400,500,600,800,1000,0,0,0,0,0,0,0,0,0 };
  2674. int bits[8] = { 8,16,0,32,2,4,0,0 };
  2675. int freq = (frq >> 8) & 0xf;
  2676. if (freqs[freq] == 0)
  2677. printk("%s: Unknown HT link frequency %x\n", name, freq);
  2678. else
  2679. printk("%s: %d MHz on main link, (%d in / %d out) bits width\n",
  2680. name, freqs[freq],
  2681. bits[(cfg >> 28) & 0x7], bits[(cfg >> 24) & 0x7]);
  2682. }
  2683. void __init pmac_check_ht_link(void)
  2684. {
  2685. u32 ufreq, freq, ucfg, cfg;
  2686. struct device_node *pcix_node;
  2687. u8 px_bus, px_devfn;
  2688. struct pci_controller *px_hose;
  2689. (void)in_be32(u3_ht + U3_HT_LINK_COMMAND);
  2690. ucfg = cfg = in_be32(u3_ht + U3_HT_LINK_CONFIG);
  2691. ufreq = freq = in_be32(u3_ht + U3_HT_LINK_FREQ);
  2692. dump_HT_speeds("U3 HyperTransport", cfg, freq);
  2693. pcix_node = of_find_compatible_node(NULL, "pci", "pci-x");
  2694. if (pcix_node == NULL) {
  2695. printk("No PCI-X bridge found\n");
  2696. return;
  2697. }
  2698. if (pci_device_from_OF_node(pcix_node, &px_bus, &px_devfn) != 0) {
  2699. printk("PCI-X bridge found but not matched to pci\n");
  2700. return;
  2701. }
  2702. px_hose = pci_find_hose_for_OF_device(pcix_node);
  2703. if (px_hose == NULL) {
  2704. printk("PCI-X bridge found but not matched to host\n");
  2705. return;
  2706. }
  2707. early_read_config_dword(px_hose, px_bus, px_devfn, 0xc4, &cfg);
  2708. early_read_config_dword(px_hose, px_bus, px_devfn, 0xcc, &freq);
  2709. dump_HT_speeds("PCI-X HT Uplink", cfg, freq);
  2710. early_read_config_dword(px_hose, px_bus, px_devfn, 0xc8, &cfg);
  2711. early_read_config_dword(px_hose, px_bus, px_devfn, 0xd0, &freq);
  2712. dump_HT_speeds("PCI-X HT Downlink", cfg, freq);
  2713. }
  2714. #endif /* 0 */
  2715. /*
  2716. * Early video resume hook
  2717. */
  2718. static void (*pmac_early_vresume_proc)(void *data);
  2719. static void *pmac_early_vresume_data;
  2720. void pmac_set_early_video_resume(void (*proc)(void *data), void *data)
  2721. {
  2722. if (_machine != _MACH_Pmac)
  2723. return;
  2724. preempt_disable();
  2725. pmac_early_vresume_proc = proc;
  2726. pmac_early_vresume_data = data;
  2727. preempt_enable();
  2728. }
  2729. EXPORT_SYMBOL(pmac_set_early_video_resume);
  2730. void pmac_call_early_video_resume(void)
  2731. {
  2732. if (pmac_early_vresume_proc)
  2733. pmac_early_vresume_proc(pmac_early_vresume_data);
  2734. }
  2735. /*
  2736. * AGP related suspend/resume code
  2737. */
  2738. static struct pci_dev *pmac_agp_bridge;
  2739. static int (*pmac_agp_suspend)(struct pci_dev *bridge);
  2740. static int (*pmac_agp_resume)(struct pci_dev *bridge);
  2741. void pmac_register_agp_pm(struct pci_dev *bridge,
  2742. int (*suspend)(struct pci_dev *bridge),
  2743. int (*resume)(struct pci_dev *bridge))
  2744. {
  2745. if (suspend || resume) {
  2746. pmac_agp_bridge = bridge;
  2747. pmac_agp_suspend = suspend;
  2748. pmac_agp_resume = resume;
  2749. return;
  2750. }
  2751. if (bridge != pmac_agp_bridge)
  2752. return;
  2753. pmac_agp_suspend = pmac_agp_resume = NULL;
  2754. return;
  2755. }
  2756. EXPORT_SYMBOL(pmac_register_agp_pm);
  2757. void pmac_suspend_agp_for_card(struct pci_dev *dev)
  2758. {
  2759. if (pmac_agp_bridge == NULL || pmac_agp_suspend == NULL)
  2760. return;
  2761. if (pmac_agp_bridge->bus != dev->bus)
  2762. return;
  2763. pmac_agp_suspend(pmac_agp_bridge);
  2764. }
  2765. EXPORT_SYMBOL(pmac_suspend_agp_for_card);
  2766. void pmac_resume_agp_for_card(struct pci_dev *dev)
  2767. {
  2768. if (pmac_agp_bridge == NULL || pmac_agp_resume == NULL)
  2769. return;
  2770. if (pmac_agp_bridge->bus != dev->bus)
  2771. return;
  2772. pmac_agp_resume(pmac_agp_bridge);
  2773. }
  2774. EXPORT_SYMBOL(pmac_resume_agp_for_card);