cirrusfb.c 75 KB

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