cirrusfb.c 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952
  1. /*
  2. * drivers/video/cirrusfb.c - driver for Cirrus Logic chipsets
  3. *
  4. * Copyright 1999-2001 Jeff Garzik <jgarzik@pobox.com>
  5. *
  6. * Contributors (thanks, all!)
  7. *
  8. * David Eger:
  9. * Overhaul for Linux 2.6
  10. *
  11. * Jeff Rugen:
  12. * Major contributions; Motorola PowerStack (PPC and PCI) support,
  13. * GD54xx, 1280x1024 mode support, change MCLK based on VCLK.
  14. *
  15. * Geert Uytterhoeven:
  16. * Excellent code review.
  17. *
  18. * Lars Hecking:
  19. * Amiga updates and testing.
  20. *
  21. * Original cirrusfb author: Frank Neumann
  22. *
  23. * Based on retz3fb.c and cirrusfb.c:
  24. * Copyright (C) 1997 Jes Sorensen
  25. * Copyright (C) 1996 Frank Neumann
  26. *
  27. ***************************************************************
  28. *
  29. * Format this code with GNU indent '-kr -i8 -pcs' options.
  30. *
  31. * This file is subject to the terms and conditions of the GNU General Public
  32. * License. See the file COPYING in the main directory of this archive
  33. * for more details.
  34. *
  35. */
  36. #include <linux/module.h>
  37. #include <linux/kernel.h>
  38. #include <linux/errno.h>
  39. #include <linux/string.h>
  40. #include <linux/mm.h>
  41. #include <linux/delay.h>
  42. #include <linux/fb.h>
  43. #include <linux/init.h>
  44. #include <asm/pgtable.h>
  45. #ifdef CONFIG_ZORRO
  46. #include <linux/zorro.h>
  47. #endif
  48. #ifdef CONFIG_PCI
  49. #include <linux/pci.h>
  50. #endif
  51. #ifdef CONFIG_AMIGA
  52. #include <asm/amigahw.h>
  53. #endif
  54. #include <video/vga.h>
  55. #include <video/cirrus.h>
  56. /*****************************************************************
  57. *
  58. * debugging and utility macros
  59. *
  60. */
  61. /* disable runtime assertions? */
  62. /* #define CIRRUSFB_NDEBUG */
  63. /* debugging assertions */
  64. #ifndef CIRRUSFB_NDEBUG
  65. #define assert(expr) \
  66. if (!(expr)) { \
  67. printk("Assertion failed! %s,%s,%s,line=%d\n", \
  68. #expr, __FILE__, __func__, __LINE__); \
  69. }
  70. #else
  71. #define assert(expr)
  72. #endif
  73. #define MB_ (1024 * 1024)
  74. /*****************************************************************
  75. *
  76. * chipset information
  77. *
  78. */
  79. /* board types */
  80. enum cirrus_board {
  81. BT_NONE = 0,
  82. BT_SD64, /* GD5434 */
  83. BT_PICCOLO, /* GD5426 */
  84. BT_PICASSO, /* GD5426 or GD5428 */
  85. BT_SPECTRUM, /* GD5426 or GD5428 */
  86. BT_PICASSO4, /* GD5446 */
  87. BT_ALPINE, /* GD543x/4x */
  88. BT_GD5480,
  89. BT_LAGUNA, /* GD5462/64 */
  90. BT_LAGUNAB, /* GD5465 */
  91. };
  92. /*
  93. * per-board-type information, used for enumerating and abstracting
  94. * chip-specific information
  95. * NOTE: MUST be in the same order as enum cirrus_board in order to
  96. * use direct indexing on this array
  97. * NOTE: '__initdata' cannot be used as some of this info
  98. * is required at runtime. Maybe separate into an init-only and
  99. * a run-time table?
  100. */
  101. static const struct cirrusfb_board_info_rec {
  102. char *name; /* ASCII name of chipset */
  103. long maxclock[5]; /* maximum video clock */
  104. /* for 1/4bpp, 8bpp 15/16bpp, 24bpp, 32bpp - numbers from xorg code */
  105. bool init_sr07 : 1; /* init SR07 during init_vgachip() */
  106. bool init_sr1f : 1; /* write SR1F during init_vgachip() */
  107. /* construct bit 19 of screen start address */
  108. bool scrn_start_bit19 : 1;
  109. /* initial SR07 value, then for each mode */
  110. unsigned char sr07;
  111. unsigned char sr07_1bpp;
  112. unsigned char sr07_1bpp_mux;
  113. unsigned char sr07_8bpp;
  114. unsigned char sr07_8bpp_mux;
  115. unsigned char sr1f; /* SR1F VGA initial register value */
  116. } cirrusfb_board_info[] = {
  117. [BT_SD64] = {
  118. .name = "CL SD64",
  119. .maxclock = {
  120. /* guess */
  121. /* the SD64/P4 have a higher max. videoclock */
  122. 135100, 135100, 85500, 85500, 0
  123. },
  124. .init_sr07 = true,
  125. .init_sr1f = true,
  126. .scrn_start_bit19 = true,
  127. .sr07 = 0xF0,
  128. .sr07_1bpp = 0xF0,
  129. .sr07_1bpp_mux = 0xF6,
  130. .sr07_8bpp = 0xF1,
  131. .sr07_8bpp_mux = 0xF7,
  132. .sr1f = 0x1E
  133. },
  134. [BT_PICCOLO] = {
  135. .name = "CL Piccolo",
  136. .maxclock = {
  137. /* guess */
  138. 90000, 90000, 90000, 90000, 90000
  139. },
  140. .init_sr07 = true,
  141. .init_sr1f = true,
  142. .scrn_start_bit19 = false,
  143. .sr07 = 0x80,
  144. .sr07_1bpp = 0x80,
  145. .sr07_8bpp = 0x81,
  146. .sr1f = 0x22
  147. },
  148. [BT_PICASSO] = {
  149. .name = "CL Picasso",
  150. .maxclock = {
  151. /* guess */
  152. 90000, 90000, 90000, 90000, 90000
  153. },
  154. .init_sr07 = true,
  155. .init_sr1f = true,
  156. .scrn_start_bit19 = false,
  157. .sr07 = 0x20,
  158. .sr07_1bpp = 0x20,
  159. .sr07_8bpp = 0x21,
  160. .sr1f = 0x22
  161. },
  162. [BT_SPECTRUM] = {
  163. .name = "CL Spectrum",
  164. .maxclock = {
  165. /* guess */
  166. 90000, 90000, 90000, 90000, 90000
  167. },
  168. .init_sr07 = true,
  169. .init_sr1f = true,
  170. .scrn_start_bit19 = false,
  171. .sr07 = 0x80,
  172. .sr07_1bpp = 0x80,
  173. .sr07_8bpp = 0x81,
  174. .sr1f = 0x22
  175. },
  176. [BT_PICASSO4] = {
  177. .name = "CL Picasso4",
  178. .maxclock = {
  179. 135100, 135100, 85500, 85500, 0
  180. },
  181. .init_sr07 = true,
  182. .init_sr1f = false,
  183. .scrn_start_bit19 = true,
  184. .sr07 = 0xA0,
  185. .sr07_1bpp = 0xA0,
  186. .sr07_1bpp_mux = 0xA6,
  187. .sr07_8bpp = 0xA1,
  188. .sr07_8bpp_mux = 0xA7,
  189. .sr1f = 0
  190. },
  191. [BT_ALPINE] = {
  192. .name = "CL Alpine",
  193. .maxclock = {
  194. /* for the GD5430. GD5446 can do more... */
  195. 85500, 85500, 50000, 28500, 0
  196. },
  197. .init_sr07 = true,
  198. .init_sr1f = true,
  199. .scrn_start_bit19 = true,
  200. .sr07 = 0xA0,
  201. .sr07_1bpp = 0xA0,
  202. .sr07_1bpp_mux = 0xA6,
  203. .sr07_8bpp = 0xA1,
  204. .sr07_8bpp_mux = 0xA7,
  205. .sr1f = 0x1C
  206. },
  207. [BT_GD5480] = {
  208. .name = "CL GD5480",
  209. .maxclock = {
  210. 135100, 200000, 200000, 135100, 135100
  211. },
  212. .init_sr07 = true,
  213. .init_sr1f = true,
  214. .scrn_start_bit19 = true,
  215. .sr07 = 0x10,
  216. .sr07_1bpp = 0x11,
  217. .sr07_8bpp = 0x11,
  218. .sr1f = 0x1C
  219. },
  220. [BT_LAGUNA] = {
  221. .name = "CL Laguna",
  222. .maxclock = {
  223. /* taken from X11 code */
  224. 170000, 170000, 170000, 170000, 135100,
  225. },
  226. .init_sr07 = false,
  227. .init_sr1f = false,
  228. .scrn_start_bit19 = true,
  229. },
  230. [BT_LAGUNAB] = {
  231. .name = "CL Laguna AGP",
  232. .maxclock = {
  233. /* taken from X11 code */
  234. 170000, 250000, 170000, 170000, 135100,
  235. },
  236. .init_sr07 = false,
  237. .init_sr1f = false,
  238. .scrn_start_bit19 = true,
  239. }
  240. };
  241. #ifdef CONFIG_PCI
  242. #define CHIP(id, btype) \
  243. { PCI_VENDOR_ID_CIRRUS, id, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (btype) }
  244. static struct pci_device_id cirrusfb_pci_table[] = {
  245. CHIP(PCI_DEVICE_ID_CIRRUS_5436, BT_ALPINE),
  246. CHIP(PCI_DEVICE_ID_CIRRUS_5434_8, BT_SD64),
  247. CHIP(PCI_DEVICE_ID_CIRRUS_5434_4, BT_SD64),
  248. CHIP(PCI_DEVICE_ID_CIRRUS_5430, BT_ALPINE), /* GD-5440 is same id */
  249. CHIP(PCI_DEVICE_ID_CIRRUS_7543, BT_ALPINE),
  250. CHIP(PCI_DEVICE_ID_CIRRUS_7548, BT_ALPINE),
  251. CHIP(PCI_DEVICE_ID_CIRRUS_5480, BT_GD5480), /* MacPicasso likely */
  252. CHIP(PCI_DEVICE_ID_CIRRUS_5446, BT_PICASSO4), /* Picasso 4 is 5446 */
  253. CHIP(PCI_DEVICE_ID_CIRRUS_5462, BT_LAGUNA), /* CL Laguna */
  254. CHIP(PCI_DEVICE_ID_CIRRUS_5464, BT_LAGUNA), /* CL Laguna 3D */
  255. CHIP(PCI_DEVICE_ID_CIRRUS_5465, BT_LAGUNAB), /* CL Laguna 3DA*/
  256. { 0, }
  257. };
  258. MODULE_DEVICE_TABLE(pci, cirrusfb_pci_table);
  259. #undef CHIP
  260. #endif /* CONFIG_PCI */
  261. #ifdef CONFIG_ZORRO
  262. struct zorrocl {
  263. enum cirrus_board type; /* Board type */
  264. u32 regoffset; /* Offset of registers in first Zorro device */
  265. u32 ramsize; /* Size of video RAM in first Zorro device */
  266. /* If zero, use autoprobe on RAM device */
  267. u32 ramoffset; /* Offset of video RAM in first Zorro device */
  268. zorro_id ramid; /* Zorro ID of RAM device */
  269. zorro_id ramid2; /* Zorro ID of optional second RAM device */
  270. };
  271. static const struct zorrocl zcl_sd64 = {
  272. .type = BT_SD64,
  273. .ramid = ZORRO_PROD_HELFRICH_SD64_RAM,
  274. };
  275. static const struct zorrocl zcl_piccolo = {
  276. .type = BT_PICCOLO,
  277. .ramid = ZORRO_PROD_HELFRICH_PICCOLO_RAM,
  278. };
  279. static const struct zorrocl zcl_picasso = {
  280. .type = BT_PICASSO,
  281. .ramid = ZORRO_PROD_VILLAGE_TRONIC_PICASSO_II_II_PLUS_RAM,
  282. };
  283. static const struct zorrocl zcl_spectrum = {
  284. .type = BT_SPECTRUM,
  285. .ramid = ZORRO_PROD_GVP_EGS_28_24_SPECTRUM_RAM,
  286. };
  287. static const struct zorrocl zcl_picasso4_z3 = {
  288. .type = BT_PICASSO4,
  289. .regoffset = 0x00600000,
  290. .ramsize = 4 * MB_,
  291. .ramoffset = 0x01000000, /* 0x02000000 for 64 MiB boards */
  292. };
  293. static const struct zorrocl zcl_picasso4_z2 = {
  294. .type = BT_PICASSO4,
  295. .regoffset = 0x10000,
  296. .ramid = ZORRO_PROD_VILLAGE_TRONIC_PICASSO_IV_Z2_RAM1,
  297. .ramid2 = ZORRO_PROD_VILLAGE_TRONIC_PICASSO_IV_Z2_RAM2,
  298. };
  299. static const struct zorro_device_id cirrusfb_zorro_table[] = {
  300. {
  301. .id = ZORRO_PROD_HELFRICH_SD64_REG,
  302. .driver_data = (unsigned long)&zcl_sd64,
  303. }, {
  304. .id = ZORRO_PROD_HELFRICH_PICCOLO_REG,
  305. .driver_data = (unsigned long)&zcl_piccolo,
  306. }, {
  307. .id = ZORRO_PROD_VILLAGE_TRONIC_PICASSO_II_II_PLUS_REG,
  308. .driver_data = (unsigned long)&zcl_picasso,
  309. }, {
  310. .id = ZORRO_PROD_GVP_EGS_28_24_SPECTRUM_REG,
  311. .driver_data = (unsigned long)&zcl_spectrum,
  312. }, {
  313. .id = ZORRO_PROD_VILLAGE_TRONIC_PICASSO_IV_Z3,
  314. .driver_data = (unsigned long)&zcl_picasso4_z3,
  315. }, {
  316. .id = ZORRO_PROD_VILLAGE_TRONIC_PICASSO_IV_Z2_REG,
  317. .driver_data = (unsigned long)&zcl_picasso4_z2,
  318. },
  319. { 0 }
  320. };
  321. MODULE_DEVICE_TABLE(zorro, cirrusfb_zorro_table);
  322. #endif /* CONFIG_ZORRO */
  323. #ifdef CIRRUSFB_DEBUG
  324. enum cirrusfb_dbg_reg_class {
  325. CRT,
  326. SEQ
  327. };
  328. #endif /* CIRRUSFB_DEBUG */
  329. /* info about board */
  330. struct cirrusfb_info {
  331. u8 __iomem *regbase;
  332. u8 __iomem *laguna_mmio;
  333. enum cirrus_board btype;
  334. unsigned char SFR; /* Shadow of special function register */
  335. int multiplexing;
  336. int doubleVCLK;
  337. int blank_mode;
  338. u32 pseudo_palette[16];
  339. void (*unmap)(struct fb_info *info);
  340. };
  341. static bool noaccel;
  342. static char *mode_option = "640x480@60";
  343. /****************************************************************************/
  344. /**** BEGIN PROTOTYPES ******************************************************/
  345. /*--- Interface used by the world ------------------------------------------*/
  346. static int cirrusfb_pan_display(struct fb_var_screeninfo *var,
  347. struct fb_info *info);
  348. /*--- Internal routines ----------------------------------------------------*/
  349. static void init_vgachip(struct fb_info *info);
  350. static void switch_monitor(struct cirrusfb_info *cinfo, int on);
  351. static void WGen(const struct cirrusfb_info *cinfo,
  352. int regnum, unsigned char val);
  353. static unsigned char RGen(const struct cirrusfb_info *cinfo, int regnum);
  354. static void AttrOn(const struct cirrusfb_info *cinfo);
  355. static void WHDR(const struct cirrusfb_info *cinfo, unsigned char val);
  356. static void WSFR(struct cirrusfb_info *cinfo, unsigned char val);
  357. static void WSFR2(struct cirrusfb_info *cinfo, unsigned char val);
  358. static void WClut(struct cirrusfb_info *cinfo, unsigned char regnum,
  359. unsigned char red, unsigned char green, unsigned char blue);
  360. #if 0
  361. static void RClut(struct cirrusfb_info *cinfo, unsigned char regnum,
  362. unsigned char *red, unsigned char *green,
  363. unsigned char *blue);
  364. #endif
  365. static void cirrusfb_WaitBLT(u8 __iomem *regbase);
  366. static void cirrusfb_BitBLT(u8 __iomem *regbase, int bits_per_pixel,
  367. u_short curx, u_short cury,
  368. u_short destx, u_short desty,
  369. u_short width, u_short height,
  370. u_short line_length);
  371. static void cirrusfb_RectFill(u8 __iomem *regbase, int bits_per_pixel,
  372. u_short x, u_short y,
  373. u_short width, u_short height,
  374. u32 fg_color, u32 bg_color,
  375. u_short line_length, u_char blitmode);
  376. static void bestclock(long freq, int *nom, int *den, int *div);
  377. #ifdef CIRRUSFB_DEBUG
  378. static void cirrusfb_dbg_reg_dump(struct fb_info *info, caddr_t regbase);
  379. static void cirrusfb_dbg_print_regs(struct fb_info *info,
  380. caddr_t regbase,
  381. enum cirrusfb_dbg_reg_class reg_class, ...);
  382. #endif /* CIRRUSFB_DEBUG */
  383. /*** END PROTOTYPES ********************************************************/
  384. /*****************************************************************************/
  385. /*** BEGIN Interface Used by the World ***************************************/
  386. static inline int is_laguna(const struct cirrusfb_info *cinfo)
  387. {
  388. return cinfo->btype == BT_LAGUNA || cinfo->btype == BT_LAGUNAB;
  389. }
  390. static int opencount;
  391. /*--- Open /dev/fbx ---------------------------------------------------------*/
  392. static int cirrusfb_open(struct fb_info *info, int user)
  393. {
  394. if (opencount++ == 0)
  395. switch_monitor(info->par, 1);
  396. return 0;
  397. }
  398. /*--- Close /dev/fbx --------------------------------------------------------*/
  399. static int cirrusfb_release(struct fb_info *info, int user)
  400. {
  401. if (--opencount == 0)
  402. switch_monitor(info->par, 0);
  403. return 0;
  404. }
  405. /**** END Interface used by the World *************************************/
  406. /****************************************************************************/
  407. /**** BEGIN Hardware specific Routines **************************************/
  408. /* Check if the MCLK is not a better clock source */
  409. static int cirrusfb_check_mclk(struct fb_info *info, long freq)
  410. {
  411. struct cirrusfb_info *cinfo = info->par;
  412. long mclk = vga_rseq(cinfo->regbase, CL_SEQR1F) & 0x3f;
  413. /* Read MCLK value */
  414. mclk = (14318 * mclk) >> 3;
  415. dev_dbg(info->device, "Read MCLK of %ld kHz\n", mclk);
  416. /* Determine if we should use MCLK instead of VCLK, and if so, what we
  417. * should divide it by to get VCLK
  418. */
  419. if (abs(freq - mclk) < 250) {
  420. dev_dbg(info->device, "Using VCLK = MCLK\n");
  421. return 1;
  422. } else if (abs(freq - (mclk / 2)) < 250) {
  423. dev_dbg(info->device, "Using VCLK = MCLK/2\n");
  424. return 2;
  425. }
  426. return 0;
  427. }
  428. static int cirrusfb_check_pixclock(const struct fb_var_screeninfo *var,
  429. struct fb_info *info)
  430. {
  431. long freq;
  432. long maxclock;
  433. struct cirrusfb_info *cinfo = info->par;
  434. unsigned maxclockidx = var->bits_per_pixel >> 3;
  435. /* convert from ps to kHz */
  436. freq = PICOS2KHZ(var->pixclock);
  437. dev_dbg(info->device, "desired pixclock: %ld kHz\n", freq);
  438. maxclock = cirrusfb_board_info[cinfo->btype].maxclock[maxclockidx];
  439. cinfo->multiplexing = 0;
  440. /* If the frequency is greater than we can support, we might be able
  441. * to use multiplexing for the video mode */
  442. if (freq > maxclock) {
  443. dev_err(info->device,
  444. "Frequency greater than maxclock (%ld kHz)\n",
  445. maxclock);
  446. return -EINVAL;
  447. }
  448. /*
  449. * Additional constraint: 8bpp uses DAC clock doubling to allow maximum
  450. * pixel clock
  451. */
  452. if (var->bits_per_pixel == 8) {
  453. switch (cinfo->btype) {
  454. case BT_ALPINE:
  455. case BT_SD64:
  456. case BT_PICASSO4:
  457. if (freq > 85500)
  458. cinfo->multiplexing = 1;
  459. break;
  460. case BT_GD5480:
  461. if (freq > 135100)
  462. cinfo->multiplexing = 1;
  463. break;
  464. default:
  465. break;
  466. }
  467. }
  468. /* If we have a 1MB 5434, we need to put ourselves in a mode where
  469. * the VCLK is double the pixel clock. */
  470. cinfo->doubleVCLK = 0;
  471. if (cinfo->btype == BT_SD64 && info->fix.smem_len <= MB_ &&
  472. var->bits_per_pixel == 16) {
  473. cinfo->doubleVCLK = 1;
  474. }
  475. return 0;
  476. }
  477. static int cirrusfb_check_var(struct fb_var_screeninfo *var,
  478. struct fb_info *info)
  479. {
  480. int yres;
  481. /* memory size in pixels */
  482. unsigned pixels = info->screen_size * 8 / var->bits_per_pixel;
  483. struct cirrusfb_info *cinfo = info->par;
  484. switch (var->bits_per_pixel) {
  485. case 1:
  486. var->red.offset = 0;
  487. var->red.length = 1;
  488. var->green = var->red;
  489. var->blue = var->red;
  490. break;
  491. case 8:
  492. var->red.offset = 0;
  493. var->red.length = 8;
  494. var->green = var->red;
  495. var->blue = var->red;
  496. break;
  497. case 16:
  498. var->red.offset = 11;
  499. var->green.offset = 5;
  500. var->blue.offset = 0;
  501. var->red.length = 5;
  502. var->green.length = 6;
  503. var->blue.length = 5;
  504. break;
  505. case 24:
  506. var->red.offset = 16;
  507. var->green.offset = 8;
  508. var->blue.offset = 0;
  509. var->red.length = 8;
  510. var->green.length = 8;
  511. var->blue.length = 8;
  512. break;
  513. default:
  514. dev_dbg(info->device,
  515. "Unsupported bpp size: %d\n", var->bits_per_pixel);
  516. return -EINVAL;
  517. }
  518. if (var->xres_virtual < var->xres)
  519. var->xres_virtual = var->xres;
  520. /* use highest possible virtual resolution */
  521. if (var->yres_virtual == -1) {
  522. var->yres_virtual = pixels / var->xres_virtual;
  523. dev_info(info->device,
  524. "virtual resolution set to maximum of %dx%d\n",
  525. var->xres_virtual, var->yres_virtual);
  526. }
  527. if (var->yres_virtual < var->yres)
  528. var->yres_virtual = var->yres;
  529. if (var->xres_virtual * var->yres_virtual > pixels) {
  530. dev_err(info->device, "mode %dx%dx%d rejected... "
  531. "virtual resolution too high to fit into video memory!\n",
  532. var->xres_virtual, var->yres_virtual,
  533. var->bits_per_pixel);
  534. return -EINVAL;
  535. }
  536. /* truncate xoffset and yoffset to maximum if too high */
  537. if (var->xoffset > var->xres_virtual - var->xres)
  538. var->xoffset = var->xres_virtual - var->xres - 1;
  539. if (var->yoffset > var->yres_virtual - var->yres)
  540. var->yoffset = var->yres_virtual - var->yres - 1;
  541. var->red.msb_right =
  542. var->green.msb_right =
  543. var->blue.msb_right =
  544. var->transp.offset =
  545. var->transp.length =
  546. var->transp.msb_right = 0;
  547. yres = var->yres;
  548. if (var->vmode & FB_VMODE_DOUBLE)
  549. yres *= 2;
  550. else if (var->vmode & FB_VMODE_INTERLACED)
  551. yres = (yres + 1) / 2;
  552. if (yres >= 1280) {
  553. dev_err(info->device, "ERROR: VerticalTotal >= 1280; "
  554. "special treatment required! (TODO)\n");
  555. return -EINVAL;
  556. }
  557. if (cirrusfb_check_pixclock(var, info))
  558. return -EINVAL;
  559. if (!is_laguna(cinfo))
  560. var->accel_flags = FB_ACCELF_TEXT;
  561. return 0;
  562. }
  563. static void cirrusfb_set_mclk_as_source(const struct fb_info *info, int div)
  564. {
  565. struct cirrusfb_info *cinfo = info->par;
  566. unsigned char old1f, old1e;
  567. assert(cinfo != NULL);
  568. old1f = vga_rseq(cinfo->regbase, CL_SEQR1F) & ~0x40;
  569. if (div) {
  570. dev_dbg(info->device, "Set %s as pixclock source.\n",
  571. (div == 2) ? "MCLK/2" : "MCLK");
  572. old1f |= 0x40;
  573. old1e = vga_rseq(cinfo->regbase, CL_SEQR1E) & ~0x1;
  574. if (div == 2)
  575. old1e |= 1;
  576. vga_wseq(cinfo->regbase, CL_SEQR1E, old1e);
  577. }
  578. vga_wseq(cinfo->regbase, CL_SEQR1F, old1f);
  579. }
  580. /*************************************************************************
  581. cirrusfb_set_par_foo()
  582. actually writes the values for a new video mode into the hardware,
  583. **************************************************************************/
  584. static int cirrusfb_set_par_foo(struct fb_info *info)
  585. {
  586. struct cirrusfb_info *cinfo = info->par;
  587. struct fb_var_screeninfo *var = &info->var;
  588. u8 __iomem *regbase = cinfo->regbase;
  589. unsigned char tmp;
  590. int pitch;
  591. const struct cirrusfb_board_info_rec *bi;
  592. int hdispend, hsyncstart, hsyncend, htotal;
  593. int yres, vdispend, vsyncstart, vsyncend, vtotal;
  594. long freq;
  595. int nom, den, div;
  596. unsigned int control = 0, format = 0, threshold = 0;
  597. dev_dbg(info->device, "Requested mode: %dx%dx%d\n",
  598. var->xres, var->yres, var->bits_per_pixel);
  599. switch (var->bits_per_pixel) {
  600. case 1:
  601. info->fix.line_length = var->xres_virtual / 8;
  602. info->fix.visual = FB_VISUAL_MONO10;
  603. break;
  604. case 8:
  605. info->fix.line_length = var->xres_virtual;
  606. info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
  607. break;
  608. case 16:
  609. case 24:
  610. info->fix.line_length = var->xres_virtual *
  611. var->bits_per_pixel >> 3;
  612. info->fix.visual = FB_VISUAL_TRUECOLOR;
  613. break;
  614. }
  615. info->fix.type = FB_TYPE_PACKED_PIXELS;
  616. init_vgachip(info);
  617. bi = &cirrusfb_board_info[cinfo->btype];
  618. hsyncstart = var->xres + var->right_margin;
  619. hsyncend = hsyncstart + var->hsync_len;
  620. htotal = (hsyncend + var->left_margin) / 8;
  621. hdispend = var->xres / 8;
  622. hsyncstart = hsyncstart / 8;
  623. hsyncend = hsyncend / 8;
  624. vdispend = var->yres;
  625. vsyncstart = vdispend + var->lower_margin;
  626. vsyncend = vsyncstart + var->vsync_len;
  627. vtotal = vsyncend + var->upper_margin;
  628. if (var->vmode & FB_VMODE_DOUBLE) {
  629. vdispend *= 2;
  630. vsyncstart *= 2;
  631. vsyncend *= 2;
  632. vtotal *= 2;
  633. } else if (var->vmode & FB_VMODE_INTERLACED) {
  634. vdispend = (vdispend + 1) / 2;
  635. vsyncstart = (vsyncstart + 1) / 2;
  636. vsyncend = (vsyncend + 1) / 2;
  637. vtotal = (vtotal + 1) / 2;
  638. }
  639. yres = vdispend;
  640. if (yres >= 1024) {
  641. vtotal /= 2;
  642. vsyncstart /= 2;
  643. vsyncend /= 2;
  644. vdispend /= 2;
  645. }
  646. vdispend -= 1;
  647. vsyncstart -= 1;
  648. vsyncend -= 1;
  649. vtotal -= 2;
  650. if (cinfo->multiplexing) {
  651. htotal /= 2;
  652. hsyncstart /= 2;
  653. hsyncend /= 2;
  654. hdispend /= 2;
  655. }
  656. htotal -= 5;
  657. hdispend -= 1;
  658. hsyncstart += 1;
  659. hsyncend += 1;
  660. /* unlock register VGA_CRTC_H_TOTAL..CRT7 */
  661. vga_wcrt(regbase, VGA_CRTC_V_SYNC_END, 0x20); /* previously: 0x00) */
  662. /* if debugging is enabled, all parameters get output before writing */
  663. dev_dbg(info->device, "CRT0: %d\n", htotal);
  664. vga_wcrt(regbase, VGA_CRTC_H_TOTAL, htotal);
  665. dev_dbg(info->device, "CRT1: %d\n", hdispend);
  666. vga_wcrt(regbase, VGA_CRTC_H_DISP, hdispend);
  667. dev_dbg(info->device, "CRT2: %d\n", var->xres / 8);
  668. vga_wcrt(regbase, VGA_CRTC_H_BLANK_START, var->xres / 8);
  669. /* + 128: Compatible read */
  670. dev_dbg(info->device, "CRT3: 128+%d\n", (htotal + 5) % 32);
  671. vga_wcrt(regbase, VGA_CRTC_H_BLANK_END,
  672. 128 + ((htotal + 5) % 32));
  673. dev_dbg(info->device, "CRT4: %d\n", hsyncstart);
  674. vga_wcrt(regbase, VGA_CRTC_H_SYNC_START, hsyncstart);
  675. tmp = hsyncend % 32;
  676. if ((htotal + 5) & 32)
  677. tmp += 128;
  678. dev_dbg(info->device, "CRT5: %d\n", tmp);
  679. vga_wcrt(regbase, VGA_CRTC_H_SYNC_END, tmp);
  680. dev_dbg(info->device, "CRT6: %d\n", vtotal & 0xff);
  681. vga_wcrt(regbase, VGA_CRTC_V_TOTAL, vtotal & 0xff);
  682. tmp = 16; /* LineCompare bit #9 */
  683. if (vtotal & 256)
  684. tmp |= 1;
  685. if (vdispend & 256)
  686. tmp |= 2;
  687. if (vsyncstart & 256)
  688. tmp |= 4;
  689. if ((vdispend + 1) & 256)
  690. tmp |= 8;
  691. if (vtotal & 512)
  692. tmp |= 32;
  693. if (vdispend & 512)
  694. tmp |= 64;
  695. if (vsyncstart & 512)
  696. tmp |= 128;
  697. dev_dbg(info->device, "CRT7: %d\n", tmp);
  698. vga_wcrt(regbase, VGA_CRTC_OVERFLOW, tmp);
  699. tmp = 0x40; /* LineCompare bit #8 */
  700. if ((vdispend + 1) & 512)
  701. tmp |= 0x20;
  702. if (var->vmode & FB_VMODE_DOUBLE)
  703. tmp |= 0x80;
  704. dev_dbg(info->device, "CRT9: %d\n", tmp);
  705. vga_wcrt(regbase, VGA_CRTC_MAX_SCAN, tmp);
  706. dev_dbg(info->device, "CRT10: %d\n", vsyncstart & 0xff);
  707. vga_wcrt(regbase, VGA_CRTC_V_SYNC_START, vsyncstart & 0xff);
  708. dev_dbg(info->device, "CRT11: 64+32+%d\n", vsyncend % 16);
  709. vga_wcrt(regbase, VGA_CRTC_V_SYNC_END, vsyncend % 16 + 64 + 32);
  710. dev_dbg(info->device, "CRT12: %d\n", vdispend & 0xff);
  711. vga_wcrt(regbase, VGA_CRTC_V_DISP_END, vdispend & 0xff);
  712. dev_dbg(info->device, "CRT15: %d\n", (vdispend + 1) & 0xff);
  713. vga_wcrt(regbase, VGA_CRTC_V_BLANK_START, (vdispend + 1) & 0xff);
  714. dev_dbg(info->device, "CRT16: %d\n", vtotal & 0xff);
  715. vga_wcrt(regbase, VGA_CRTC_V_BLANK_END, vtotal & 0xff);
  716. dev_dbg(info->device, "CRT18: 0xff\n");
  717. vga_wcrt(regbase, VGA_CRTC_LINE_COMPARE, 0xff);
  718. tmp = 0;
  719. if (var->vmode & FB_VMODE_INTERLACED)
  720. tmp |= 1;
  721. if ((htotal + 5) & 64)
  722. tmp |= 16;
  723. if ((htotal + 5) & 128)
  724. tmp |= 32;
  725. if (vtotal & 256)
  726. tmp |= 64;
  727. if (vtotal & 512)
  728. tmp |= 128;
  729. dev_dbg(info->device, "CRT1a: %d\n", tmp);
  730. vga_wcrt(regbase, CL_CRT1A, tmp);
  731. freq = PICOS2KHZ(var->pixclock);
  732. if (var->bits_per_pixel == 24)
  733. if (cinfo->btype == BT_ALPINE || cinfo->btype == BT_SD64)
  734. freq *= 3;
  735. if (cinfo->multiplexing)
  736. freq /= 2;
  737. if (cinfo->doubleVCLK)
  738. freq *= 2;
  739. bestclock(freq, &nom, &den, &div);
  740. dev_dbg(info->device, "VCLK freq: %ld kHz nom: %d den: %d div: %d\n",
  741. freq, nom, den, div);
  742. /* set VCLK0 */
  743. /* hardware RefClock: 14.31818 MHz */
  744. /* formula: VClk = (OSC * N) / (D * (1+P)) */
  745. /* Example: VClk = (14.31818 * 91) / (23 * (1+1)) = 28.325 MHz */
  746. if (cinfo->btype == BT_ALPINE || cinfo->btype == BT_PICASSO4 ||
  747. cinfo->btype == BT_SD64) {
  748. /* if freq is close to mclk or mclk/2 select mclk
  749. * as clock source
  750. */
  751. int divMCLK = cirrusfb_check_mclk(info, freq);
  752. if (divMCLK)
  753. nom = 0;
  754. cirrusfb_set_mclk_as_source(info, divMCLK);
  755. }
  756. if (is_laguna(cinfo)) {
  757. long pcifc = fb_readl(cinfo->laguna_mmio + 0x3fc);
  758. unsigned char tile = fb_readb(cinfo->laguna_mmio + 0x407);
  759. unsigned short tile_control;
  760. if (cinfo->btype == BT_LAGUNAB) {
  761. tile_control = fb_readw(cinfo->laguna_mmio + 0x2c4);
  762. tile_control &= ~0x80;
  763. fb_writew(tile_control, cinfo->laguna_mmio + 0x2c4);
  764. }
  765. fb_writel(pcifc | 0x10000000l, cinfo->laguna_mmio + 0x3fc);
  766. fb_writeb(tile & 0x3f, cinfo->laguna_mmio + 0x407);
  767. control = fb_readw(cinfo->laguna_mmio + 0x402);
  768. threshold = fb_readw(cinfo->laguna_mmio + 0xea);
  769. control &= ~0x6800;
  770. format = 0;
  771. threshold &= 0xffc0 & 0x3fbf;
  772. }
  773. if (nom) {
  774. tmp = den << 1;
  775. if (div != 0)
  776. tmp |= 1;
  777. /* 6 bit denom; ONLY 5434!!! (bugged me 10 days) */
  778. if ((cinfo->btype == BT_SD64) ||
  779. (cinfo->btype == BT_ALPINE) ||
  780. (cinfo->btype == BT_GD5480))
  781. tmp |= 0x80;
  782. /* Laguna chipset has reversed clock registers */
  783. if (is_laguna(cinfo)) {
  784. vga_wseq(regbase, CL_SEQRE, tmp);
  785. vga_wseq(regbase, CL_SEQR1E, nom);
  786. } else {
  787. vga_wseq(regbase, CL_SEQRE, nom);
  788. vga_wseq(regbase, CL_SEQR1E, tmp);
  789. }
  790. }
  791. if (yres >= 1024)
  792. /* 1280x1024 */
  793. vga_wcrt(regbase, VGA_CRTC_MODE, 0xc7);
  794. else
  795. /* mode control: VGA_CRTC_START_HI enable, ROTATE(?), 16bit
  796. * address wrap, no compat. */
  797. vga_wcrt(regbase, VGA_CRTC_MODE, 0xc3);
  798. /* don't know if it would hurt to also program this if no interlaced */
  799. /* mode is used, but I feel better this way.. :-) */
  800. if (var->vmode & FB_VMODE_INTERLACED)
  801. vga_wcrt(regbase, VGA_CRTC_REGS, htotal / 2);
  802. else
  803. vga_wcrt(regbase, VGA_CRTC_REGS, 0x00); /* interlace control */
  804. /* adjust horizontal/vertical sync type (low/high), use VCLK3 */
  805. /* enable display memory & CRTC I/O address for color mode */
  806. tmp = 0x03 | 0xc;
  807. if (var->sync & FB_SYNC_HOR_HIGH_ACT)
  808. tmp |= 0x40;
  809. if (var->sync & FB_SYNC_VERT_HIGH_ACT)
  810. tmp |= 0x80;
  811. WGen(cinfo, VGA_MIS_W, tmp);
  812. /* text cursor on and start line */
  813. vga_wcrt(regbase, VGA_CRTC_CURSOR_START, 0);
  814. /* text cursor end line */
  815. vga_wcrt(regbase, VGA_CRTC_CURSOR_END, 31);
  816. /******************************************************
  817. *
  818. * 1 bpp
  819. *
  820. */
  821. /* programming for different color depths */
  822. if (var->bits_per_pixel == 1) {
  823. dev_dbg(info->device, "preparing for 1 bit deep display\n");
  824. vga_wgfx(regbase, VGA_GFX_MODE, 0); /* mode register */
  825. /* SR07 */
  826. switch (cinfo->btype) {
  827. case BT_SD64:
  828. case BT_PICCOLO:
  829. case BT_PICASSO:
  830. case BT_SPECTRUM:
  831. case BT_PICASSO4:
  832. case BT_ALPINE:
  833. case BT_GD5480:
  834. vga_wseq(regbase, CL_SEQR7,
  835. cinfo->multiplexing ?
  836. bi->sr07_1bpp_mux : bi->sr07_1bpp);
  837. break;
  838. case BT_LAGUNA:
  839. case BT_LAGUNAB:
  840. vga_wseq(regbase, CL_SEQR7,
  841. vga_rseq(regbase, CL_SEQR7) & ~0x01);
  842. break;
  843. default:
  844. dev_warn(info->device, "unknown Board\n");
  845. break;
  846. }
  847. /* Extended Sequencer Mode */
  848. switch (cinfo->btype) {
  849. case BT_PICCOLO:
  850. case BT_SPECTRUM:
  851. /* evtl d0 bei 1 bit? avoid FIFO underruns..? */
  852. vga_wseq(regbase, CL_SEQRF, 0xb0);
  853. break;
  854. case BT_PICASSO:
  855. /* ## vorher d0 avoid FIFO underruns..? */
  856. vga_wseq(regbase, CL_SEQRF, 0xd0);
  857. break;
  858. case BT_SD64:
  859. case BT_PICASSO4:
  860. case BT_ALPINE:
  861. case BT_GD5480:
  862. case BT_LAGUNA:
  863. case BT_LAGUNAB:
  864. /* do nothing */
  865. break;
  866. default:
  867. dev_warn(info->device, "unknown Board\n");
  868. break;
  869. }
  870. /* pixel mask: pass-through for first plane */
  871. WGen(cinfo, VGA_PEL_MSK, 0x01);
  872. if (cinfo->multiplexing)
  873. /* hidden dac reg: 1280x1024 */
  874. WHDR(cinfo, 0x4a);
  875. else
  876. /* hidden dac: nothing */
  877. WHDR(cinfo, 0);
  878. /* memory mode: odd/even, ext. memory */
  879. vga_wseq(regbase, VGA_SEQ_MEMORY_MODE, 0x06);
  880. /* plane mask: only write to first plane */
  881. vga_wseq(regbase, VGA_SEQ_PLANE_WRITE, 0x01);
  882. }
  883. /******************************************************
  884. *
  885. * 8 bpp
  886. *
  887. */
  888. else if (var->bits_per_pixel == 8) {
  889. dev_dbg(info->device, "preparing for 8 bit deep display\n");
  890. switch (cinfo->btype) {
  891. case BT_SD64:
  892. case BT_PICCOLO:
  893. case BT_PICASSO:
  894. case BT_SPECTRUM:
  895. case BT_PICASSO4:
  896. case BT_ALPINE:
  897. case BT_GD5480:
  898. vga_wseq(regbase, CL_SEQR7,
  899. cinfo->multiplexing ?
  900. bi->sr07_8bpp_mux : bi->sr07_8bpp);
  901. break;
  902. case BT_LAGUNA:
  903. case BT_LAGUNAB:
  904. vga_wseq(regbase, CL_SEQR7,
  905. vga_rseq(regbase, CL_SEQR7) | 0x01);
  906. threshold |= 0x10;
  907. break;
  908. default:
  909. dev_warn(info->device, "unknown Board\n");
  910. break;
  911. }
  912. switch (cinfo->btype) {
  913. case BT_PICCOLO:
  914. case BT_PICASSO:
  915. case BT_SPECTRUM:
  916. /* Fast Page-Mode writes */
  917. vga_wseq(regbase, CL_SEQRF, 0xb0);
  918. break;
  919. case BT_PICASSO4:
  920. #ifdef CONFIG_ZORRO
  921. /* ### INCOMPLETE!! */
  922. vga_wseq(regbase, CL_SEQRF, 0xb8);
  923. #endif
  924. case BT_ALPINE:
  925. case BT_SD64:
  926. case BT_GD5480:
  927. case BT_LAGUNA:
  928. case BT_LAGUNAB:
  929. /* do nothing */
  930. break;
  931. default:
  932. dev_warn(info->device, "unknown board\n");
  933. break;
  934. }
  935. /* mode register: 256 color mode */
  936. vga_wgfx(regbase, VGA_GFX_MODE, 64);
  937. if (cinfo->multiplexing)
  938. /* hidden dac reg: 1280x1024 */
  939. WHDR(cinfo, 0x4a);
  940. else
  941. /* hidden dac: nothing */
  942. WHDR(cinfo, 0);
  943. }
  944. /******************************************************
  945. *
  946. * 16 bpp
  947. *
  948. */
  949. else if (var->bits_per_pixel == 16) {
  950. dev_dbg(info->device, "preparing for 16 bit deep display\n");
  951. switch (cinfo->btype) {
  952. case BT_PICCOLO:
  953. case BT_SPECTRUM:
  954. vga_wseq(regbase, CL_SEQR7, 0x87);
  955. /* Fast Page-Mode writes */
  956. vga_wseq(regbase, CL_SEQRF, 0xb0);
  957. break;
  958. case BT_PICASSO:
  959. vga_wseq(regbase, CL_SEQR7, 0x27);
  960. /* Fast Page-Mode writes */
  961. vga_wseq(regbase, CL_SEQRF, 0xb0);
  962. break;
  963. case BT_SD64:
  964. case BT_PICASSO4:
  965. case BT_ALPINE:
  966. /* Extended Sequencer Mode: 256c col. mode */
  967. vga_wseq(regbase, CL_SEQR7,
  968. cinfo->doubleVCLK ? 0xa3 : 0xa7);
  969. break;
  970. case BT_GD5480:
  971. vga_wseq(regbase, CL_SEQR7, 0x17);
  972. /* We already set SRF and SR1F */
  973. break;
  974. case BT_LAGUNA:
  975. case BT_LAGUNAB:
  976. vga_wseq(regbase, CL_SEQR7,
  977. vga_rseq(regbase, CL_SEQR7) & ~0x01);
  978. control |= 0x2000;
  979. format |= 0x1400;
  980. threshold |= 0x10;
  981. break;
  982. default:
  983. dev_warn(info->device, "unknown Board\n");
  984. break;
  985. }
  986. /* mode register: 256 color mode */
  987. vga_wgfx(regbase, VGA_GFX_MODE, 64);
  988. #ifdef CONFIG_PCI
  989. WHDR(cinfo, cinfo->doubleVCLK ? 0xe1 : 0xc1);
  990. #elif defined(CONFIG_ZORRO)
  991. /* FIXME: CONFIG_PCI and CONFIG_ZORRO may be defined both */
  992. WHDR(cinfo, 0xa0); /* hidden dac reg: nothing special */
  993. #endif
  994. }
  995. /******************************************************
  996. *
  997. * 24 bpp
  998. *
  999. */
  1000. else if (var->bits_per_pixel == 24) {
  1001. dev_dbg(info->device, "preparing for 24 bit deep display\n");
  1002. switch (cinfo->btype) {
  1003. case BT_PICCOLO:
  1004. case BT_SPECTRUM:
  1005. vga_wseq(regbase, CL_SEQR7, 0x85);
  1006. /* Fast Page-Mode writes */
  1007. vga_wseq(regbase, CL_SEQRF, 0xb0);
  1008. break;
  1009. case BT_PICASSO:
  1010. vga_wseq(regbase, CL_SEQR7, 0x25);
  1011. /* Fast Page-Mode writes */
  1012. vga_wseq(regbase, CL_SEQRF, 0xb0);
  1013. break;
  1014. case BT_SD64:
  1015. case BT_PICASSO4:
  1016. case BT_ALPINE:
  1017. /* Extended Sequencer Mode: 256c col. mode */
  1018. vga_wseq(regbase, CL_SEQR7, 0xa5);
  1019. break;
  1020. case BT_GD5480:
  1021. vga_wseq(regbase, CL_SEQR7, 0x15);
  1022. /* We already set SRF and SR1F */
  1023. break;
  1024. case BT_LAGUNA:
  1025. case BT_LAGUNAB:
  1026. vga_wseq(regbase, CL_SEQR7,
  1027. vga_rseq(regbase, CL_SEQR7) & ~0x01);
  1028. control |= 0x4000;
  1029. format |= 0x2400;
  1030. threshold |= 0x20;
  1031. break;
  1032. default:
  1033. dev_warn(info->device, "unknown Board\n");
  1034. break;
  1035. }
  1036. /* mode register: 256 color mode */
  1037. vga_wgfx(regbase, VGA_GFX_MODE, 64);
  1038. /* hidden dac reg: 8-8-8 mode (24 or 32) */
  1039. WHDR(cinfo, 0xc5);
  1040. }
  1041. /******************************************************
  1042. *
  1043. * unknown/unsupported bpp
  1044. *
  1045. */
  1046. else
  1047. dev_err(info->device,
  1048. "What's this? requested color depth == %d.\n",
  1049. var->bits_per_pixel);
  1050. pitch = info->fix.line_length >> 3;
  1051. vga_wcrt(regbase, VGA_CRTC_OFFSET, pitch & 0xff);
  1052. tmp = 0x22;
  1053. if (pitch & 0x100)
  1054. tmp |= 0x10; /* offset overflow bit */
  1055. /* screen start addr #16-18, fastpagemode cycles */
  1056. vga_wcrt(regbase, CL_CRT1B, tmp);
  1057. /* screen start address bit 19 */
  1058. if (cirrusfb_board_info[cinfo->btype].scrn_start_bit19)
  1059. vga_wcrt(regbase, CL_CRT1D, (pitch >> 9) & 1);
  1060. if (is_laguna(cinfo)) {
  1061. tmp = 0;
  1062. if ((htotal + 5) & 256)
  1063. tmp |= 128;
  1064. if (hdispend & 256)
  1065. tmp |= 64;
  1066. if (hsyncstart & 256)
  1067. tmp |= 48;
  1068. if (vtotal & 1024)
  1069. tmp |= 8;
  1070. if (vdispend & 1024)
  1071. tmp |= 4;
  1072. if (vsyncstart & 1024)
  1073. tmp |= 3;
  1074. vga_wcrt(regbase, CL_CRT1E, tmp);
  1075. dev_dbg(info->device, "CRT1e: %d\n", tmp);
  1076. }
  1077. /* pixel panning */
  1078. vga_wattr(regbase, CL_AR33, 0);
  1079. /* [ EGS: SetOffset(); ] */
  1080. /* From SetOffset(): Turn on VideoEnable bit in Attribute controller */
  1081. AttrOn(cinfo);
  1082. if (is_laguna(cinfo)) {
  1083. /* no tiles */
  1084. fb_writew(control | 0x1000, cinfo->laguna_mmio + 0x402);
  1085. fb_writew(format, cinfo->laguna_mmio + 0xc0);
  1086. fb_writew(threshold, cinfo->laguna_mmio + 0xea);
  1087. }
  1088. /* finally, turn on everything - turn off "FullBandwidth" bit */
  1089. /* also, set "DotClock%2" bit where requested */
  1090. tmp = 0x01;
  1091. /*** FB_VMODE_CLOCK_HALVE in linux/fb.h not defined anymore ?
  1092. if (var->vmode & FB_VMODE_CLOCK_HALVE)
  1093. tmp |= 0x08;
  1094. */
  1095. vga_wseq(regbase, VGA_SEQ_CLOCK_MODE, tmp);
  1096. dev_dbg(info->device, "CL_SEQR1: %d\n", tmp);
  1097. #ifdef CIRRUSFB_DEBUG
  1098. cirrusfb_dbg_reg_dump(info, NULL);
  1099. #endif
  1100. return 0;
  1101. }
  1102. /* for some reason incomprehensible to me, cirrusfb requires that you write
  1103. * the registers twice for the settings to take..grr. -dte */
  1104. static int cirrusfb_set_par(struct fb_info *info)
  1105. {
  1106. cirrusfb_set_par_foo(info);
  1107. return cirrusfb_set_par_foo(info);
  1108. }
  1109. static int cirrusfb_setcolreg(unsigned regno, unsigned red, unsigned green,
  1110. unsigned blue, unsigned transp,
  1111. struct fb_info *info)
  1112. {
  1113. struct cirrusfb_info *cinfo = info->par;
  1114. if (regno > 255)
  1115. return -EINVAL;
  1116. if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
  1117. u32 v;
  1118. red >>= (16 - info->var.red.length);
  1119. green >>= (16 - info->var.green.length);
  1120. blue >>= (16 - info->var.blue.length);
  1121. if (regno >= 16)
  1122. return 1;
  1123. v = (red << info->var.red.offset) |
  1124. (green << info->var.green.offset) |
  1125. (blue << info->var.blue.offset);
  1126. cinfo->pseudo_palette[regno] = v;
  1127. return 0;
  1128. }
  1129. if (info->var.bits_per_pixel == 8)
  1130. WClut(cinfo, regno, red >> 10, green >> 10, blue >> 10);
  1131. return 0;
  1132. }
  1133. /*************************************************************************
  1134. cirrusfb_pan_display()
  1135. performs display panning - provided hardware permits this
  1136. **************************************************************************/
  1137. static int cirrusfb_pan_display(struct fb_var_screeninfo *var,
  1138. struct fb_info *info)
  1139. {
  1140. int xoffset;
  1141. unsigned long base;
  1142. unsigned char tmp, xpix;
  1143. struct cirrusfb_info *cinfo = info->par;
  1144. /* no range checks for xoffset and yoffset, */
  1145. /* as fb_pan_display has already done this */
  1146. if (var->vmode & FB_VMODE_YWRAP)
  1147. return -EINVAL;
  1148. xoffset = var->xoffset * info->var.bits_per_pixel / 8;
  1149. base = var->yoffset * info->fix.line_length + xoffset;
  1150. if (info->var.bits_per_pixel == 1) {
  1151. /* base is already correct */
  1152. xpix = (unsigned char) (var->xoffset % 8);
  1153. } else {
  1154. base /= 4;
  1155. xpix = (unsigned char) ((xoffset % 4) * 2);
  1156. }
  1157. if (!is_laguna(cinfo))
  1158. cirrusfb_WaitBLT(cinfo->regbase);
  1159. /* lower 8 + 8 bits of screen start address */
  1160. vga_wcrt(cinfo->regbase, VGA_CRTC_START_LO, base & 0xff);
  1161. vga_wcrt(cinfo->regbase, VGA_CRTC_START_HI, (base >> 8) & 0xff);
  1162. /* 0xf2 is %11110010, exclude tmp bits */
  1163. tmp = vga_rcrt(cinfo->regbase, CL_CRT1B) & 0xf2;
  1164. /* construct bits 16, 17 and 18 of screen start address */
  1165. if (base & 0x10000)
  1166. tmp |= 0x01;
  1167. if (base & 0x20000)
  1168. tmp |= 0x04;
  1169. if (base & 0x40000)
  1170. tmp |= 0x08;
  1171. vga_wcrt(cinfo->regbase, CL_CRT1B, tmp);
  1172. /* construct bit 19 of screen start address */
  1173. if (cirrusfb_board_info[cinfo->btype].scrn_start_bit19) {
  1174. tmp = vga_rcrt(cinfo->regbase, CL_CRT1D);
  1175. if (is_laguna(cinfo))
  1176. tmp = (tmp & ~0x18) | ((base >> 16) & 0x18);
  1177. else
  1178. tmp = (tmp & ~0x80) | ((base >> 12) & 0x80);
  1179. vga_wcrt(cinfo->regbase, CL_CRT1D, tmp);
  1180. }
  1181. /* write pixel panning value to AR33; this does not quite work in 8bpp
  1182. *
  1183. * ### Piccolo..? Will this work?
  1184. */
  1185. if (info->var.bits_per_pixel == 1)
  1186. vga_wattr(cinfo->regbase, CL_AR33, xpix);
  1187. return 0;
  1188. }
  1189. static int cirrusfb_blank(int blank_mode, struct fb_info *info)
  1190. {
  1191. /*
  1192. * Blank the screen if blank_mode != 0, else unblank. If blank == NULL
  1193. * then the caller blanks by setting the CLUT (Color Look Up Table)
  1194. * to all black. Return 0 if blanking succeeded, != 0 if un-/blanking
  1195. * failed due to e.g. a video mode which doesn't support it.
  1196. * Implements VESA suspend and powerdown modes on hardware that
  1197. * supports disabling hsync/vsync:
  1198. * blank_mode == 2: suspend vsync
  1199. * blank_mode == 3: suspend hsync
  1200. * blank_mode == 4: powerdown
  1201. */
  1202. unsigned char val;
  1203. struct cirrusfb_info *cinfo = info->par;
  1204. int current_mode = cinfo->blank_mode;
  1205. dev_dbg(info->device, "ENTER, blank mode = %d\n", blank_mode);
  1206. if (info->state != FBINFO_STATE_RUNNING ||
  1207. current_mode == blank_mode) {
  1208. dev_dbg(info->device, "EXIT, returning 0\n");
  1209. return 0;
  1210. }
  1211. /* Undo current */
  1212. if (current_mode == FB_BLANK_NORMAL ||
  1213. current_mode == FB_BLANK_UNBLANK)
  1214. /* clear "FullBandwidth" bit */
  1215. val = 0;
  1216. else
  1217. /* set "FullBandwidth" bit */
  1218. val = 0x20;
  1219. val |= vga_rseq(cinfo->regbase, VGA_SEQ_CLOCK_MODE) & 0xdf;
  1220. vga_wseq(cinfo->regbase, VGA_SEQ_CLOCK_MODE, val);
  1221. switch (blank_mode) {
  1222. case FB_BLANK_UNBLANK:
  1223. case FB_BLANK_NORMAL:
  1224. val = 0x00;
  1225. break;
  1226. case FB_BLANK_VSYNC_SUSPEND:
  1227. val = 0x04;
  1228. break;
  1229. case FB_BLANK_HSYNC_SUSPEND:
  1230. val = 0x02;
  1231. break;
  1232. case FB_BLANK_POWERDOWN:
  1233. val = 0x06;
  1234. break;
  1235. default:
  1236. dev_dbg(info->device, "EXIT, returning 1\n");
  1237. return 1;
  1238. }
  1239. vga_wgfx(cinfo->regbase, CL_GRE, val);
  1240. cinfo->blank_mode = blank_mode;
  1241. dev_dbg(info->device, "EXIT, returning 0\n");
  1242. /* Let fbcon do a soft blank for us */
  1243. return (blank_mode == FB_BLANK_NORMAL) ? 1 : 0;
  1244. }
  1245. /**** END Hardware specific Routines **************************************/
  1246. /****************************************************************************/
  1247. /**** BEGIN Internal Routines ***********************************************/
  1248. static void init_vgachip(struct fb_info *info)
  1249. {
  1250. struct cirrusfb_info *cinfo = info->par;
  1251. const struct cirrusfb_board_info_rec *bi;
  1252. assert(cinfo != NULL);
  1253. bi = &cirrusfb_board_info[cinfo->btype];
  1254. /* reset board globally */
  1255. switch (cinfo->btype) {
  1256. case BT_PICCOLO:
  1257. WSFR(cinfo, 0x01);
  1258. udelay(500);
  1259. WSFR(cinfo, 0x51);
  1260. udelay(500);
  1261. break;
  1262. case BT_PICASSO:
  1263. WSFR2(cinfo, 0xff);
  1264. udelay(500);
  1265. break;
  1266. case BT_SD64:
  1267. case BT_SPECTRUM:
  1268. WSFR(cinfo, 0x1f);
  1269. udelay(500);
  1270. WSFR(cinfo, 0x4f);
  1271. udelay(500);
  1272. break;
  1273. case BT_PICASSO4:
  1274. /* disable flickerfixer */
  1275. vga_wcrt(cinfo->regbase, CL_CRT51, 0x00);
  1276. mdelay(100);
  1277. /* mode */
  1278. vga_wgfx(cinfo->regbase, CL_GR31, 0x00);
  1279. case BT_GD5480: /* fall through */
  1280. /* from Klaus' NetBSD driver: */
  1281. vga_wgfx(cinfo->regbase, CL_GR2F, 0x00);
  1282. case BT_ALPINE: /* fall through */
  1283. /* put blitter into 542x compat */
  1284. vga_wgfx(cinfo->regbase, CL_GR33, 0x00);
  1285. break;
  1286. case BT_LAGUNA:
  1287. case BT_LAGUNAB:
  1288. /* Nothing to do to reset the board. */
  1289. break;
  1290. default:
  1291. dev_err(info->device, "Warning: Unknown board type\n");
  1292. break;
  1293. }
  1294. /* make sure RAM size set by this point */
  1295. assert(info->screen_size > 0);
  1296. /* the P4 is not fully initialized here; I rely on it having been */
  1297. /* inited under AmigaOS already, which seems to work just fine */
  1298. /* (Klaus advised to do it this way) */
  1299. if (cinfo->btype != BT_PICASSO4) {
  1300. WGen(cinfo, CL_VSSM, 0x10); /* EGS: 0x16 */
  1301. WGen(cinfo, CL_POS102, 0x01);
  1302. WGen(cinfo, CL_VSSM, 0x08); /* EGS: 0x0e */
  1303. if (cinfo->btype != BT_SD64)
  1304. WGen(cinfo, CL_VSSM2, 0x01);
  1305. /* reset sequencer logic */
  1306. vga_wseq(cinfo->regbase, VGA_SEQ_RESET, 0x03);
  1307. /* FullBandwidth (video off) and 8/9 dot clock */
  1308. vga_wseq(cinfo->regbase, VGA_SEQ_CLOCK_MODE, 0x21);
  1309. /* "magic cookie" - doesn't make any sense to me.. */
  1310. /* vga_wgfx(cinfo->regbase, CL_GRA, 0xce); */
  1311. /* unlock all extension registers */
  1312. vga_wseq(cinfo->regbase, CL_SEQR6, 0x12);
  1313. switch (cinfo->btype) {
  1314. case BT_GD5480:
  1315. vga_wseq(cinfo->regbase, CL_SEQRF, 0x98);
  1316. break;
  1317. case BT_ALPINE:
  1318. case BT_LAGUNA:
  1319. case BT_LAGUNAB:
  1320. break;
  1321. case BT_SD64:
  1322. #ifdef CONFIG_ZORRO
  1323. vga_wseq(cinfo->regbase, CL_SEQRF, 0xb8);
  1324. #endif
  1325. break;
  1326. default:
  1327. vga_wseq(cinfo->regbase, CL_SEQR16, 0x0f);
  1328. vga_wseq(cinfo->regbase, CL_SEQRF, 0xb0);
  1329. break;
  1330. }
  1331. }
  1332. /* plane mask: nothing */
  1333. vga_wseq(cinfo->regbase, VGA_SEQ_PLANE_WRITE, 0xff);
  1334. /* character map select: doesn't even matter in gx mode */
  1335. vga_wseq(cinfo->regbase, VGA_SEQ_CHARACTER_MAP, 0x00);
  1336. /* memory mode: chain4, ext. memory */
  1337. vga_wseq(cinfo->regbase, VGA_SEQ_MEMORY_MODE, 0x0a);
  1338. /* controller-internal base address of video memory */
  1339. if (bi->init_sr07)
  1340. vga_wseq(cinfo->regbase, CL_SEQR7, bi->sr07);
  1341. /* vga_wseq(cinfo->regbase, CL_SEQR8, 0x00); */
  1342. /* EEPROM control: shouldn't be necessary to write to this at all.. */
  1343. /* graphics cursor X position (incomplete; position gives rem. 3 bits */
  1344. vga_wseq(cinfo->regbase, CL_SEQR10, 0x00);
  1345. /* graphics cursor Y position (..."... ) */
  1346. vga_wseq(cinfo->regbase, CL_SEQR11, 0x00);
  1347. /* graphics cursor attributes */
  1348. vga_wseq(cinfo->regbase, CL_SEQR12, 0x00);
  1349. /* graphics cursor pattern address */
  1350. vga_wseq(cinfo->regbase, CL_SEQR13, 0x00);
  1351. /* writing these on a P4 might give problems.. */
  1352. if (cinfo->btype != BT_PICASSO4) {
  1353. /* configuration readback and ext. color */
  1354. vga_wseq(cinfo->regbase, CL_SEQR17, 0x00);
  1355. /* signature generator */
  1356. vga_wseq(cinfo->regbase, CL_SEQR18, 0x02);
  1357. }
  1358. /* Screen A preset row scan: none */
  1359. vga_wcrt(cinfo->regbase, VGA_CRTC_PRESET_ROW, 0x00);
  1360. /* Text cursor start: disable text cursor */
  1361. vga_wcrt(cinfo->regbase, VGA_CRTC_CURSOR_START, 0x20);
  1362. /* Text cursor end: - */
  1363. vga_wcrt(cinfo->regbase, VGA_CRTC_CURSOR_END, 0x00);
  1364. /* text cursor location high: 0 */
  1365. vga_wcrt(cinfo->regbase, VGA_CRTC_CURSOR_HI, 0x00);
  1366. /* text cursor location low: 0 */
  1367. vga_wcrt(cinfo->regbase, VGA_CRTC_CURSOR_LO, 0x00);
  1368. /* Underline Row scanline: - */
  1369. vga_wcrt(cinfo->regbase, VGA_CRTC_UNDERLINE, 0x00);
  1370. /* ### add 0x40 for text modes with > 30 MHz pixclock */
  1371. /* ext. display controls: ext.adr. wrap */
  1372. vga_wcrt(cinfo->regbase, CL_CRT1B, 0x02);
  1373. /* Set/Reset registers: - */
  1374. vga_wgfx(cinfo->regbase, VGA_GFX_SR_VALUE, 0x00);
  1375. /* Set/Reset enable: - */
  1376. vga_wgfx(cinfo->regbase, VGA_GFX_SR_ENABLE, 0x00);
  1377. /* Color Compare: - */
  1378. vga_wgfx(cinfo->regbase, VGA_GFX_COMPARE_VALUE, 0x00);
  1379. /* Data Rotate: - */
  1380. vga_wgfx(cinfo->regbase, VGA_GFX_DATA_ROTATE, 0x00);
  1381. /* Read Map Select: - */
  1382. vga_wgfx(cinfo->regbase, VGA_GFX_PLANE_READ, 0x00);
  1383. /* Mode: conf. for 16/4/2 color mode, no odd/even, read/write mode 0 */
  1384. vga_wgfx(cinfo->regbase, VGA_GFX_MODE, 0x00);
  1385. /* Miscellaneous: memory map base address, graphics mode */
  1386. vga_wgfx(cinfo->regbase, VGA_GFX_MISC, 0x01);
  1387. /* Color Don't care: involve all planes */
  1388. vga_wgfx(cinfo->regbase, VGA_GFX_COMPARE_MASK, 0x0f);
  1389. /* Bit Mask: no mask at all */
  1390. vga_wgfx(cinfo->regbase, VGA_GFX_BIT_MASK, 0xff);
  1391. if (cinfo->btype == BT_ALPINE || cinfo->btype == BT_SD64 ||
  1392. is_laguna(cinfo))
  1393. /* (5434 can't have bit 3 set for bitblt) */
  1394. vga_wgfx(cinfo->regbase, CL_GRB, 0x20);
  1395. else
  1396. /* Graphics controller mode extensions: finer granularity,
  1397. * 8byte data latches
  1398. */
  1399. vga_wgfx(cinfo->regbase, CL_GRB, 0x28);
  1400. vga_wgfx(cinfo->regbase, CL_GRC, 0xff); /* Color Key compare: - */
  1401. vga_wgfx(cinfo->regbase, CL_GRD, 0x00); /* Color Key compare mask: - */
  1402. vga_wgfx(cinfo->regbase, CL_GRE, 0x00); /* Miscellaneous control: - */
  1403. /* Background color byte 1: - */
  1404. /* vga_wgfx (cinfo->regbase, CL_GR10, 0x00); */
  1405. /* vga_wgfx (cinfo->regbase, CL_GR11, 0x00); */
  1406. /* Attribute Controller palette registers: "identity mapping" */
  1407. vga_wattr(cinfo->regbase, VGA_ATC_PALETTE0, 0x00);
  1408. vga_wattr(cinfo->regbase, VGA_ATC_PALETTE1, 0x01);
  1409. vga_wattr(cinfo->regbase, VGA_ATC_PALETTE2, 0x02);
  1410. vga_wattr(cinfo->regbase, VGA_ATC_PALETTE3, 0x03);
  1411. vga_wattr(cinfo->regbase, VGA_ATC_PALETTE4, 0x04);
  1412. vga_wattr(cinfo->regbase, VGA_ATC_PALETTE5, 0x05);
  1413. vga_wattr(cinfo->regbase, VGA_ATC_PALETTE6, 0x06);
  1414. vga_wattr(cinfo->regbase, VGA_ATC_PALETTE7, 0x07);
  1415. vga_wattr(cinfo->regbase, VGA_ATC_PALETTE8, 0x08);
  1416. vga_wattr(cinfo->regbase, VGA_ATC_PALETTE9, 0x09);
  1417. vga_wattr(cinfo->regbase, VGA_ATC_PALETTEA, 0x0a);
  1418. vga_wattr(cinfo->regbase, VGA_ATC_PALETTEB, 0x0b);
  1419. vga_wattr(cinfo->regbase, VGA_ATC_PALETTEC, 0x0c);
  1420. vga_wattr(cinfo->regbase, VGA_ATC_PALETTED, 0x0d);
  1421. vga_wattr(cinfo->regbase, VGA_ATC_PALETTEE, 0x0e);
  1422. vga_wattr(cinfo->regbase, VGA_ATC_PALETTEF, 0x0f);
  1423. /* Attribute Controller mode: graphics mode */
  1424. vga_wattr(cinfo->regbase, VGA_ATC_MODE, 0x01);
  1425. /* Overscan color reg.: reg. 0 */
  1426. vga_wattr(cinfo->regbase, VGA_ATC_OVERSCAN, 0x00);
  1427. /* Color Plane enable: Enable all 4 planes */
  1428. vga_wattr(cinfo->regbase, VGA_ATC_PLANE_ENABLE, 0x0f);
  1429. /* Color Select: - */
  1430. vga_wattr(cinfo->regbase, VGA_ATC_COLOR_PAGE, 0x00);
  1431. WGen(cinfo, VGA_PEL_MSK, 0xff); /* Pixel mask: no mask */
  1432. /* BLT Start/status: Blitter reset */
  1433. vga_wgfx(cinfo->regbase, CL_GR31, 0x04);
  1434. /* - " - : "end-of-reset" */
  1435. vga_wgfx(cinfo->regbase, CL_GR31, 0x00);
  1436. /* misc... */
  1437. WHDR(cinfo, 0); /* Hidden DAC register: - */
  1438. return;
  1439. }
  1440. static void switch_monitor(struct cirrusfb_info *cinfo, int on)
  1441. {
  1442. #ifdef CONFIG_ZORRO /* only works on Zorro boards */
  1443. static int IsOn = 0; /* XXX not ok for multiple boards */
  1444. if (cinfo->btype == BT_PICASSO4)
  1445. return; /* nothing to switch */
  1446. if (cinfo->btype == BT_ALPINE)
  1447. return; /* nothing to switch */
  1448. if (cinfo->btype == BT_GD5480)
  1449. return; /* nothing to switch */
  1450. if (cinfo->btype == BT_PICASSO) {
  1451. if ((on && !IsOn) || (!on && IsOn))
  1452. WSFR(cinfo, 0xff);
  1453. return;
  1454. }
  1455. if (on) {
  1456. switch (cinfo->btype) {
  1457. case BT_SD64:
  1458. WSFR(cinfo, cinfo->SFR | 0x21);
  1459. break;
  1460. case BT_PICCOLO:
  1461. WSFR(cinfo, cinfo->SFR | 0x28);
  1462. break;
  1463. case BT_SPECTRUM:
  1464. WSFR(cinfo, 0x6f);
  1465. break;
  1466. default: /* do nothing */ break;
  1467. }
  1468. } else {
  1469. switch (cinfo->btype) {
  1470. case BT_SD64:
  1471. WSFR(cinfo, cinfo->SFR & 0xde);
  1472. break;
  1473. case BT_PICCOLO:
  1474. WSFR(cinfo, cinfo->SFR & 0xd7);
  1475. break;
  1476. case BT_SPECTRUM:
  1477. WSFR(cinfo, 0x4f);
  1478. break;
  1479. default: /* do nothing */
  1480. break;
  1481. }
  1482. }
  1483. #endif /* CONFIG_ZORRO */
  1484. }
  1485. /******************************************/
  1486. /* Linux 2.6-style accelerated functions */
  1487. /******************************************/
  1488. static int cirrusfb_sync(struct fb_info *info)
  1489. {
  1490. struct cirrusfb_info *cinfo = info->par;
  1491. if (!is_laguna(cinfo)) {
  1492. while (vga_rgfx(cinfo->regbase, CL_GR31) & 0x03)
  1493. cpu_relax();
  1494. }
  1495. return 0;
  1496. }
  1497. static void cirrusfb_fillrect(struct fb_info *info,
  1498. const struct fb_fillrect *region)
  1499. {
  1500. struct fb_fillrect modded;
  1501. int vxres, vyres;
  1502. struct cirrusfb_info *cinfo = info->par;
  1503. int m = info->var.bits_per_pixel;
  1504. u32 color = (info->fix.visual == FB_VISUAL_TRUECOLOR) ?
  1505. cinfo->pseudo_palette[region->color] : region->color;
  1506. if (info->state != FBINFO_STATE_RUNNING)
  1507. return;
  1508. if (info->flags & FBINFO_HWACCEL_DISABLED) {
  1509. cfb_fillrect(info, region);
  1510. return;
  1511. }
  1512. vxres = info->var.xres_virtual;
  1513. vyres = info->var.yres_virtual;
  1514. memcpy(&modded, region, sizeof(struct fb_fillrect));
  1515. if (!modded.width || !modded.height ||
  1516. modded.dx >= vxres || modded.dy >= vyres)
  1517. return;
  1518. if (modded.dx + modded.width > vxres)
  1519. modded.width = vxres - modded.dx;
  1520. if (modded.dy + modded.height > vyres)
  1521. modded.height = vyres - modded.dy;
  1522. cirrusfb_RectFill(cinfo->regbase,
  1523. info->var.bits_per_pixel,
  1524. (region->dx * m) / 8, region->dy,
  1525. (region->width * m) / 8, region->height,
  1526. color, color,
  1527. info->fix.line_length, 0x40);
  1528. }
  1529. static void cirrusfb_copyarea(struct fb_info *info,
  1530. const struct fb_copyarea *area)
  1531. {
  1532. struct fb_copyarea modded;
  1533. u32 vxres, vyres;
  1534. struct cirrusfb_info *cinfo = info->par;
  1535. int m = info->var.bits_per_pixel;
  1536. if (info->state != FBINFO_STATE_RUNNING)
  1537. return;
  1538. if (info->flags & FBINFO_HWACCEL_DISABLED) {
  1539. cfb_copyarea(info, area);
  1540. return;
  1541. }
  1542. vxres = info->var.xres_virtual;
  1543. vyres = info->var.yres_virtual;
  1544. memcpy(&modded, area, sizeof(struct fb_copyarea));
  1545. if (!modded.width || !modded.height ||
  1546. modded.sx >= vxres || modded.sy >= vyres ||
  1547. modded.dx >= vxres || modded.dy >= vyres)
  1548. return;
  1549. if (modded.sx + modded.width > vxres)
  1550. modded.width = vxres - modded.sx;
  1551. if (modded.dx + modded.width > vxres)
  1552. modded.width = vxres - modded.dx;
  1553. if (modded.sy + modded.height > vyres)
  1554. modded.height = vyres - modded.sy;
  1555. if (modded.dy + modded.height > vyres)
  1556. modded.height = vyres - modded.dy;
  1557. cirrusfb_BitBLT(cinfo->regbase, info->var.bits_per_pixel,
  1558. (area->sx * m) / 8, area->sy,
  1559. (area->dx * m) / 8, area->dy,
  1560. (area->width * m) / 8, area->height,
  1561. info->fix.line_length);
  1562. }
  1563. static void cirrusfb_imageblit(struct fb_info *info,
  1564. const struct fb_image *image)
  1565. {
  1566. struct cirrusfb_info *cinfo = info->par;
  1567. unsigned char op = (info->var.bits_per_pixel == 24) ? 0xc : 0x4;
  1568. if (info->state != FBINFO_STATE_RUNNING)
  1569. return;
  1570. /* Alpine/SD64 does not work at 24bpp ??? */
  1571. if (info->flags & FBINFO_HWACCEL_DISABLED || image->depth != 1)
  1572. cfb_imageblit(info, image);
  1573. else if ((cinfo->btype == BT_ALPINE || cinfo->btype == BT_SD64) &&
  1574. op == 0xc)
  1575. cfb_imageblit(info, image);
  1576. else {
  1577. unsigned size = ((image->width + 7) >> 3) * image->height;
  1578. int m = info->var.bits_per_pixel;
  1579. u32 fg, bg;
  1580. if (info->var.bits_per_pixel == 8) {
  1581. fg = image->fg_color;
  1582. bg = image->bg_color;
  1583. } else {
  1584. fg = ((u32 *)(info->pseudo_palette))[image->fg_color];
  1585. bg = ((u32 *)(info->pseudo_palette))[image->bg_color];
  1586. }
  1587. if (info->var.bits_per_pixel == 24) {
  1588. /* clear background first */
  1589. cirrusfb_RectFill(cinfo->regbase,
  1590. info->var.bits_per_pixel,
  1591. (image->dx * m) / 8, image->dy,
  1592. (image->width * m) / 8,
  1593. image->height,
  1594. bg, bg,
  1595. info->fix.line_length, 0x40);
  1596. }
  1597. cirrusfb_RectFill(cinfo->regbase,
  1598. info->var.bits_per_pixel,
  1599. (image->dx * m) / 8, image->dy,
  1600. (image->width * m) / 8, image->height,
  1601. fg, bg,
  1602. info->fix.line_length, op);
  1603. memcpy(info->screen_base, image->data, size);
  1604. }
  1605. }
  1606. #ifdef CONFIG_PCI
  1607. static int release_io_ports;
  1608. /* Pulled the logic from XFree86 Cirrus driver to get the memory size,
  1609. * based on the DRAM bandwidth bit and DRAM bank switching bit. This
  1610. * works with 1MB, 2MB and 4MB configurations (which the Motorola boards
  1611. * seem to have. */
  1612. static unsigned int cirrusfb_get_memsize(struct fb_info *info,
  1613. u8 __iomem *regbase)
  1614. {
  1615. unsigned long mem;
  1616. struct cirrusfb_info *cinfo = info->par;
  1617. if (is_laguna(cinfo)) {
  1618. unsigned char SR14 = vga_rseq(regbase, CL_SEQR14);
  1619. mem = ((SR14 & 7) + 1) << 20;
  1620. } else {
  1621. unsigned char SRF = vga_rseq(regbase, CL_SEQRF);
  1622. switch ((SRF & 0x18)) {
  1623. case 0x08:
  1624. mem = 512 * 1024;
  1625. break;
  1626. case 0x10:
  1627. mem = 1024 * 1024;
  1628. break;
  1629. /* 64-bit DRAM data bus width; assume 2MB.
  1630. * Also indicates 2MB memory on the 5430.
  1631. */
  1632. case 0x18:
  1633. mem = 2048 * 1024;
  1634. break;
  1635. default:
  1636. dev_warn(info->device, "Unknown memory size!\n");
  1637. mem = 1024 * 1024;
  1638. }
  1639. /* If DRAM bank switching is enabled, there must be
  1640. * twice as much memory installed. (4MB on the 5434)
  1641. */
  1642. if (cinfo->btype != BT_ALPINE && (SRF & 0x80) != 0)
  1643. mem *= 2;
  1644. }
  1645. /* TODO: Handling of GD5446/5480 (see XF86 sources ...) */
  1646. return mem;
  1647. }
  1648. static void get_pci_addrs(const struct pci_dev *pdev,
  1649. unsigned long *display, unsigned long *registers)
  1650. {
  1651. assert(pdev != NULL);
  1652. assert(display != NULL);
  1653. assert(registers != NULL);
  1654. *display = 0;
  1655. *registers = 0;
  1656. /* This is a best-guess for now */
  1657. if (pci_resource_flags(pdev, 0) & IORESOURCE_IO) {
  1658. *display = pci_resource_start(pdev, 1);
  1659. *registers = pci_resource_start(pdev, 0);
  1660. } else {
  1661. *display = pci_resource_start(pdev, 0);
  1662. *registers = pci_resource_start(pdev, 1);
  1663. }
  1664. assert(*display != 0);
  1665. }
  1666. static void cirrusfb_pci_unmap(struct fb_info *info)
  1667. {
  1668. struct pci_dev *pdev = to_pci_dev(info->device);
  1669. struct cirrusfb_info *cinfo = info->par;
  1670. if (cinfo->laguna_mmio == NULL)
  1671. iounmap(cinfo->laguna_mmio);
  1672. iounmap(info->screen_base);
  1673. #if 0 /* if system didn't claim this region, we would... */
  1674. release_mem_region(0xA0000, 65535);
  1675. #endif
  1676. if (release_io_ports)
  1677. release_region(0x3C0, 32);
  1678. pci_release_regions(pdev);
  1679. }
  1680. #endif /* CONFIG_PCI */
  1681. #ifdef CONFIG_ZORRO
  1682. static void cirrusfb_zorro_unmap(struct fb_info *info)
  1683. {
  1684. struct cirrusfb_info *cinfo = info->par;
  1685. struct zorro_dev *zdev = to_zorro_dev(info->device);
  1686. if (info->fix.smem_start > 16 * MB_)
  1687. iounmap(info->screen_base);
  1688. if (info->fix.mmio_start > 16 * MB_)
  1689. iounmap(cinfo->regbase);
  1690. zorro_release_device(zdev);
  1691. }
  1692. #endif /* CONFIG_ZORRO */
  1693. /* function table of the above functions */
  1694. static struct fb_ops cirrusfb_ops = {
  1695. .owner = THIS_MODULE,
  1696. .fb_open = cirrusfb_open,
  1697. .fb_release = cirrusfb_release,
  1698. .fb_setcolreg = cirrusfb_setcolreg,
  1699. .fb_check_var = cirrusfb_check_var,
  1700. .fb_set_par = cirrusfb_set_par,
  1701. .fb_pan_display = cirrusfb_pan_display,
  1702. .fb_blank = cirrusfb_blank,
  1703. .fb_fillrect = cirrusfb_fillrect,
  1704. .fb_copyarea = cirrusfb_copyarea,
  1705. .fb_sync = cirrusfb_sync,
  1706. .fb_imageblit = cirrusfb_imageblit,
  1707. };
  1708. static int cirrusfb_set_fbinfo(struct fb_info *info)
  1709. {
  1710. struct cirrusfb_info *cinfo = info->par;
  1711. struct fb_var_screeninfo *var = &info->var;
  1712. info->pseudo_palette = cinfo->pseudo_palette;
  1713. info->flags = FBINFO_DEFAULT
  1714. | FBINFO_HWACCEL_XPAN
  1715. | FBINFO_HWACCEL_YPAN
  1716. | FBINFO_HWACCEL_FILLRECT
  1717. | FBINFO_HWACCEL_IMAGEBLIT
  1718. | FBINFO_HWACCEL_COPYAREA;
  1719. if (noaccel || is_laguna(cinfo)) {
  1720. info->flags |= FBINFO_HWACCEL_DISABLED;
  1721. info->fix.accel = FB_ACCEL_NONE;
  1722. } else
  1723. info->fix.accel = FB_ACCEL_CIRRUS_ALPINE;
  1724. info->fbops = &cirrusfb_ops;
  1725. if (cinfo->btype == BT_GD5480) {
  1726. if (var->bits_per_pixel == 16)
  1727. info->screen_base += 1 * MB_;
  1728. if (var->bits_per_pixel == 32)
  1729. info->screen_base += 2 * MB_;
  1730. }
  1731. /* Fill fix common fields */
  1732. strlcpy(info->fix.id, cirrusfb_board_info[cinfo->btype].name,
  1733. sizeof(info->fix.id));
  1734. /* monochrome: only 1 memory plane */
  1735. /* 8 bit and above: Use whole memory area */
  1736. info->fix.smem_len = info->screen_size;
  1737. if (var->bits_per_pixel == 1)
  1738. info->fix.smem_len /= 4;
  1739. info->fix.type_aux = 0;
  1740. info->fix.xpanstep = 1;
  1741. info->fix.ypanstep = 1;
  1742. info->fix.ywrapstep = 0;
  1743. /* FIXME: map region at 0xB8000 if available, fill in here */
  1744. info->fix.mmio_len = 0;
  1745. fb_alloc_cmap(&info->cmap, 256, 0);
  1746. return 0;
  1747. }
  1748. static int cirrusfb_register(struct fb_info *info)
  1749. {
  1750. struct cirrusfb_info *cinfo = info->par;
  1751. int err;
  1752. /* sanity checks */
  1753. assert(cinfo->btype != BT_NONE);
  1754. /* set all the vital stuff */
  1755. cirrusfb_set_fbinfo(info);
  1756. dev_dbg(info->device, "(RAM start set to: 0x%p)\n", info->screen_base);
  1757. err = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 8);
  1758. if (!err) {
  1759. dev_dbg(info->device, "wrong initial video mode\n");
  1760. err = -EINVAL;
  1761. goto err_dealloc_cmap;
  1762. }
  1763. info->var.activate = FB_ACTIVATE_NOW;
  1764. err = cirrusfb_check_var(&info->var, info);
  1765. if (err < 0) {
  1766. /* should never happen */
  1767. dev_dbg(info->device,
  1768. "choking on default var... umm, no good.\n");
  1769. goto err_dealloc_cmap;
  1770. }
  1771. err = register_framebuffer(info);
  1772. if (err < 0) {
  1773. dev_err(info->device,
  1774. "could not register fb device; err = %d!\n", err);
  1775. goto err_dealloc_cmap;
  1776. }
  1777. return 0;
  1778. err_dealloc_cmap:
  1779. fb_dealloc_cmap(&info->cmap);
  1780. return err;
  1781. }
  1782. static void cirrusfb_cleanup(struct fb_info *info)
  1783. {
  1784. struct cirrusfb_info *cinfo = info->par;
  1785. switch_monitor(cinfo, 0);
  1786. unregister_framebuffer(info);
  1787. fb_dealloc_cmap(&info->cmap);
  1788. dev_dbg(info->device, "Framebuffer unregistered\n");
  1789. cinfo->unmap(info);
  1790. framebuffer_release(info);
  1791. }
  1792. #ifdef CONFIG_PCI
  1793. static int cirrusfb_pci_register(struct pci_dev *pdev,
  1794. const struct pci_device_id *ent)
  1795. {
  1796. struct cirrusfb_info *cinfo;
  1797. struct fb_info *info;
  1798. unsigned long board_addr, board_size;
  1799. int ret;
  1800. ret = pci_enable_device(pdev);
  1801. if (ret < 0) {
  1802. printk(KERN_ERR "cirrusfb: Cannot enable PCI device\n");
  1803. goto err_out;
  1804. }
  1805. info = framebuffer_alloc(sizeof(struct cirrusfb_info), &pdev->dev);
  1806. if (!info) {
  1807. printk(KERN_ERR "cirrusfb: could not allocate memory\n");
  1808. ret = -ENOMEM;
  1809. goto err_out;
  1810. }
  1811. cinfo = info->par;
  1812. cinfo->btype = (enum cirrus_board) ent->driver_data;
  1813. dev_dbg(info->device,
  1814. " Found PCI device, base address 0 is 0x%Lx, btype set to %d\n",
  1815. (unsigned long long)pdev->resource[0].start, cinfo->btype);
  1816. dev_dbg(info->device, " base address 1 is 0x%Lx\n",
  1817. (unsigned long long)pdev->resource[1].start);
  1818. dev_dbg(info->device,
  1819. "Attempt to get PCI info for Cirrus Graphics Card\n");
  1820. get_pci_addrs(pdev, &board_addr, &info->fix.mmio_start);
  1821. /* FIXME: this forces VGA. alternatives? */
  1822. cinfo->regbase = NULL;
  1823. cinfo->laguna_mmio = ioremap(info->fix.mmio_start, 0x1000);
  1824. dev_dbg(info->device, "Board address: 0x%lx, register address: 0x%lx\n",
  1825. board_addr, info->fix.mmio_start);
  1826. board_size = (cinfo->btype == BT_GD5480) ?
  1827. 32 * MB_ : cirrusfb_get_memsize(info, cinfo->regbase);
  1828. ret = pci_request_regions(pdev, "cirrusfb");
  1829. if (ret < 0) {
  1830. dev_err(info->device, "cannot reserve region 0x%lx, abort\n",
  1831. board_addr);
  1832. goto err_release_fb;
  1833. }
  1834. #if 0 /* if the system didn't claim this region, we would... */
  1835. if (!request_mem_region(0xA0000, 65535, "cirrusfb")) {
  1836. dev_err(info->device, "cannot reserve region 0x%lx, abort\n",
  1837. 0xA0000L);
  1838. ret = -EBUSY;
  1839. goto err_release_regions;
  1840. }
  1841. #endif
  1842. if (request_region(0x3C0, 32, "cirrusfb"))
  1843. release_io_ports = 1;
  1844. info->screen_base = ioremap(board_addr, board_size);
  1845. if (!info->screen_base) {
  1846. ret = -EIO;
  1847. goto err_release_legacy;
  1848. }
  1849. info->fix.smem_start = board_addr;
  1850. info->screen_size = board_size;
  1851. cinfo->unmap = cirrusfb_pci_unmap;
  1852. dev_info(info->device,
  1853. "Cirrus Logic chipset on PCI bus, RAM (%lu kB) at 0x%lx\n",
  1854. info->screen_size >> 10, board_addr);
  1855. pci_set_drvdata(pdev, info);
  1856. ret = cirrusfb_register(info);
  1857. if (!ret)
  1858. return 0;
  1859. iounmap(info->screen_base);
  1860. err_release_legacy:
  1861. if (release_io_ports)
  1862. release_region(0x3C0, 32);
  1863. #if 0
  1864. release_mem_region(0xA0000, 65535);
  1865. err_release_regions:
  1866. #endif
  1867. pci_release_regions(pdev);
  1868. err_release_fb:
  1869. if (cinfo->laguna_mmio != NULL)
  1870. iounmap(cinfo->laguna_mmio);
  1871. framebuffer_release(info);
  1872. err_out:
  1873. return ret;
  1874. }
  1875. static void cirrusfb_pci_unregister(struct pci_dev *pdev)
  1876. {
  1877. struct fb_info *info = pci_get_drvdata(pdev);
  1878. cirrusfb_cleanup(info);
  1879. }
  1880. static struct pci_driver cirrusfb_pci_driver = {
  1881. .name = "cirrusfb",
  1882. .id_table = cirrusfb_pci_table,
  1883. .probe = cirrusfb_pci_register,
  1884. .remove = cirrusfb_pci_unregister,
  1885. #ifdef CONFIG_PM
  1886. #if 0
  1887. .suspend = cirrusfb_pci_suspend,
  1888. .resume = cirrusfb_pci_resume,
  1889. #endif
  1890. #endif
  1891. };
  1892. #endif /* CONFIG_PCI */
  1893. #ifdef CONFIG_ZORRO
  1894. static int cirrusfb_zorro_register(struct zorro_dev *z,
  1895. const struct zorro_device_id *ent)
  1896. {
  1897. struct fb_info *info;
  1898. int error;
  1899. const struct zorrocl *zcl;
  1900. enum cirrus_board btype;
  1901. unsigned long regbase, ramsize, rambase;
  1902. struct cirrusfb_info *cinfo;
  1903. info = framebuffer_alloc(sizeof(struct cirrusfb_info), &z->dev);
  1904. if (!info) {
  1905. printk(KERN_ERR "cirrusfb: could not allocate memory\n");
  1906. return -ENOMEM;
  1907. }
  1908. zcl = (const struct zorrocl *)ent->driver_data;
  1909. btype = zcl->type;
  1910. regbase = zorro_resource_start(z) + zcl->regoffset;
  1911. ramsize = zcl->ramsize;
  1912. if (ramsize) {
  1913. rambase = zorro_resource_start(z) + zcl->ramoffset;
  1914. if (zorro_resource_len(z) == 64 * MB_) {
  1915. /* Quirk for 64 MiB Picasso IV */
  1916. rambase += zcl->ramoffset;
  1917. }
  1918. } else {
  1919. struct zorro_dev *ram = zorro_find_device(zcl->ramid, NULL);
  1920. if (!ram || !zorro_resource_len(ram)) {
  1921. dev_err(info->device, "No video RAM found\n");
  1922. error = -ENODEV;
  1923. goto err_release_fb;
  1924. }
  1925. rambase = zorro_resource_start(ram);
  1926. ramsize = zorro_resource_len(ram);
  1927. if (zcl->ramid2 &&
  1928. (ram = zorro_find_device(zcl->ramid2, NULL))) {
  1929. if (zorro_resource_start(ram) != rambase + ramsize) {
  1930. dev_warn(info->device,
  1931. "Skipping non-contiguous RAM at %pR\n",
  1932. &ram->resource);
  1933. } else {
  1934. ramsize += zorro_resource_len(ram);
  1935. }
  1936. }
  1937. }
  1938. dev_info(info->device,
  1939. "%s board detected, REG at 0x%lx, %lu MiB RAM at 0x%lx\n",
  1940. cirrusfb_board_info[btype].name, regbase, ramsize / MB_,
  1941. rambase);
  1942. if (!zorro_request_device(z, "cirrusfb")) {
  1943. dev_err(info->device, "Cannot reserve %pR\n", &z->resource);
  1944. error = -EBUSY;
  1945. goto err_release_fb;
  1946. }
  1947. cinfo = info->par;
  1948. cinfo->btype = btype;
  1949. info->fix.mmio_start = regbase;
  1950. cinfo->regbase = regbase > 16 * MB_ ? ioremap(regbase, 64 * 1024)
  1951. : ZTWO_VADDR(regbase);
  1952. if (!cinfo->regbase) {
  1953. dev_err(info->device, "Cannot map registers\n");
  1954. error = -EIO;
  1955. goto err_release_dev;
  1956. }
  1957. info->fix.smem_start = rambase;
  1958. info->screen_size = ramsize;
  1959. info->screen_base = rambase > 16 * MB_ ? ioremap(rambase, ramsize)
  1960. : ZTWO_VADDR(rambase);
  1961. if (!info->screen_base) {
  1962. dev_err(info->device, "Cannot map video RAM\n");
  1963. error = -EIO;
  1964. goto err_unmap_reg;
  1965. }
  1966. cinfo->unmap = cirrusfb_zorro_unmap;
  1967. dev_info(info->device,
  1968. "Cirrus Logic chipset on Zorro bus, RAM (%lu MiB) at 0x%lx\n",
  1969. ramsize / MB_, rambase);
  1970. /* MCLK select etc. */
  1971. if (cirrusfb_board_info[btype].init_sr1f)
  1972. vga_wseq(cinfo->regbase, CL_SEQR1F,
  1973. cirrusfb_board_info[btype].sr1f);
  1974. error = cirrusfb_register(info);
  1975. if (error) {
  1976. dev_err(info->device, "Failed to register device, error %d\n",
  1977. error);
  1978. goto err_unmap_ram;
  1979. }
  1980. zorro_set_drvdata(z, info);
  1981. return 0;
  1982. err_unmap_ram:
  1983. if (rambase > 16 * MB_)
  1984. iounmap(info->screen_base);
  1985. err_unmap_reg:
  1986. if (regbase > 16 * MB_)
  1987. iounmap(cinfo->regbase);
  1988. err_release_dev:
  1989. zorro_release_device(z);
  1990. err_release_fb:
  1991. framebuffer_release(info);
  1992. return error;
  1993. }
  1994. void cirrusfb_zorro_unregister(struct zorro_dev *z)
  1995. {
  1996. struct fb_info *info = zorro_get_drvdata(z);
  1997. cirrusfb_cleanup(info);
  1998. zorro_set_drvdata(z, NULL);
  1999. }
  2000. static struct zorro_driver cirrusfb_zorro_driver = {
  2001. .name = "cirrusfb",
  2002. .id_table = cirrusfb_zorro_table,
  2003. .probe = cirrusfb_zorro_register,
  2004. .remove = cirrusfb_zorro_unregister,
  2005. };
  2006. #endif /* CONFIG_ZORRO */
  2007. #ifndef MODULE
  2008. static int __init cirrusfb_setup(char *options)
  2009. {
  2010. char *this_opt;
  2011. if (!options || !*options)
  2012. return 0;
  2013. while ((this_opt = strsep(&options, ",")) != NULL) {
  2014. if (!*this_opt)
  2015. continue;
  2016. if (!strcmp(this_opt, "noaccel"))
  2017. noaccel = 1;
  2018. else if (!strncmp(this_opt, "mode:", 5))
  2019. mode_option = this_opt + 5;
  2020. else
  2021. mode_option = this_opt;
  2022. }
  2023. return 0;
  2024. }
  2025. #endif
  2026. /*
  2027. * Modularization
  2028. */
  2029. MODULE_AUTHOR("Copyright 1999,2000 Jeff Garzik <jgarzik@pobox.com>");
  2030. MODULE_DESCRIPTION("Accelerated FBDev driver for Cirrus Logic chips");
  2031. MODULE_LICENSE("GPL");
  2032. static int __init cirrusfb_init(void)
  2033. {
  2034. int error = 0;
  2035. #ifndef MODULE
  2036. char *option = NULL;
  2037. if (fb_get_options("cirrusfb", &option))
  2038. return -ENODEV;
  2039. cirrusfb_setup(option);
  2040. #endif
  2041. #ifdef CONFIG_ZORRO
  2042. error |= zorro_register_driver(&cirrusfb_zorro_driver);
  2043. #endif
  2044. #ifdef CONFIG_PCI
  2045. error |= pci_register_driver(&cirrusfb_pci_driver);
  2046. #endif
  2047. return error;
  2048. }
  2049. static void __exit cirrusfb_exit(void)
  2050. {
  2051. #ifdef CONFIG_PCI
  2052. pci_unregister_driver(&cirrusfb_pci_driver);
  2053. #endif
  2054. #ifdef CONFIG_ZORRO
  2055. zorro_unregister_driver(&cirrusfb_zorro_driver);
  2056. #endif
  2057. }
  2058. module_init(cirrusfb_init);
  2059. module_param(mode_option, charp, 0);
  2060. MODULE_PARM_DESC(mode_option, "Initial video mode e.g. '648x480-8@60'");
  2061. module_param(noaccel, bool, 0);
  2062. MODULE_PARM_DESC(noaccel, "Disable acceleration");
  2063. #ifdef MODULE
  2064. module_exit(cirrusfb_exit);
  2065. #endif
  2066. /**********************************************************************/
  2067. /* about the following functions - I have used the same names for the */
  2068. /* functions as Markus Wild did in his Retina driver for NetBSD as */
  2069. /* they just made sense for this purpose. Apart from that, I wrote */
  2070. /* these functions myself. */
  2071. /**********************************************************************/
  2072. /*** WGen() - write into one of the external/general registers ***/
  2073. static void WGen(const struct cirrusfb_info *cinfo,
  2074. int regnum, unsigned char val)
  2075. {
  2076. unsigned long regofs = 0;
  2077. if (cinfo->btype == BT_PICASSO) {
  2078. /* Picasso II specific hack */
  2079. /* if (regnum == VGA_PEL_IR || regnum == VGA_PEL_D ||
  2080. regnum == CL_VSSM2) */
  2081. if (regnum == VGA_PEL_IR || regnum == VGA_PEL_D)
  2082. regofs = 0xfff;
  2083. }
  2084. vga_w(cinfo->regbase, regofs + regnum, val);
  2085. }
  2086. /*** RGen() - read out one of the external/general registers ***/
  2087. static unsigned char RGen(const struct cirrusfb_info *cinfo, int regnum)
  2088. {
  2089. unsigned long regofs = 0;
  2090. if (cinfo->btype == BT_PICASSO) {
  2091. /* Picasso II specific hack */
  2092. /* if (regnum == VGA_PEL_IR || regnum == VGA_PEL_D ||
  2093. regnum == CL_VSSM2) */
  2094. if (regnum == VGA_PEL_IR || regnum == VGA_PEL_D)
  2095. regofs = 0xfff;
  2096. }
  2097. return vga_r(cinfo->regbase, regofs + regnum);
  2098. }
  2099. /*** AttrOn() - turn on VideoEnable for Attribute controller ***/
  2100. static void AttrOn(const struct cirrusfb_info *cinfo)
  2101. {
  2102. assert(cinfo != NULL);
  2103. if (vga_rcrt(cinfo->regbase, CL_CRT24) & 0x80) {
  2104. /* if we're just in "write value" mode, write back the */
  2105. /* same value as before to not modify anything */
  2106. vga_w(cinfo->regbase, VGA_ATT_IW,
  2107. vga_r(cinfo->regbase, VGA_ATT_R));
  2108. }
  2109. /* turn on video bit */
  2110. /* vga_w(cinfo->regbase, VGA_ATT_IW, 0x20); */
  2111. vga_w(cinfo->regbase, VGA_ATT_IW, 0x33);
  2112. /* dummy write on Reg0 to be on "write index" mode next time */
  2113. vga_w(cinfo->regbase, VGA_ATT_IW, 0x00);
  2114. }
  2115. /*** WHDR() - write into the Hidden DAC register ***/
  2116. /* as the HDR is the only extension register that requires special treatment
  2117. * (the other extension registers are accessible just like the "ordinary"
  2118. * registers of their functional group) here is a specialized routine for
  2119. * accessing the HDR
  2120. */
  2121. static void WHDR(const struct cirrusfb_info *cinfo, unsigned char val)
  2122. {
  2123. unsigned char dummy;
  2124. if (is_laguna(cinfo))
  2125. return;
  2126. if (cinfo->btype == BT_PICASSO) {
  2127. /* Klaus' hint for correct access to HDR on some boards */
  2128. /* first write 0 to pixel mask (3c6) */
  2129. WGen(cinfo, VGA_PEL_MSK, 0x00);
  2130. udelay(200);
  2131. /* next read dummy from pixel address (3c8) */
  2132. dummy = RGen(cinfo, VGA_PEL_IW);
  2133. udelay(200);
  2134. }
  2135. /* now do the usual stuff to access the HDR */
  2136. dummy = RGen(cinfo, VGA_PEL_MSK);
  2137. udelay(200);
  2138. dummy = RGen(cinfo, VGA_PEL_MSK);
  2139. udelay(200);
  2140. dummy = RGen(cinfo, VGA_PEL_MSK);
  2141. udelay(200);
  2142. dummy = RGen(cinfo, VGA_PEL_MSK);
  2143. udelay(200);
  2144. WGen(cinfo, VGA_PEL_MSK, val);
  2145. udelay(200);
  2146. if (cinfo->btype == BT_PICASSO) {
  2147. /* now first reset HDR access counter */
  2148. dummy = RGen(cinfo, VGA_PEL_IW);
  2149. udelay(200);
  2150. /* and at the end, restore the mask value */
  2151. /* ## is this mask always 0xff? */
  2152. WGen(cinfo, VGA_PEL_MSK, 0xff);
  2153. udelay(200);
  2154. }
  2155. }
  2156. /*** WSFR() - write to the "special function register" (SFR) ***/
  2157. static void WSFR(struct cirrusfb_info *cinfo, unsigned char val)
  2158. {
  2159. #ifdef CONFIG_ZORRO
  2160. assert(cinfo->regbase != NULL);
  2161. cinfo->SFR = val;
  2162. z_writeb(val, cinfo->regbase + 0x8000);
  2163. #endif
  2164. }
  2165. /* The Picasso has a second register for switching the monitor bit */
  2166. static void WSFR2(struct cirrusfb_info *cinfo, unsigned char val)
  2167. {
  2168. #ifdef CONFIG_ZORRO
  2169. /* writing an arbitrary value to this one causes the monitor switcher */
  2170. /* to flip to Amiga display */
  2171. assert(cinfo->regbase != NULL);
  2172. cinfo->SFR = val;
  2173. z_writeb(val, cinfo->regbase + 0x9000);
  2174. #endif
  2175. }
  2176. /*** WClut - set CLUT entry (range: 0..63) ***/
  2177. static void WClut(struct cirrusfb_info *cinfo, unsigned char regnum, unsigned char red,
  2178. unsigned char green, unsigned char blue)
  2179. {
  2180. unsigned int data = VGA_PEL_D;
  2181. /* address write mode register is not translated.. */
  2182. vga_w(cinfo->regbase, VGA_PEL_IW, regnum);
  2183. if (cinfo->btype == BT_PICASSO || cinfo->btype == BT_PICASSO4 ||
  2184. cinfo->btype == BT_ALPINE || cinfo->btype == BT_GD5480 ||
  2185. cinfo->btype == BT_SD64 || is_laguna(cinfo)) {
  2186. /* but DAC data register IS, at least for Picasso II */
  2187. if (cinfo->btype == BT_PICASSO)
  2188. data += 0xfff;
  2189. vga_w(cinfo->regbase, data, red);
  2190. vga_w(cinfo->regbase, data, green);
  2191. vga_w(cinfo->regbase, data, blue);
  2192. } else {
  2193. vga_w(cinfo->regbase, data, blue);
  2194. vga_w(cinfo->regbase, data, green);
  2195. vga_w(cinfo->regbase, data, red);
  2196. }
  2197. }
  2198. #if 0
  2199. /*** RClut - read CLUT entry (range 0..63) ***/
  2200. static void RClut(struct cirrusfb_info *cinfo, unsigned char regnum, unsigned char *red,
  2201. unsigned char *green, unsigned char *blue)
  2202. {
  2203. unsigned int data = VGA_PEL_D;
  2204. vga_w(cinfo->regbase, VGA_PEL_IR, regnum);
  2205. if (cinfo->btype == BT_PICASSO || cinfo->btype == BT_PICASSO4 ||
  2206. cinfo->btype == BT_ALPINE || cinfo->btype == BT_GD5480) {
  2207. if (cinfo->btype == BT_PICASSO)
  2208. data += 0xfff;
  2209. *red = vga_r(cinfo->regbase, data);
  2210. *green = vga_r(cinfo->regbase, data);
  2211. *blue = vga_r(cinfo->regbase, data);
  2212. } else {
  2213. *blue = vga_r(cinfo->regbase, data);
  2214. *green = vga_r(cinfo->regbase, data);
  2215. *red = vga_r(cinfo->regbase, data);
  2216. }
  2217. }
  2218. #endif
  2219. /*******************************************************************
  2220. cirrusfb_WaitBLT()
  2221. Wait for the BitBLT engine to complete a possible earlier job
  2222. *********************************************************************/
  2223. /* FIXME: use interrupts instead */
  2224. static void cirrusfb_WaitBLT(u8 __iomem *regbase)
  2225. {
  2226. while (vga_rgfx(regbase, CL_GR31) & 0x08)
  2227. cpu_relax();
  2228. }
  2229. /*******************************************************************
  2230. cirrusfb_BitBLT()
  2231. perform accelerated "scrolling"
  2232. ********************************************************************/
  2233. static void cirrusfb_set_blitter(u8 __iomem *regbase,
  2234. u_short nwidth, u_short nheight,
  2235. u_long nsrc, u_long ndest,
  2236. u_short bltmode, u_short line_length)
  2237. {
  2238. /* pitch: set to line_length */
  2239. /* dest pitch low */
  2240. vga_wgfx(regbase, CL_GR24, line_length & 0xff);
  2241. /* dest pitch hi */
  2242. vga_wgfx(regbase, CL_GR25, line_length >> 8);
  2243. /* source pitch low */
  2244. vga_wgfx(regbase, CL_GR26, line_length & 0xff);
  2245. /* source pitch hi */
  2246. vga_wgfx(regbase, CL_GR27, line_length >> 8);
  2247. /* BLT width: actual number of pixels - 1 */
  2248. /* BLT width low */
  2249. vga_wgfx(regbase, CL_GR20, nwidth & 0xff);
  2250. /* BLT width hi */
  2251. vga_wgfx(regbase, CL_GR21, nwidth >> 8);
  2252. /* BLT height: actual number of lines -1 */
  2253. /* BLT height low */
  2254. vga_wgfx(regbase, CL_GR22, nheight & 0xff);
  2255. /* BLT width hi */
  2256. vga_wgfx(regbase, CL_GR23, nheight >> 8);
  2257. /* BLT destination */
  2258. /* BLT dest low */
  2259. vga_wgfx(regbase, CL_GR28, (u_char) (ndest & 0xff));
  2260. /* BLT dest mid */
  2261. vga_wgfx(regbase, CL_GR29, (u_char) (ndest >> 8));
  2262. /* BLT dest hi */
  2263. vga_wgfx(regbase, CL_GR2A, (u_char) (ndest >> 16));
  2264. /* BLT source */
  2265. /* BLT src low */
  2266. vga_wgfx(regbase, CL_GR2C, (u_char) (nsrc & 0xff));
  2267. /* BLT src mid */
  2268. vga_wgfx(regbase, CL_GR2D, (u_char) (nsrc >> 8));
  2269. /* BLT src hi */
  2270. vga_wgfx(regbase, CL_GR2E, (u_char) (nsrc >> 16));
  2271. /* BLT mode */
  2272. vga_wgfx(regbase, CL_GR30, bltmode); /* BLT mode */
  2273. /* BLT ROP: SrcCopy */
  2274. vga_wgfx(regbase, CL_GR32, 0x0d); /* BLT ROP */
  2275. /* and finally: GO! */
  2276. vga_wgfx(regbase, CL_GR31, 0x02); /* BLT Start/status */
  2277. }
  2278. /*******************************************************************
  2279. cirrusfb_BitBLT()
  2280. perform accelerated "scrolling"
  2281. ********************************************************************/
  2282. static void cirrusfb_BitBLT(u8 __iomem *regbase, int bits_per_pixel,
  2283. u_short curx, u_short cury,
  2284. u_short destx, u_short desty,
  2285. u_short width, u_short height,
  2286. u_short line_length)
  2287. {
  2288. u_short nwidth = width - 1;
  2289. u_short nheight = height - 1;
  2290. u_long nsrc, ndest;
  2291. u_char bltmode;
  2292. bltmode = 0x00;
  2293. /* if source adr < dest addr, do the Blt backwards */
  2294. if (cury <= desty) {
  2295. if (cury == desty) {
  2296. /* if src and dest are on the same line, check x */
  2297. if (curx < destx)
  2298. bltmode |= 0x01;
  2299. } else
  2300. bltmode |= 0x01;
  2301. }
  2302. /* standard case: forward blitting */
  2303. nsrc = (cury * line_length) + curx;
  2304. ndest = (desty * line_length) + destx;
  2305. if (bltmode) {
  2306. /* this means start addresses are at the end,
  2307. * counting backwards
  2308. */
  2309. nsrc += nheight * line_length + nwidth;
  2310. ndest += nheight * line_length + nwidth;
  2311. }
  2312. cirrusfb_WaitBLT(regbase);
  2313. cirrusfb_set_blitter(regbase, nwidth, nheight,
  2314. nsrc, ndest, bltmode, line_length);
  2315. }
  2316. /*******************************************************************
  2317. cirrusfb_RectFill()
  2318. perform accelerated rectangle fill
  2319. ********************************************************************/
  2320. static void cirrusfb_RectFill(u8 __iomem *regbase, int bits_per_pixel,
  2321. u_short x, u_short y, u_short width, u_short height,
  2322. u32 fg_color, u32 bg_color, u_short line_length,
  2323. u_char blitmode)
  2324. {
  2325. u_long ndest = (y * line_length) + x;
  2326. u_char op;
  2327. cirrusfb_WaitBLT(regbase);
  2328. /* This is a ColorExpand Blt, using the */
  2329. /* same color for foreground and background */
  2330. vga_wgfx(regbase, VGA_GFX_SR_VALUE, bg_color);
  2331. vga_wgfx(regbase, VGA_GFX_SR_ENABLE, fg_color);
  2332. op = 0x80;
  2333. if (bits_per_pixel >= 16) {
  2334. vga_wgfx(regbase, CL_GR10, bg_color >> 8);
  2335. vga_wgfx(regbase, CL_GR11, fg_color >> 8);
  2336. op = 0x90;
  2337. }
  2338. if (bits_per_pixel >= 24) {
  2339. vga_wgfx(regbase, CL_GR12, bg_color >> 16);
  2340. vga_wgfx(regbase, CL_GR13, fg_color >> 16);
  2341. op = 0xa0;
  2342. }
  2343. if (bits_per_pixel == 32) {
  2344. vga_wgfx(regbase, CL_GR14, bg_color >> 24);
  2345. vga_wgfx(regbase, CL_GR15, fg_color >> 24);
  2346. op = 0xb0;
  2347. }
  2348. cirrusfb_set_blitter(regbase, width - 1, height - 1,
  2349. 0, ndest, op | blitmode, line_length);
  2350. }
  2351. /**************************************************************************
  2352. * bestclock() - determine closest possible clock lower(?) than the
  2353. * desired pixel clock
  2354. **************************************************************************/
  2355. static void bestclock(long freq, int *nom, int *den, int *div)
  2356. {
  2357. int n, d;
  2358. long h, diff;
  2359. assert(nom != NULL);
  2360. assert(den != NULL);
  2361. assert(div != NULL);
  2362. *nom = 0;
  2363. *den = 0;
  2364. *div = 0;
  2365. if (freq < 8000)
  2366. freq = 8000;
  2367. diff = freq;
  2368. for (n = 32; n < 128; n++) {
  2369. int s = 0;
  2370. d = (14318 * n) / freq;
  2371. if ((d >= 7) && (d <= 63)) {
  2372. int temp = d;
  2373. if (temp > 31) {
  2374. s = 1;
  2375. temp >>= 1;
  2376. }
  2377. h = ((14318 * n) / temp) >> s;
  2378. h = h > freq ? h - freq : freq - h;
  2379. if (h < diff) {
  2380. diff = h;
  2381. *nom = n;
  2382. *den = temp;
  2383. *div = s;
  2384. }
  2385. }
  2386. d++;
  2387. if ((d >= 7) && (d <= 63)) {
  2388. if (d > 31) {
  2389. s = 1;
  2390. d >>= 1;
  2391. }
  2392. h = ((14318 * n) / d) >> s;
  2393. h = h > freq ? h - freq : freq - h;
  2394. if (h < diff) {
  2395. diff = h;
  2396. *nom = n;
  2397. *den = d;
  2398. *div = s;
  2399. }
  2400. }
  2401. }
  2402. }
  2403. /* -------------------------------------------------------------------------
  2404. *
  2405. * debugging functions
  2406. *
  2407. * -------------------------------------------------------------------------
  2408. */
  2409. #ifdef CIRRUSFB_DEBUG
  2410. /**
  2411. * cirrusfb_dbg_print_regs
  2412. * @base: If using newmmio, the newmmio base address, otherwise %NULL
  2413. * @reg_class: type of registers to read: %CRT, or %SEQ
  2414. *
  2415. * DESCRIPTION:
  2416. * Dumps the given list of VGA CRTC registers. If @base is %NULL,
  2417. * old-style I/O ports are queried for information, otherwise MMIO is
  2418. * used at the given @base address to query the information.
  2419. */
  2420. static void cirrusfb_dbg_print_regs(struct fb_info *info,
  2421. caddr_t regbase,
  2422. enum cirrusfb_dbg_reg_class reg_class, ...)
  2423. {
  2424. va_list list;
  2425. unsigned char val = 0;
  2426. unsigned reg;
  2427. char *name;
  2428. va_start(list, reg_class);
  2429. name = va_arg(list, char *);
  2430. while (name != NULL) {
  2431. reg = va_arg(list, int);
  2432. switch (reg_class) {
  2433. case CRT:
  2434. val = vga_rcrt(regbase, (unsigned char) reg);
  2435. break;
  2436. case SEQ:
  2437. val = vga_rseq(regbase, (unsigned char) reg);
  2438. break;
  2439. default:
  2440. /* should never occur */
  2441. assert(false);
  2442. break;
  2443. }
  2444. dev_dbg(info->device, "%8s = 0x%02X\n", name, val);
  2445. name = va_arg(list, char *);
  2446. }
  2447. va_end(list);
  2448. }
  2449. /**
  2450. * cirrusfb_dbg_reg_dump
  2451. * @base: If using newmmio, the newmmio base address, otherwise %NULL
  2452. *
  2453. * DESCRIPTION:
  2454. * Dumps a list of interesting VGA and CIRRUSFB registers. If @base is %NULL,
  2455. * old-style I/O ports are queried for information, otherwise MMIO is
  2456. * used at the given @base address to query the information.
  2457. */
  2458. static void cirrusfb_dbg_reg_dump(struct fb_info *info, caddr_t regbase)
  2459. {
  2460. dev_dbg(info->device, "VGA CRTC register dump:\n");
  2461. cirrusfb_dbg_print_regs(info, regbase, CRT,
  2462. "CR00", 0x00,
  2463. "CR01", 0x01,
  2464. "CR02", 0x02,
  2465. "CR03", 0x03,
  2466. "CR04", 0x04,
  2467. "CR05", 0x05,
  2468. "CR06", 0x06,
  2469. "CR07", 0x07,
  2470. "CR08", 0x08,
  2471. "CR09", 0x09,
  2472. "CR0A", 0x0A,
  2473. "CR0B", 0x0B,
  2474. "CR0C", 0x0C,
  2475. "CR0D", 0x0D,
  2476. "CR0E", 0x0E,
  2477. "CR0F", 0x0F,
  2478. "CR10", 0x10,
  2479. "CR11", 0x11,
  2480. "CR12", 0x12,
  2481. "CR13", 0x13,
  2482. "CR14", 0x14,
  2483. "CR15", 0x15,
  2484. "CR16", 0x16,
  2485. "CR17", 0x17,
  2486. "CR18", 0x18,
  2487. "CR22", 0x22,
  2488. "CR24", 0x24,
  2489. "CR26", 0x26,
  2490. "CR2D", 0x2D,
  2491. "CR2E", 0x2E,
  2492. "CR2F", 0x2F,
  2493. "CR30", 0x30,
  2494. "CR31", 0x31,
  2495. "CR32", 0x32,
  2496. "CR33", 0x33,
  2497. "CR34", 0x34,
  2498. "CR35", 0x35,
  2499. "CR36", 0x36,
  2500. "CR37", 0x37,
  2501. "CR38", 0x38,
  2502. "CR39", 0x39,
  2503. "CR3A", 0x3A,
  2504. "CR3B", 0x3B,
  2505. "CR3C", 0x3C,
  2506. "CR3D", 0x3D,
  2507. "CR3E", 0x3E,
  2508. "CR3F", 0x3F,
  2509. NULL);
  2510. dev_dbg(info->device, "\n");
  2511. dev_dbg(info->device, "VGA SEQ register dump:\n");
  2512. cirrusfb_dbg_print_regs(info, regbase, SEQ,
  2513. "SR00", 0x00,
  2514. "SR01", 0x01,
  2515. "SR02", 0x02,
  2516. "SR03", 0x03,
  2517. "SR04", 0x04,
  2518. "SR08", 0x08,
  2519. "SR09", 0x09,
  2520. "SR0A", 0x0A,
  2521. "SR0B", 0x0B,
  2522. "SR0D", 0x0D,
  2523. "SR10", 0x10,
  2524. "SR11", 0x11,
  2525. "SR12", 0x12,
  2526. "SR13", 0x13,
  2527. "SR14", 0x14,
  2528. "SR15", 0x15,
  2529. "SR16", 0x16,
  2530. "SR17", 0x17,
  2531. "SR18", 0x18,
  2532. "SR19", 0x19,
  2533. "SR1A", 0x1A,
  2534. "SR1B", 0x1B,
  2535. "SR1C", 0x1C,
  2536. "SR1D", 0x1D,
  2537. "SR1E", 0x1E,
  2538. "SR1F", 0x1F,
  2539. NULL);
  2540. dev_dbg(info->device, "\n");
  2541. }
  2542. #endif /* CIRRUSFB_DEBUG */