cirrusfb.c 89 KB

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