sm712fb.c 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643
  1. /*
  2. * Silicon Motion SM7XX frame buffer device
  3. *
  4. * Copyright (C) 2006 Silicon Motion Technology Corp.
  5. * Authors: Ge Wang, gewang@siliconmotion.com
  6. * Boyod boyod.yang@siliconmotion.com.cn
  7. *
  8. * Copyright (C) 2009 Lemote, Inc.
  9. * Author: Wu Zhangjin, wuzhangjin@gmail.com
  10. *
  11. * Copyright (C) 2011 Igalia, S.L.
  12. * Author: Javier M. Mellid <jmunhoz@igalia.com>
  13. *
  14. * This file is subject to the terms and conditions of the GNU General Public
  15. * License. See the file COPYING in the main directory of this archive for
  16. * more details.
  17. *
  18. * Framebuffer driver for Silicon Motion SM710, SM712, SM721 and SM722 chips
  19. */
  20. #include <linux/io.h>
  21. #include <linux/fb.h>
  22. #include <linux/pci.h>
  23. #include <linux/init.h>
  24. #include <linux/slab.h>
  25. #include <linux/uaccess.h>
  26. #include <linux/module.h>
  27. #include <linux/console.h>
  28. #include <linux/screen_info.h>
  29. #include <linux/pm.h>
  30. #include "sm712.h"
  31. /*
  32. * Private structure
  33. */
  34. struct smtcfb_info {
  35. struct pci_dev *pdev;
  36. struct fb_info *fb;
  37. u16 chip_id;
  38. u8 chip_rev_id;
  39. void __iomem *lfb; /* linear frame buffer */
  40. void __iomem *dp_regs; /* drawing processor control regs */
  41. void __iomem *vp_regs; /* video processor control regs */
  42. void __iomem *cp_regs; /* capture processor control regs */
  43. void __iomem *mmio; /* memory map IO port */
  44. u_int width;
  45. u_int height;
  46. u_int hz;
  47. u32 colreg[17];
  48. };
  49. void __iomem *smtc_regbaseaddress; /* Memory Map IO starting address */
  50. static const struct fb_var_screeninfo smtcfb_var = {
  51. .xres = 1024,
  52. .yres = 600,
  53. .xres_virtual = 1024,
  54. .yres_virtual = 600,
  55. .bits_per_pixel = 16,
  56. .red = {16, 8, 0},
  57. .green = {8, 8, 0},
  58. .blue = {0, 8, 0},
  59. .activate = FB_ACTIVATE_NOW,
  60. .height = -1,
  61. .width = -1,
  62. .vmode = FB_VMODE_NONINTERLACED,
  63. .nonstd = 0,
  64. .accel_flags = FB_ACCELF_TEXT,
  65. };
  66. static struct fb_fix_screeninfo smtcfb_fix = {
  67. .id = "smXXXfb",
  68. .type = FB_TYPE_PACKED_PIXELS,
  69. .visual = FB_VISUAL_TRUECOLOR,
  70. .line_length = 800 * 3,
  71. .accel = FB_ACCEL_SMI_LYNX,
  72. .type_aux = 0,
  73. .xpanstep = 0,
  74. .ypanstep = 0,
  75. .ywrapstep = 0,
  76. };
  77. struct vesa_mode {
  78. char index[6];
  79. u16 lfb_width;
  80. u16 lfb_height;
  81. u16 lfb_depth;
  82. };
  83. static const struct vesa_mode vesa_mode_table[] = {
  84. {"0x301", 640, 480, 8},
  85. {"0x303", 800, 600, 8},
  86. {"0x305", 1024, 768, 8},
  87. {"0x307", 1280, 1024, 8},
  88. {"0x311", 640, 480, 16},
  89. {"0x314", 800, 600, 16},
  90. {"0x317", 1024, 768, 16},
  91. {"0x31A", 1280, 1024, 16},
  92. {"0x312", 640, 480, 24},
  93. {"0x315", 800, 600, 24},
  94. {"0x318", 1024, 768, 24},
  95. {"0x31B", 1280, 1024, 24},
  96. };
  97. /**********************************************************************
  98. SM712 Mode table.
  99. **********************************************************************/
  100. static const struct modeinit vgamode[] = {
  101. {
  102. /* mode#0: 640 x 480 16Bpp 60Hz */
  103. 640, 480, 16, 60,
  104. /* Init_MISC */
  105. 0xE3,
  106. { /* Init_SR0_SR4 */
  107. 0x03, 0x01, 0x0F, 0x00, 0x0E,
  108. },
  109. { /* Init_SR10_SR24 */
  110. 0xFF, 0xBE, 0xEF, 0xFF, 0x00, 0x0E, 0x17, 0x2C,
  111. 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  112. 0xC4, 0x30, 0x02, 0x01, 0x01,
  113. },
  114. { /* Init_SR30_SR75 */
  115. 0x32, 0x03, 0xA0, 0x09, 0xC0, 0x32, 0x32, 0x32,
  116. 0x32, 0x32, 0x32, 0x32, 0x00, 0x00, 0x03, 0xFF,
  117. 0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
  118. 0x20, 0x0C, 0x44, 0x20, 0x00, 0x32, 0x32, 0x32,
  119. 0x04, 0x24, 0x63, 0x4F, 0x52, 0x0B, 0xDF, 0xEA,
  120. 0x04, 0x50, 0x19, 0x32, 0x32, 0x00, 0x00, 0x32,
  121. 0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
  122. 0x50, 0x03, 0x74, 0x14, 0x07, 0x82, 0x07, 0x04,
  123. 0x00, 0x45, 0x30, 0x30, 0x40, 0x30,
  124. },
  125. { /* Init_SR80_SR93 */
  126. 0xFF, 0x07, 0x00, 0x6F, 0x7F, 0x7F, 0xFF, 0x32,
  127. 0xF7, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0x32, 0x32,
  128. 0x00, 0x00, 0x00, 0x00,
  129. },
  130. { /* Init_SRA0_SRAF */
  131. 0x00, 0xFF, 0xBF, 0xFF, 0xFF, 0xED, 0xED, 0xED,
  132. 0x7B, 0xFF, 0xFF, 0xFF, 0xBF, 0xEF, 0xFF, 0xDF,
  133. },
  134. { /* Init_GR00_GR08 */
  135. 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
  136. 0xFF,
  137. },
  138. { /* Init_AR00_AR14 */
  139. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  140. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  141. 0x41, 0x00, 0x0F, 0x00, 0x00,
  142. },
  143. { /* Init_CR00_CR18 */
  144. 0x5F, 0x4F, 0x4F, 0x00, 0x53, 0x1F, 0x0B, 0x3E,
  145. 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  146. 0xEA, 0x0C, 0xDF, 0x50, 0x40, 0xDF, 0x00, 0xE3,
  147. 0xFF,
  148. },
  149. { /* Init_CR30_CR4D */
  150. 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x03, 0x20,
  151. 0x00, 0x00, 0x00, 0x40, 0x00, 0xE7, 0xFF, 0xFD,
  152. 0x5F, 0x4F, 0x00, 0x54, 0x00, 0x0B, 0xDF, 0x00,
  153. 0xEA, 0x0C, 0x2E, 0x00, 0x4F, 0xDF,
  154. },
  155. { /* Init_CR90_CRA7 */
  156. 0x56, 0xDD, 0x5E, 0xEA, 0x87, 0x44, 0x8F, 0x55,
  157. 0x0A, 0x8F, 0x55, 0x0A, 0x00, 0x00, 0x18, 0x00,
  158. 0x11, 0x10, 0x0B, 0x0A, 0x0A, 0x0A, 0x0A, 0x00,
  159. },
  160. },
  161. {
  162. /* mode#1: 640 x 480 24Bpp 60Hz */
  163. 640, 480, 24, 60,
  164. /* Init_MISC */
  165. 0xE3,
  166. { /* Init_SR0_SR4 */
  167. 0x03, 0x01, 0x0F, 0x00, 0x0E,
  168. },
  169. { /* Init_SR10_SR24 */
  170. 0xFF, 0xBE, 0xEF, 0xFF, 0x00, 0x0E, 0x17, 0x2C,
  171. 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  172. 0xC4, 0x30, 0x02, 0x01, 0x01,
  173. },
  174. { /* Init_SR30_SR75 */
  175. 0x32, 0x03, 0xA0, 0x09, 0xC0, 0x32, 0x32, 0x32,
  176. 0x32, 0x32, 0x32, 0x32, 0x00, 0x00, 0x03, 0xFF,
  177. 0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
  178. 0x20, 0x0C, 0x44, 0x20, 0x00, 0x32, 0x32, 0x32,
  179. 0x04, 0x24, 0x63, 0x4F, 0x52, 0x0B, 0xDF, 0xEA,
  180. 0x04, 0x50, 0x19, 0x32, 0x32, 0x00, 0x00, 0x32,
  181. 0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
  182. 0x50, 0x03, 0x74, 0x14, 0x07, 0x82, 0x07, 0x04,
  183. 0x00, 0x45, 0x30, 0x30, 0x40, 0x30,
  184. },
  185. { /* Init_SR80_SR93 */
  186. 0xFF, 0x07, 0x00, 0x6F, 0x7F, 0x7F, 0xFF, 0x32,
  187. 0xF7, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0x32, 0x32,
  188. 0x00, 0x00, 0x00, 0x00,
  189. },
  190. { /* Init_SRA0_SRAF */
  191. 0x00, 0xFF, 0xBF, 0xFF, 0xFF, 0xED, 0xED, 0xED,
  192. 0x7B, 0xFF, 0xFF, 0xFF, 0xBF, 0xEF, 0xFF, 0xDF,
  193. },
  194. { /* Init_GR00_GR08 */
  195. 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
  196. 0xFF,
  197. },
  198. { /* Init_AR00_AR14 */
  199. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  200. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  201. 0x41, 0x00, 0x0F, 0x00, 0x00,
  202. },
  203. { /* Init_CR00_CR18 */
  204. 0x5F, 0x4F, 0x4F, 0x00, 0x53, 0x1F, 0x0B, 0x3E,
  205. 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  206. 0xEA, 0x0C, 0xDF, 0x50, 0x40, 0xDF, 0x00, 0xE3,
  207. 0xFF,
  208. },
  209. { /* Init_CR30_CR4D */
  210. 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x03, 0x20,
  211. 0x00, 0x00, 0x00, 0x40, 0x00, 0xE7, 0xFF, 0xFD,
  212. 0x5F, 0x4F, 0x00, 0x54, 0x00, 0x0B, 0xDF, 0x00,
  213. 0xEA, 0x0C, 0x2E, 0x00, 0x4F, 0xDF,
  214. },
  215. { /* Init_CR90_CRA7 */
  216. 0x56, 0xDD, 0x5E, 0xEA, 0x87, 0x44, 0x8F, 0x55,
  217. 0x0A, 0x8F, 0x55, 0x0A, 0x00, 0x00, 0x18, 0x00,
  218. 0x11, 0x10, 0x0B, 0x0A, 0x0A, 0x0A, 0x0A, 0x00,
  219. },
  220. },
  221. {
  222. /* mode#0: 640 x 480 32Bpp 60Hz */
  223. 640, 480, 32, 60,
  224. /* Init_MISC */
  225. 0xE3,
  226. { /* Init_SR0_SR4 */
  227. 0x03, 0x01, 0x0F, 0x00, 0x0E,
  228. },
  229. { /* Init_SR10_SR24 */
  230. 0xFF, 0xBE, 0xEF, 0xFF, 0x00, 0x0E, 0x17, 0x2C,
  231. 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  232. 0xC4, 0x30, 0x02, 0x01, 0x01,
  233. },
  234. { /* Init_SR30_SR75 */
  235. 0x32, 0x03, 0xA0, 0x09, 0xC0, 0x32, 0x32, 0x32,
  236. 0x32, 0x32, 0x32, 0x32, 0x00, 0x00, 0x03, 0xFF,
  237. 0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
  238. 0x20, 0x0C, 0x44, 0x20, 0x00, 0x32, 0x32, 0x32,
  239. 0x04, 0x24, 0x63, 0x4F, 0x52, 0x0B, 0xDF, 0xEA,
  240. 0x04, 0x50, 0x19, 0x32, 0x32, 0x00, 0x00, 0x32,
  241. 0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
  242. 0x50, 0x03, 0x74, 0x14, 0x07, 0x82, 0x07, 0x04,
  243. 0x00, 0x45, 0x30, 0x30, 0x40, 0x30,
  244. },
  245. { /* Init_SR80_SR93 */
  246. 0xFF, 0x07, 0x00, 0x6F, 0x7F, 0x7F, 0xFF, 0x32,
  247. 0xF7, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0x32, 0x32,
  248. 0x00, 0x00, 0x00, 0x00,
  249. },
  250. { /* Init_SRA0_SRAF */
  251. 0x00, 0xFF, 0xBF, 0xFF, 0xFF, 0xED, 0xED, 0xED,
  252. 0x7B, 0xFF, 0xFF, 0xFF, 0xBF, 0xEF, 0xFF, 0xDF,
  253. },
  254. { /* Init_GR00_GR08 */
  255. 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
  256. 0xFF,
  257. },
  258. { /* Init_AR00_AR14 */
  259. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  260. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  261. 0x41, 0x00, 0x0F, 0x00, 0x00,
  262. },
  263. { /* Init_CR00_CR18 */
  264. 0x5F, 0x4F, 0x4F, 0x00, 0x53, 0x1F, 0x0B, 0x3E,
  265. 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  266. 0xEA, 0x0C, 0xDF, 0x50, 0x40, 0xDF, 0x00, 0xE3,
  267. 0xFF,
  268. },
  269. { /* Init_CR30_CR4D */
  270. 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x03, 0x20,
  271. 0x00, 0x00, 0x00, 0x40, 0x00, 0xE7, 0xFF, 0xFD,
  272. 0x5F, 0x4F, 0x00, 0x54, 0x00, 0x0B, 0xDF, 0x00,
  273. 0xEA, 0x0C, 0x2E, 0x00, 0x4F, 0xDF,
  274. },
  275. { /* Init_CR90_CRA7 */
  276. 0x56, 0xDD, 0x5E, 0xEA, 0x87, 0x44, 0x8F, 0x55,
  277. 0x0A, 0x8F, 0x55, 0x0A, 0x00, 0x00, 0x18, 0x00,
  278. 0x11, 0x10, 0x0B, 0x0A, 0x0A, 0x0A, 0x0A, 0x00,
  279. },
  280. },
  281. { /* mode#2: 800 x 600 16Bpp 60Hz */
  282. 800, 600, 16, 60,
  283. /* Init_MISC */
  284. 0x2B,
  285. { /* Init_SR0_SR4 */
  286. 0x03, 0x01, 0x0F, 0x03, 0x0E,
  287. },
  288. { /* Init_SR10_SR24 */
  289. 0xFF, 0xBE, 0xEE, 0xFF, 0x00, 0x0E, 0x17, 0x2C,
  290. 0x99, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  291. 0xC4, 0x30, 0x02, 0x01, 0x01,
  292. },
  293. { /* Init_SR30_SR75 */
  294. 0x34, 0x03, 0x20, 0x09, 0xC0, 0x24, 0x24, 0x24,
  295. 0x24, 0x24, 0x24, 0x24, 0x00, 0x00, 0x03, 0xFF,
  296. 0x00, 0xFC, 0x00, 0x00, 0x20, 0x38, 0x00, 0xFC,
  297. 0x20, 0x0C, 0x44, 0x20, 0x00, 0x24, 0x24, 0x24,
  298. 0x04, 0x48, 0x83, 0x63, 0x68, 0x72, 0x57, 0x58,
  299. 0x04, 0x55, 0x59, 0x24, 0x24, 0x00, 0x00, 0x24,
  300. 0x01, 0x80, 0x7A, 0x1A, 0x1A, 0x00, 0x00, 0x00,
  301. 0x50, 0x03, 0x74, 0x14, 0x1C, 0x85, 0x35, 0x13,
  302. 0x02, 0x45, 0x30, 0x35, 0x40, 0x20,
  303. },
  304. { /* Init_SR80_SR93 */
  305. 0x00, 0x00, 0x00, 0x6F, 0x7F, 0x7F, 0xFF, 0x24,
  306. 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x24, 0x24,
  307. 0x00, 0x00, 0x00, 0x00,
  308. },
  309. { /* Init_SRA0_SRAF */
  310. 0x00, 0xFF, 0xBF, 0xFF, 0xFF, 0xED, 0xED, 0xED,
  311. 0x7B, 0xFF, 0xFF, 0xFF, 0xBF, 0xEF, 0xBF, 0xDF,
  312. },
  313. { /* Init_GR00_GR08 */
  314. 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
  315. 0xFF,
  316. },
  317. { /* Init_AR00_AR14 */
  318. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  319. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  320. 0x41, 0x00, 0x0F, 0x00, 0x00,
  321. },
  322. { /* Init_CR00_CR18 */
  323. 0x7F, 0x63, 0x63, 0x00, 0x68, 0x18, 0x72, 0xF0,
  324. 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  325. 0x58, 0x0C, 0x57, 0x64, 0x40, 0x57, 0x00, 0xE3,
  326. 0xFF,
  327. },
  328. { /* Init_CR30_CR4D */
  329. 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x03, 0x20,
  330. 0x00, 0x00, 0x00, 0x40, 0x00, 0xE7, 0xBF, 0xFD,
  331. 0x7F, 0x63, 0x00, 0x69, 0x18, 0x72, 0x57, 0x00,
  332. 0x58, 0x0C, 0xE0, 0x20, 0x63, 0x57,
  333. },
  334. { /* Init_CR90_CRA7 */
  335. 0x56, 0x4B, 0x5E, 0x55, 0x86, 0x9D, 0x8E, 0xAA,
  336. 0xDB, 0x2A, 0xDF, 0x33, 0x00, 0x00, 0x18, 0x00,
  337. 0x20, 0x1F, 0x1A, 0x19, 0x0F, 0x0F, 0x0F, 0x00,
  338. },
  339. },
  340. { /* mode#3: 800 x 600 24Bpp 60Hz */
  341. 800, 600, 24, 60,
  342. 0x2B,
  343. { /* Init_SR0_SR4 */
  344. 0x03, 0x01, 0x0F, 0x03, 0x0E,
  345. },
  346. { /* Init_SR10_SR24 */
  347. 0xFF, 0xBE, 0xEE, 0xFF, 0x00, 0x0E, 0x17, 0x2C,
  348. 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  349. 0xC4, 0x30, 0x02, 0x01, 0x01,
  350. },
  351. { /* Init_SR30_SR75 */
  352. 0x36, 0x03, 0x20, 0x09, 0xC0, 0x36, 0x36, 0x36,
  353. 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x03, 0xFF,
  354. 0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
  355. 0x20, 0x0C, 0x44, 0x20, 0x00, 0x36, 0x36, 0x36,
  356. 0x04, 0x48, 0x83, 0x63, 0x68, 0x72, 0x57, 0x58,
  357. 0x04, 0x55, 0x59, 0x36, 0x36, 0x00, 0x00, 0x36,
  358. 0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
  359. 0x50, 0x03, 0x74, 0x14, 0x1C, 0x85, 0x35, 0x13,
  360. 0x02, 0x45, 0x30, 0x30, 0x40, 0x20,
  361. },
  362. { /* Init_SR80_SR93 */
  363. 0xFF, 0x07, 0x00, 0x6F, 0x7F, 0x7F, 0xFF, 0x36,
  364. 0xF7, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0x36, 0x36,
  365. 0x00, 0x00, 0x00, 0x00,
  366. },
  367. { /* Init_SRA0_SRAF */
  368. 0x00, 0xFF, 0xBF, 0xFF, 0xFF, 0xED, 0xED, 0xED,
  369. 0x7B, 0xFF, 0xFF, 0xFF, 0xBF, 0xEF, 0xBF, 0xDF,
  370. },
  371. { /* Init_GR00_GR08 */
  372. 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
  373. 0xFF,
  374. },
  375. { /* Init_AR00_AR14 */
  376. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  377. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  378. 0x41, 0x00, 0x0F, 0x00, 0x00,
  379. },
  380. { /* Init_CR00_CR18 */
  381. 0x7F, 0x63, 0x63, 0x00, 0x68, 0x18, 0x72, 0xF0,
  382. 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  383. 0x58, 0x0C, 0x57, 0x64, 0x40, 0x57, 0x00, 0xE3,
  384. 0xFF,
  385. },
  386. { /* Init_CR30_CR4D */
  387. 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x03, 0x20,
  388. 0x00, 0x00, 0x00, 0x40, 0x00, 0xE7, 0xBF, 0xFD,
  389. 0x7F, 0x63, 0x00, 0x69, 0x18, 0x72, 0x57, 0x00,
  390. 0x58, 0x0C, 0xE0, 0x20, 0x63, 0x57,
  391. },
  392. { /* Init_CR90_CRA7 */
  393. 0x56, 0x4B, 0x5E, 0x55, 0x86, 0x9D, 0x8E, 0xAA,
  394. 0xDB, 0x2A, 0xDF, 0x33, 0x00, 0x00, 0x18, 0x00,
  395. 0x20, 0x1F, 0x1A, 0x19, 0x0F, 0x0F, 0x0F, 0x00,
  396. },
  397. },
  398. { /* mode#7: 800 x 600 32Bpp 60Hz */
  399. 800, 600, 32, 60,
  400. /* Init_MISC */
  401. 0x2B,
  402. { /* Init_SR0_SR4 */
  403. 0x03, 0x01, 0x0F, 0x03, 0x0E,
  404. },
  405. { /* Init_SR10_SR24 */
  406. 0xFF, 0xBE, 0xEE, 0xFF, 0x00, 0x0E, 0x17, 0x2C,
  407. 0x99, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  408. 0xC4, 0x30, 0x02, 0x01, 0x01,
  409. },
  410. { /* Init_SR30_SR75 */
  411. 0x34, 0x03, 0x20, 0x09, 0xC0, 0x24, 0x24, 0x24,
  412. 0x24, 0x24, 0x24, 0x24, 0x00, 0x00, 0x03, 0xFF,
  413. 0x00, 0xFC, 0x00, 0x00, 0x20, 0x38, 0x00, 0xFC,
  414. 0x20, 0x0C, 0x44, 0x20, 0x00, 0x24, 0x24, 0x24,
  415. 0x04, 0x48, 0x83, 0x63, 0x68, 0x72, 0x57, 0x58,
  416. 0x04, 0x55, 0x59, 0x24, 0x24, 0x00, 0x00, 0x24,
  417. 0x01, 0x80, 0x7A, 0x1A, 0x1A, 0x00, 0x00, 0x00,
  418. 0x50, 0x03, 0x74, 0x14, 0x1C, 0x85, 0x35, 0x13,
  419. 0x02, 0x45, 0x30, 0x35, 0x40, 0x20,
  420. },
  421. { /* Init_SR80_SR93 */
  422. 0x00, 0x00, 0x00, 0x6F, 0x7F, 0x7F, 0xFF, 0x24,
  423. 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x24, 0x24,
  424. 0x00, 0x00, 0x00, 0x00,
  425. },
  426. { /* Init_SRA0_SRAF */
  427. 0x00, 0xFF, 0xBF, 0xFF, 0xFF, 0xED, 0xED, 0xED,
  428. 0x7B, 0xFF, 0xFF, 0xFF, 0xBF, 0xEF, 0xBF, 0xDF,
  429. },
  430. { /* Init_GR00_GR08 */
  431. 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
  432. 0xFF,
  433. },
  434. { /* Init_AR00_AR14 */
  435. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  436. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  437. 0x41, 0x00, 0x0F, 0x00, 0x00,
  438. },
  439. { /* Init_CR00_CR18 */
  440. 0x7F, 0x63, 0x63, 0x00, 0x68, 0x18, 0x72, 0xF0,
  441. 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  442. 0x58, 0x0C, 0x57, 0x64, 0x40, 0x57, 0x00, 0xE3,
  443. 0xFF,
  444. },
  445. { /* Init_CR30_CR4D */
  446. 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x03, 0x20,
  447. 0x00, 0x00, 0x00, 0x40, 0x00, 0xE7, 0xBF, 0xFD,
  448. 0x7F, 0x63, 0x00, 0x69, 0x18, 0x72, 0x57, 0x00,
  449. 0x58, 0x0C, 0xE0, 0x20, 0x63, 0x57,
  450. },
  451. { /* Init_CR90_CRA7 */
  452. 0x56, 0x4B, 0x5E, 0x55, 0x86, 0x9D, 0x8E, 0xAA,
  453. 0xDB, 0x2A, 0xDF, 0x33, 0x00, 0x00, 0x18, 0x00,
  454. 0x20, 0x1F, 0x1A, 0x19, 0x0F, 0x0F, 0x0F, 0x00,
  455. },
  456. },
  457. /* We use 1024x768 table to light 1024x600 panel for lemote */
  458. { /* mode#4: 1024 x 600 16Bpp 60Hz */
  459. 1024, 600, 16, 60,
  460. /* Init_MISC */
  461. 0xEB,
  462. { /* Init_SR0_SR4 */
  463. 0x03, 0x01, 0x0F, 0x00, 0x0E,
  464. },
  465. { /* Init_SR10_SR24 */
  466. 0xC8, 0x40, 0x14, 0x60, 0x00, 0x0A, 0x17, 0x20,
  467. 0x51, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  468. 0xC4, 0x30, 0x02, 0x00, 0x01,
  469. },
  470. { /* Init_SR30_SR75 */
  471. 0x22, 0x03, 0x24, 0x09, 0xC0, 0x22, 0x22, 0x22,
  472. 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x03, 0xFF,
  473. 0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
  474. 0x20, 0x0C, 0x44, 0x20, 0x00, 0x22, 0x22, 0x22,
  475. 0x06, 0x68, 0xA7, 0x7F, 0x83, 0x24, 0xFF, 0x03,
  476. 0x00, 0x60, 0x59, 0x22, 0x22, 0x00, 0x00, 0x22,
  477. 0x01, 0x80, 0x7A, 0x1A, 0x1A, 0x00, 0x00, 0x00,
  478. 0x50, 0x03, 0x16, 0x02, 0x0D, 0x82, 0x09, 0x02,
  479. 0x04, 0x45, 0x3F, 0x30, 0x40, 0x20,
  480. },
  481. { /* Init_SR80_SR93 */
  482. 0xFF, 0x07, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x3A,
  483. 0xF7, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3A, 0x3A,
  484. 0x00, 0x00, 0x00, 0x00,
  485. },
  486. { /* Init_SRA0_SRAF */
  487. 0x00, 0xFB, 0x9F, 0x01, 0x00, 0xED, 0xED, 0xED,
  488. 0x7B, 0xFB, 0xFF, 0xFF, 0x97, 0xEF, 0xBF, 0xDF,
  489. },
  490. { /* Init_GR00_GR08 */
  491. 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
  492. 0xFF,
  493. },
  494. { /* Init_AR00_AR14 */
  495. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  496. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  497. 0x41, 0x00, 0x0F, 0x00, 0x00,
  498. },
  499. { /* Init_CR00_CR18 */
  500. 0xA3, 0x7F, 0x7F, 0x00, 0x85, 0x16, 0x24, 0xF5,
  501. 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  502. 0x03, 0x09, 0xFF, 0x80, 0x40, 0xFF, 0x00, 0xE3,
  503. 0xFF,
  504. },
  505. { /* Init_CR30_CR4D */
  506. 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20,
  507. 0x00, 0x00, 0x00, 0x40, 0x00, 0xFF, 0xBF, 0xFF,
  508. 0xA3, 0x7F, 0x00, 0x82, 0x0b, 0x6f, 0x57, 0x00,
  509. 0x5c, 0x0f, 0xE0, 0xe0, 0x7F, 0x57,
  510. },
  511. { /* Init_CR90_CRA7 */
  512. 0x55, 0xD9, 0x5D, 0xE1, 0x86, 0x1B, 0x8E, 0x26,
  513. 0xDA, 0x8D, 0xDE, 0x94, 0x00, 0x00, 0x18, 0x00,
  514. 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03,
  515. },
  516. },
  517. { /* mode#5: 1024 x 768 24Bpp 60Hz */
  518. 1024, 768, 24, 60,
  519. /* Init_MISC */
  520. 0xEB,
  521. { /* Init_SR0_SR4 */
  522. 0x03, 0x01, 0x0F, 0x03, 0x0E,
  523. },
  524. { /* Init_SR10_SR24 */
  525. 0xF3, 0xB6, 0xC0, 0xDD, 0x00, 0x0E, 0x17, 0x2C,
  526. 0x99, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  527. 0xC4, 0x30, 0x02, 0x01, 0x01,
  528. },
  529. { /* Init_SR30_SR75 */
  530. 0x38, 0x03, 0x20, 0x09, 0xC0, 0x3A, 0x3A, 0x3A,
  531. 0x3A, 0x3A, 0x3A, 0x3A, 0x00, 0x00, 0x03, 0xFF,
  532. 0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
  533. 0x20, 0x0C, 0x44, 0x20, 0x00, 0x00, 0x00, 0x3A,
  534. 0x06, 0x68, 0xA7, 0x7F, 0x83, 0x24, 0xFF, 0x03,
  535. 0x00, 0x60, 0x59, 0x3A, 0x3A, 0x00, 0x00, 0x3A,
  536. 0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
  537. 0x50, 0x03, 0x74, 0x14, 0x3B, 0x0D, 0x09, 0x02,
  538. 0x04, 0x45, 0x30, 0x30, 0x40, 0x20,
  539. },
  540. { /* Init_SR80_SR93 */
  541. 0xFF, 0x07, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x3A,
  542. 0xF7, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3A, 0x3A,
  543. 0x00, 0x00, 0x00, 0x00,
  544. },
  545. { /* Init_SRA0_SRAF */
  546. 0x00, 0xFB, 0x9F, 0x01, 0x00, 0xED, 0xED, 0xED,
  547. 0x7B, 0xFB, 0xFF, 0xFF, 0x97, 0xEF, 0xBF, 0xDF,
  548. },
  549. { /* Init_GR00_GR08 */
  550. 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
  551. 0xFF,
  552. },
  553. { /* Init_AR00_AR14 */
  554. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  555. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  556. 0x41, 0x00, 0x0F, 0x00, 0x00,
  557. },
  558. { /* Init_CR00_CR18 */
  559. 0xA3, 0x7F, 0x7F, 0x00, 0x85, 0x16, 0x24, 0xF5,
  560. 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  561. 0x03, 0x09, 0xFF, 0x80, 0x40, 0xFF, 0x00, 0xE3,
  562. 0xFF,
  563. },
  564. { /* Init_CR30_CR4D */
  565. 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20,
  566. 0x00, 0x00, 0x00, 0x40, 0x00, 0xFF, 0xBF, 0xFF,
  567. 0xA3, 0x7F, 0x00, 0x86, 0x15, 0x24, 0xFF, 0x00,
  568. 0x01, 0x07, 0xE5, 0x20, 0x7F, 0xFF,
  569. },
  570. { /* Init_CR90_CRA7 */
  571. 0x55, 0xD9, 0x5D, 0xE1, 0x86, 0x1B, 0x8E, 0x26,
  572. 0xDA, 0x8D, 0xDE, 0x94, 0x00, 0x00, 0x18, 0x00,
  573. 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03,
  574. },
  575. },
  576. { /* mode#4: 1024 x 768 32Bpp 60Hz */
  577. 1024, 768, 32, 60,
  578. /* Init_MISC */
  579. 0xEB,
  580. { /* Init_SR0_SR4 */
  581. 0x03, 0x01, 0x0F, 0x03, 0x0E,
  582. },
  583. { /* Init_SR10_SR24 */
  584. 0xF3, 0xB6, 0xC0, 0xDD, 0x00, 0x0E, 0x17, 0x2C,
  585. 0x99, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  586. 0xC4, 0x32, 0x02, 0x01, 0x01,
  587. },
  588. { /* Init_SR30_SR75 */
  589. 0x38, 0x03, 0x20, 0x09, 0xC0, 0x3A, 0x3A, 0x3A,
  590. 0x3A, 0x3A, 0x3A, 0x3A, 0x00, 0x00, 0x03, 0xFF,
  591. 0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
  592. 0x20, 0x0C, 0x44, 0x20, 0x00, 0x00, 0x00, 0x3A,
  593. 0x06, 0x68, 0xA7, 0x7F, 0x83, 0x24, 0xFF, 0x03,
  594. 0x00, 0x60, 0x59, 0x3A, 0x3A, 0x00, 0x00, 0x3A,
  595. 0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
  596. 0x50, 0x03, 0x74, 0x14, 0x3B, 0x0D, 0x09, 0x02,
  597. 0x04, 0x45, 0x30, 0x30, 0x40, 0x20,
  598. },
  599. { /* Init_SR80_SR93 */
  600. 0xFF, 0x07, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x3A,
  601. 0xF7, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3A, 0x3A,
  602. 0x00, 0x00, 0x00, 0x00,
  603. },
  604. { /* Init_SRA0_SRAF */
  605. 0x00, 0xFB, 0x9F, 0x01, 0x00, 0xED, 0xED, 0xED,
  606. 0x7B, 0xFB, 0xFF, 0xFF, 0x97, 0xEF, 0xBF, 0xDF,
  607. },
  608. { /* Init_GR00_GR08 */
  609. 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
  610. 0xFF,
  611. },
  612. { /* Init_AR00_AR14 */
  613. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  614. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  615. 0x41, 0x00, 0x0F, 0x00, 0x00,
  616. },
  617. { /* Init_CR00_CR18 */
  618. 0xA3, 0x7F, 0x7F, 0x00, 0x85, 0x16, 0x24, 0xF5,
  619. 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  620. 0x03, 0x09, 0xFF, 0x80, 0x40, 0xFF, 0x00, 0xE3,
  621. 0xFF,
  622. },
  623. { /* Init_CR30_CR4D */
  624. 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20,
  625. 0x00, 0x00, 0x00, 0x40, 0x00, 0xFF, 0xBF, 0xFF,
  626. 0xA3, 0x7F, 0x00, 0x86, 0x15, 0x24, 0xFF, 0x00,
  627. 0x01, 0x07, 0xE5, 0x20, 0x7F, 0xFF,
  628. },
  629. { /* Init_CR90_CRA7 */
  630. 0x55, 0xD9, 0x5D, 0xE1, 0x86, 0x1B, 0x8E, 0x26,
  631. 0xDA, 0x8D, 0xDE, 0x94, 0x00, 0x00, 0x18, 0x00,
  632. 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03,
  633. },
  634. },
  635. { /* mode#6: 320 x 240 16Bpp 60Hz */
  636. 320, 240, 16, 60,
  637. /* Init_MISC */
  638. 0xEB,
  639. { /* Init_SR0_SR4 */
  640. 0x03, 0x01, 0x0F, 0x03, 0x0E,
  641. },
  642. { /* Init_SR10_SR24 */
  643. 0xF3, 0xB6, 0xC0, 0xDD, 0x00, 0x0E, 0x17, 0x2C,
  644. 0x99, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  645. 0xC4, 0x32, 0x02, 0x01, 0x01,
  646. },
  647. { /* Init_SR30_SR75 */
  648. 0x38, 0x03, 0x20, 0x09, 0xC0, 0x3A, 0x3A, 0x3A,
  649. 0x3A, 0x3A, 0x3A, 0x3A, 0x00, 0x00, 0x03, 0xFF,
  650. 0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
  651. 0x20, 0x0C, 0x44, 0x20, 0x00, 0x00, 0x00, 0x3A,
  652. 0x06, 0x68, 0xA7, 0x7F, 0x83, 0x24, 0xFF, 0x03,
  653. 0x00, 0x60, 0x59, 0x3A, 0x3A, 0x00, 0x00, 0x3A,
  654. 0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
  655. 0x50, 0x03, 0x74, 0x14, 0x08, 0x43, 0x08, 0x43,
  656. 0x04, 0x45, 0x30, 0x30, 0x40, 0x20,
  657. },
  658. { /* Init_SR80_SR93 */
  659. 0xFF, 0x07, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x3A,
  660. 0xF7, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3A, 0x3A,
  661. 0x00, 0x00, 0x00, 0x00,
  662. },
  663. { /* Init_SRA0_SRAF */
  664. 0x00, 0xFB, 0x9F, 0x01, 0x00, 0xED, 0xED, 0xED,
  665. 0x7B, 0xFB, 0xFF, 0xFF, 0x97, 0xEF, 0xBF, 0xDF,
  666. },
  667. { /* Init_GR00_GR08 */
  668. 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
  669. 0xFF,
  670. },
  671. { /* Init_AR00_AR14 */
  672. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  673. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  674. 0x41, 0x00, 0x0F, 0x00, 0x00,
  675. },
  676. { /* Init_CR00_CR18 */
  677. 0xA3, 0x7F, 0x7F, 0x00, 0x85, 0x16, 0x24, 0xF5,
  678. 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  679. 0x03, 0x09, 0xFF, 0x80, 0x40, 0xFF, 0x00, 0xE3,
  680. 0xFF,
  681. },
  682. { /* Init_CR30_CR4D */
  683. 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20,
  684. 0x00, 0x00, 0x30, 0x40, 0x00, 0xFF, 0xBF, 0xFF,
  685. 0x2E, 0x27, 0x00, 0x2b, 0x0c, 0x0F, 0xEF, 0x00,
  686. 0xFe, 0x0f, 0x01, 0xC0, 0x27, 0xEF,
  687. },
  688. { /* Init_CR90_CRA7 */
  689. 0x55, 0xD9, 0x5D, 0xE1, 0x86, 0x1B, 0x8E, 0x26,
  690. 0xDA, 0x8D, 0xDE, 0x94, 0x00, 0x00, 0x18, 0x00,
  691. 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03,
  692. },
  693. },
  694. { /* mode#8: 320 x 240 32Bpp 60Hz */
  695. 320, 240, 32, 60,
  696. /* Init_MISC */
  697. 0xEB,
  698. { /* Init_SR0_SR4 */
  699. 0x03, 0x01, 0x0F, 0x03, 0x0E,
  700. },
  701. { /* Init_SR10_SR24 */
  702. 0xF3, 0xB6, 0xC0, 0xDD, 0x00, 0x0E, 0x17, 0x2C,
  703. 0x99, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  704. 0xC4, 0x32, 0x02, 0x01, 0x01,
  705. },
  706. { /* Init_SR30_SR75 */
  707. 0x38, 0x03, 0x20, 0x09, 0xC0, 0x3A, 0x3A, 0x3A,
  708. 0x3A, 0x3A, 0x3A, 0x3A, 0x00, 0x00, 0x03, 0xFF,
  709. 0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
  710. 0x20, 0x0C, 0x44, 0x20, 0x00, 0x00, 0x00, 0x3A,
  711. 0x06, 0x68, 0xA7, 0x7F, 0x83, 0x24, 0xFF, 0x03,
  712. 0x00, 0x60, 0x59, 0x3A, 0x3A, 0x00, 0x00, 0x3A,
  713. 0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
  714. 0x50, 0x03, 0x74, 0x14, 0x08, 0x43, 0x08, 0x43,
  715. 0x04, 0x45, 0x30, 0x30, 0x40, 0x20,
  716. },
  717. { /* Init_SR80_SR93 */
  718. 0xFF, 0x07, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x3A,
  719. 0xF7, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3A, 0x3A,
  720. 0x00, 0x00, 0x00, 0x00,
  721. },
  722. { /* Init_SRA0_SRAF */
  723. 0x00, 0xFB, 0x9F, 0x01, 0x00, 0xED, 0xED, 0xED,
  724. 0x7B, 0xFB, 0xFF, 0xFF, 0x97, 0xEF, 0xBF, 0xDF,
  725. },
  726. { /* Init_GR00_GR08 */
  727. 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
  728. 0xFF,
  729. },
  730. { /* Init_AR00_AR14 */
  731. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  732. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
  733. 0x41, 0x00, 0x0F, 0x00, 0x00,
  734. },
  735. { /* Init_CR00_CR18 */
  736. 0xA3, 0x7F, 0x7F, 0x00, 0x85, 0x16, 0x24, 0xF5,
  737. 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  738. 0x03, 0x09, 0xFF, 0x80, 0x40, 0xFF, 0x00, 0xE3,
  739. 0xFF,
  740. },
  741. { /* Init_CR30_CR4D */
  742. 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20,
  743. 0x00, 0x00, 0x30, 0x40, 0x00, 0xFF, 0xBF, 0xFF,
  744. 0x2E, 0x27, 0x00, 0x2b, 0x0c, 0x0F, 0xEF, 0x00,
  745. 0xFe, 0x0f, 0x01, 0xC0, 0x27, 0xEF,
  746. },
  747. { /* Init_CR90_CRA7 */
  748. 0x55, 0xD9, 0x5D, 0xE1, 0x86, 0x1B, 0x8E, 0x26,
  749. 0xDA, 0x8D, 0xDE, 0x94, 0x00, 0x00, 0x18, 0x00,
  750. 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03,
  751. },
  752. },
  753. };
  754. static struct screen_info smtc_scr_info;
  755. static char *mode_option;
  756. /* process command line options, get vga parameter */
  757. static void __init sm7xx_vga_setup(char *options)
  758. {
  759. int i;
  760. if (!options || !*options)
  761. return;
  762. smtc_scr_info.lfb_width = 0;
  763. smtc_scr_info.lfb_height = 0;
  764. smtc_scr_info.lfb_depth = 0;
  765. pr_debug("sm7xx_vga_setup = %s\n", options);
  766. for (i = 0; i < ARRAY_SIZE(vesa_mode_table); i++) {
  767. if (strstr(options, vesa_mode_table[i].index)) {
  768. smtc_scr_info.lfb_width = vesa_mode_table[i].lfb_width;
  769. smtc_scr_info.lfb_height =
  770. vesa_mode_table[i].lfb_height;
  771. smtc_scr_info.lfb_depth = vesa_mode_table[i].lfb_depth;
  772. return;
  773. }
  774. }
  775. }
  776. static void sm712_setpalette(int regno, unsigned red, unsigned green,
  777. unsigned blue, struct fb_info *info)
  778. {
  779. /* set bit 5:4 = 01 (write LCD RAM only) */
  780. smtc_seqw(0x66, (smtc_seqr(0x66) & 0xC3) | 0x10);
  781. smtc_mmiowb(regno, dac_reg);
  782. smtc_mmiowb(red >> 10, dac_val);
  783. smtc_mmiowb(green >> 10, dac_val);
  784. smtc_mmiowb(blue >> 10, dac_val);
  785. }
  786. /* chan_to_field
  787. *
  788. * convert a colour value into a field position
  789. *
  790. * from pxafb.c
  791. */
  792. static inline unsigned int chan_to_field(unsigned int chan,
  793. struct fb_bitfield *bf)
  794. {
  795. chan &= 0xffff;
  796. chan >>= 16 - bf->length;
  797. return chan << bf->offset;
  798. }
  799. static int smtc_blank(int blank_mode, struct fb_info *info)
  800. {
  801. /* clear DPMS setting */
  802. switch (blank_mode) {
  803. case FB_BLANK_UNBLANK:
  804. /* Screen On: HSync: On, VSync : On */
  805. smtc_seqw(0x01, (smtc_seqr(0x01) & (~0x20)));
  806. smtc_seqw(0x6a, 0x16);
  807. smtc_seqw(0x6b, 0x02);
  808. smtc_seqw(0x21, (smtc_seqr(0x21) & 0x77));
  809. smtc_seqw(0x22, (smtc_seqr(0x22) & (~0x30)));
  810. smtc_seqw(0x23, (smtc_seqr(0x23) & (~0xc0)));
  811. smtc_seqw(0x24, (smtc_seqr(0x24) | 0x01));
  812. smtc_seqw(0x31, (smtc_seqr(0x31) | 0x03));
  813. break;
  814. case FB_BLANK_NORMAL:
  815. /* Screen Off: HSync: On, VSync : On Soft blank */
  816. smtc_seqw(0x01, (smtc_seqr(0x01) & (~0x20)));
  817. smtc_seqw(0x6a, 0x16);
  818. smtc_seqw(0x6b, 0x02);
  819. smtc_seqw(0x22, (smtc_seqr(0x22) & (~0x30)));
  820. smtc_seqw(0x23, (smtc_seqr(0x23) & (~0xc0)));
  821. smtc_seqw(0x24, (smtc_seqr(0x24) | 0x01));
  822. smtc_seqw(0x31, ((smtc_seqr(0x31) & (~0x07)) | 0x00));
  823. break;
  824. case FB_BLANK_VSYNC_SUSPEND:
  825. /* Screen On: HSync: On, VSync : Off */
  826. smtc_seqw(0x01, (smtc_seqr(0x01) | 0x20));
  827. smtc_seqw(0x20, (smtc_seqr(0x20) & (~0xB0)));
  828. smtc_seqw(0x6a, 0x0c);
  829. smtc_seqw(0x6b, 0x02);
  830. smtc_seqw(0x21, (smtc_seqr(0x21) | 0x88));
  831. smtc_seqw(0x22, ((smtc_seqr(0x22) & (~0x30)) | 0x20));
  832. smtc_seqw(0x23, ((smtc_seqr(0x23) & (~0xc0)) | 0x20));
  833. smtc_seqw(0x24, (smtc_seqr(0x24) & (~0x01)));
  834. smtc_seqw(0x31, ((smtc_seqr(0x31) & (~0x07)) | 0x00));
  835. smtc_seqw(0x34, (smtc_seqr(0x34) | 0x80));
  836. break;
  837. case FB_BLANK_HSYNC_SUSPEND:
  838. /* Screen On: HSync: Off, VSync : On */
  839. smtc_seqw(0x01, (smtc_seqr(0x01) | 0x20));
  840. smtc_seqw(0x20, (smtc_seqr(0x20) & (~0xB0)));
  841. smtc_seqw(0x6a, 0x0c);
  842. smtc_seqw(0x6b, 0x02);
  843. smtc_seqw(0x21, (smtc_seqr(0x21) | 0x88));
  844. smtc_seqw(0x22, ((smtc_seqr(0x22) & (~0x30)) | 0x10));
  845. smtc_seqw(0x23, ((smtc_seqr(0x23) & (~0xc0)) | 0xD8));
  846. smtc_seqw(0x24, (smtc_seqr(0x24) & (~0x01)));
  847. smtc_seqw(0x31, ((smtc_seqr(0x31) & (~0x07)) | 0x00));
  848. smtc_seqw(0x34, (smtc_seqr(0x34) | 0x80));
  849. break;
  850. case FB_BLANK_POWERDOWN:
  851. /* Screen On: HSync: Off, VSync : Off */
  852. smtc_seqw(0x01, (smtc_seqr(0x01) | 0x20));
  853. smtc_seqw(0x20, (smtc_seqr(0x20) & (~0xB0)));
  854. smtc_seqw(0x6a, 0x0c);
  855. smtc_seqw(0x6b, 0x02);
  856. smtc_seqw(0x21, (smtc_seqr(0x21) | 0x88));
  857. smtc_seqw(0x22, ((smtc_seqr(0x22) & (~0x30)) | 0x30));
  858. smtc_seqw(0x23, ((smtc_seqr(0x23) & (~0xc0)) | 0xD8));
  859. smtc_seqw(0x24, (smtc_seqr(0x24) & (~0x01)));
  860. smtc_seqw(0x31, ((smtc_seqr(0x31) & (~0x07)) | 0x00));
  861. smtc_seqw(0x34, (smtc_seqr(0x34) | 0x80));
  862. break;
  863. default:
  864. return -EINVAL;
  865. }
  866. return 0;
  867. }
  868. static int smtc_setcolreg(unsigned regno, unsigned red, unsigned green,
  869. unsigned blue, unsigned trans, struct fb_info *info)
  870. {
  871. struct smtcfb_info *sfb;
  872. u32 val;
  873. sfb = info->par;
  874. if (regno > 255)
  875. return 1;
  876. switch (sfb->fb->fix.visual) {
  877. case FB_VISUAL_DIRECTCOLOR:
  878. case FB_VISUAL_TRUECOLOR:
  879. /*
  880. * 16/32 bit true-colour, use pseudo-palette for 16 base color
  881. */
  882. if (regno >= 16)
  883. break;
  884. if (sfb->fb->var.bits_per_pixel == 16) {
  885. u32 *pal = sfb->fb->pseudo_palette;
  886. val = chan_to_field(red, &sfb->fb->var.red);
  887. val |= chan_to_field(green, &sfb->fb->var.green);
  888. val |= chan_to_field(blue, &sfb->fb->var.blue);
  889. pal[regno] = pal_rgb(red, green, blue, val);
  890. } else {
  891. u32 *pal = sfb->fb->pseudo_palette;
  892. val = chan_to_field(red, &sfb->fb->var.red);
  893. val |= chan_to_field(green, &sfb->fb->var.green);
  894. val |= chan_to_field(blue, &sfb->fb->var.blue);
  895. pal[regno] = big_swap(val);
  896. }
  897. break;
  898. case FB_VISUAL_PSEUDOCOLOR:
  899. /* color depth 8 bit */
  900. sm712_setpalette(regno, red, green, blue, info);
  901. break;
  902. default:
  903. return 1; /* unknown type */
  904. }
  905. return 0;
  906. }
  907. static ssize_t smtcfb_read(struct fb_info *info, char __user *buf,
  908. size_t count, loff_t *ppos)
  909. {
  910. unsigned long p = *ppos;
  911. u32 *buffer, *dst;
  912. u32 __iomem *src;
  913. int c, i, cnt = 0, err = 0;
  914. unsigned long total_size;
  915. if (!info || !info->screen_base)
  916. return -ENODEV;
  917. if (info->state != FBINFO_STATE_RUNNING)
  918. return -EPERM;
  919. total_size = info->screen_size;
  920. if (total_size == 0)
  921. total_size = info->fix.smem_len;
  922. if (p >= total_size)
  923. return 0;
  924. if (count >= total_size)
  925. count = total_size;
  926. if (count + p > total_size)
  927. count = total_size - p;
  928. buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, GFP_KERNEL);
  929. if (!buffer)
  930. return -ENOMEM;
  931. src = (u32 __iomem *)(info->screen_base + p);
  932. if (info->fbops->fb_sync)
  933. info->fbops->fb_sync(info);
  934. while (count) {
  935. c = (count > PAGE_SIZE) ? PAGE_SIZE : count;
  936. dst = buffer;
  937. for (i = c >> 2; i--;) {
  938. *dst = fb_readl(src++);
  939. *dst = big_swap(*dst);
  940. dst++;
  941. }
  942. if (c & 3) {
  943. u8 *dst8 = (u8 *)dst;
  944. u8 __iomem *src8 = (u8 __iomem *)src;
  945. for (i = c & 3; i--;) {
  946. if (i & 1) {
  947. *dst8++ = fb_readb(++src8);
  948. } else {
  949. *dst8++ = fb_readb(--src8);
  950. src8 += 2;
  951. }
  952. }
  953. src = (u32 __iomem *)src8;
  954. }
  955. if (copy_to_user(buf, buffer, c)) {
  956. err = -EFAULT;
  957. break;
  958. }
  959. *ppos += c;
  960. buf += c;
  961. cnt += c;
  962. count -= c;
  963. }
  964. kfree(buffer);
  965. return (err) ? err : cnt;
  966. }
  967. static ssize_t smtcfb_write(struct fb_info *info, const char __user *buf,
  968. size_t count, loff_t *ppos)
  969. {
  970. unsigned long p = *ppos;
  971. u32 *buffer, *src;
  972. u32 __iomem *dst;
  973. int c, i, cnt = 0, err = 0;
  974. unsigned long total_size;
  975. if (!info || !info->screen_base)
  976. return -ENODEV;
  977. if (info->state != FBINFO_STATE_RUNNING)
  978. return -EPERM;
  979. total_size = info->screen_size;
  980. if (total_size == 0)
  981. total_size = info->fix.smem_len;
  982. if (p > total_size)
  983. return -EFBIG;
  984. if (count > total_size) {
  985. err = -EFBIG;
  986. count = total_size;
  987. }
  988. if (count + p > total_size) {
  989. if (!err)
  990. err = -ENOSPC;
  991. count = total_size - p;
  992. }
  993. buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, GFP_KERNEL);
  994. if (!buffer)
  995. return -ENOMEM;
  996. dst = (u32 __iomem *)(info->screen_base + p);
  997. if (info->fbops->fb_sync)
  998. info->fbops->fb_sync(info);
  999. while (count) {
  1000. c = (count > PAGE_SIZE) ? PAGE_SIZE : count;
  1001. src = buffer;
  1002. if (copy_from_user(src, buf, c)) {
  1003. err = -EFAULT;
  1004. break;
  1005. }
  1006. for (i = c >> 2; i--;) {
  1007. fb_writel(big_swap(*src), dst++);
  1008. src++;
  1009. }
  1010. if (c & 3) {
  1011. u8 *src8 = (u8 *)src;
  1012. u8 __iomem *dst8 = (u8 __iomem *)dst;
  1013. for (i = c & 3; i--;) {
  1014. if (i & 1) {
  1015. fb_writeb(*src8++, ++dst8);
  1016. } else {
  1017. fb_writeb(*src8++, --dst8);
  1018. dst8 += 2;
  1019. }
  1020. }
  1021. dst = (u32 __iomem *)dst8;
  1022. }
  1023. *ppos += c;
  1024. buf += c;
  1025. cnt += c;
  1026. count -= c;
  1027. }
  1028. kfree(buffer);
  1029. return (cnt) ? cnt : err;
  1030. }
  1031. static void sm7xx_set_timing(struct smtcfb_info *sfb)
  1032. {
  1033. int i = 0, j = 0;
  1034. u32 m_nscreenstride;
  1035. dev_dbg(&sfb->pdev->dev,
  1036. "sfb->width=%d sfb->height=%d sfb->fb->var.bits_per_pixel=%d sfb->hz=%d\n",
  1037. sfb->width, sfb->height, sfb->fb->var.bits_per_pixel, sfb->hz);
  1038. for (j = 0; j < ARRAY_SIZE(vgamode); j++) {
  1039. if (vgamode[j].mmsizex != sfb->width ||
  1040. vgamode[j].mmsizey != sfb->height ||
  1041. vgamode[j].bpp != sfb->fb->var.bits_per_pixel ||
  1042. vgamode[j].hz != sfb->hz)
  1043. continue;
  1044. dev_dbg(&sfb->pdev->dev,
  1045. "vgamode[j].mmsizex=%d vgamode[j].mmSizeY=%d vgamode[j].bpp=%d vgamode[j].hz=%d\n",
  1046. vgamode[j].mmsizex, vgamode[j].mmsizey,
  1047. vgamode[j].bpp, vgamode[j].hz);
  1048. dev_dbg(&sfb->pdev->dev, "vgamode index=%d\n", j);
  1049. smtc_mmiowb(0x0, 0x3c6);
  1050. smtc_seqw(0, 0x1);
  1051. smtc_mmiowb(vgamode[j].init_misc, 0x3c2);
  1052. /* init SEQ register SR00 - SR04 */
  1053. for (i = 0; i < SIZE_SR00_SR04; i++)
  1054. smtc_seqw(i, vgamode[j].init_sr00_sr04[i]);
  1055. /* init SEQ register SR10 - SR24 */
  1056. for (i = 0; i < SIZE_SR10_SR24; i++)
  1057. smtc_seqw(i + 0x10, vgamode[j].init_sr10_sr24[i]);
  1058. /* init SEQ register SR30 - SR75 */
  1059. for (i = 0; i < SIZE_SR30_SR75; i++)
  1060. if ((i + 0x30) != 0x62 && (i + 0x30) != 0x6a &&
  1061. (i + 0x30) != 0x6b)
  1062. smtc_seqw(i + 0x30,
  1063. vgamode[j].init_sr30_sr75[i]);
  1064. /* init SEQ register SR80 - SR93 */
  1065. for (i = 0; i < SIZE_SR80_SR93; i++)
  1066. smtc_seqw(i + 0x80, vgamode[j].init_sr80_sr93[i]);
  1067. /* init SEQ register SRA0 - SRAF */
  1068. for (i = 0; i < SIZE_SRA0_SRAF; i++)
  1069. smtc_seqw(i + 0xa0, vgamode[j].init_sra0_sraf[i]);
  1070. /* init Graphic register GR00 - GR08 */
  1071. for (i = 0; i < SIZE_GR00_GR08; i++)
  1072. smtc_grphw(i, vgamode[j].init_gr00_gr08[i]);
  1073. /* init Attribute register AR00 - AR14 */
  1074. for (i = 0; i < SIZE_AR00_AR14; i++)
  1075. smtc_attrw(i, vgamode[j].init_ar00_ar14[i]);
  1076. /* init CRTC register CR00 - CR18 */
  1077. for (i = 0; i < SIZE_CR00_CR18; i++)
  1078. smtc_crtcw(i, vgamode[j].init_cr00_cr18[i]);
  1079. /* init CRTC register CR30 - CR4D */
  1080. for (i = 0; i < SIZE_CR30_CR4D; i++)
  1081. smtc_crtcw(i + 0x30, vgamode[j].init_cr30_cr4d[i]);
  1082. /* init CRTC register CR90 - CRA7 */
  1083. for (i = 0; i < SIZE_CR90_CRA7; i++)
  1084. smtc_crtcw(i + 0x90, vgamode[j].init_cr90_cra7[i]);
  1085. }
  1086. smtc_mmiowb(0x67, 0x3c2);
  1087. /* set VPR registers */
  1088. writel(0x0, sfb->vp_regs + 0x0C);
  1089. writel(0x0, sfb->vp_regs + 0x40);
  1090. /* set data width */
  1091. m_nscreenstride = (sfb->width * sfb->fb->var.bits_per_pixel) / 64;
  1092. switch (sfb->fb->var.bits_per_pixel) {
  1093. case 8:
  1094. writel(0x0, sfb->vp_regs + 0x0);
  1095. break;
  1096. case 16:
  1097. writel(0x00020000, sfb->vp_regs + 0x0);
  1098. break;
  1099. case 24:
  1100. writel(0x00040000, sfb->vp_regs + 0x0);
  1101. break;
  1102. case 32:
  1103. writel(0x00030000, sfb->vp_regs + 0x0);
  1104. break;
  1105. }
  1106. writel((u32)(((m_nscreenstride + 2) << 16) | m_nscreenstride),
  1107. sfb->vp_regs + 0x10);
  1108. }
  1109. static void smtc_set_timing(struct smtcfb_info *sfb)
  1110. {
  1111. switch (sfb->chip_id) {
  1112. case 0x710:
  1113. case 0x712:
  1114. case 0x720:
  1115. sm7xx_set_timing(sfb);
  1116. break;
  1117. }
  1118. }
  1119. static void smtcfb_setmode(struct smtcfb_info *sfb)
  1120. {
  1121. switch (sfb->fb->var.bits_per_pixel) {
  1122. case 32:
  1123. sfb->fb->fix.visual = FB_VISUAL_TRUECOLOR;
  1124. sfb->fb->fix.line_length = sfb->fb->var.xres * 4;
  1125. sfb->fb->var.red.length = 8;
  1126. sfb->fb->var.green.length = 8;
  1127. sfb->fb->var.blue.length = 8;
  1128. sfb->fb->var.red.offset = 16;
  1129. sfb->fb->var.green.offset = 8;
  1130. sfb->fb->var.blue.offset = 0;
  1131. break;
  1132. case 24:
  1133. sfb->fb->fix.visual = FB_VISUAL_TRUECOLOR;
  1134. sfb->fb->fix.line_length = sfb->fb->var.xres * 3;
  1135. sfb->fb->var.red.length = 8;
  1136. sfb->fb->var.green.length = 8;
  1137. sfb->fb->var.blue.length = 8;
  1138. sfb->fb->var.red.offset = 16;
  1139. sfb->fb->var.green.offset = 8;
  1140. sfb->fb->var.blue.offset = 0;
  1141. break;
  1142. case 8:
  1143. sfb->fb->fix.visual = FB_VISUAL_PSEUDOCOLOR;
  1144. sfb->fb->fix.line_length = sfb->fb->var.xres;
  1145. sfb->fb->var.red.length = 3;
  1146. sfb->fb->var.green.length = 3;
  1147. sfb->fb->var.blue.length = 2;
  1148. sfb->fb->var.red.offset = 5;
  1149. sfb->fb->var.green.offset = 2;
  1150. sfb->fb->var.blue.offset = 0;
  1151. break;
  1152. case 16:
  1153. default:
  1154. sfb->fb->fix.visual = FB_VISUAL_TRUECOLOR;
  1155. sfb->fb->fix.line_length = sfb->fb->var.xres * 2;
  1156. sfb->fb->var.red.length = 5;
  1157. sfb->fb->var.green.length = 6;
  1158. sfb->fb->var.blue.length = 5;
  1159. sfb->fb->var.red.offset = 11;
  1160. sfb->fb->var.green.offset = 5;
  1161. sfb->fb->var.blue.offset = 0;
  1162. break;
  1163. }
  1164. sfb->width = sfb->fb->var.xres;
  1165. sfb->height = sfb->fb->var.yres;
  1166. sfb->hz = 60;
  1167. smtc_set_timing(sfb);
  1168. }
  1169. static int smtc_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
  1170. {
  1171. /* sanity checks */
  1172. if (var->xres_virtual < var->xres)
  1173. var->xres_virtual = var->xres;
  1174. if (var->yres_virtual < var->yres)
  1175. var->yres_virtual = var->yres;
  1176. /* set valid default bpp */
  1177. if ((var->bits_per_pixel != 8) && (var->bits_per_pixel != 16) &&
  1178. (var->bits_per_pixel != 24) && (var->bits_per_pixel != 32))
  1179. var->bits_per_pixel = 16;
  1180. return 0;
  1181. }
  1182. static int smtc_set_par(struct fb_info *info)
  1183. {
  1184. smtcfb_setmode(info->par);
  1185. return 0;
  1186. }
  1187. static struct fb_ops smtcfb_ops = {
  1188. .owner = THIS_MODULE,
  1189. .fb_check_var = smtc_check_var,
  1190. .fb_set_par = smtc_set_par,
  1191. .fb_setcolreg = smtc_setcolreg,
  1192. .fb_blank = smtc_blank,
  1193. .fb_fillrect = cfb_fillrect,
  1194. .fb_imageblit = cfb_imageblit,
  1195. .fb_copyarea = cfb_copyarea,
  1196. .fb_read = smtcfb_read,
  1197. .fb_write = smtcfb_write,
  1198. };
  1199. /*
  1200. * Unmap in the memory mapped IO registers
  1201. */
  1202. static void smtc_unmap_mmio(struct smtcfb_info *sfb)
  1203. {
  1204. if (sfb && smtc_regbaseaddress)
  1205. smtc_regbaseaddress = NULL;
  1206. }
  1207. /*
  1208. * Map in the screen memory
  1209. */
  1210. static int smtc_map_smem(struct smtcfb_info *sfb,
  1211. struct pci_dev *pdev, u_long smem_len)
  1212. {
  1213. sfb->fb->fix.smem_start = pci_resource_start(pdev, 0);
  1214. if (sfb->fb->var.bits_per_pixel == 32)
  1215. sfb->fb->fix.smem_start += big_addr;
  1216. sfb->fb->fix.smem_len = smem_len;
  1217. sfb->fb->screen_base = sfb->lfb;
  1218. if (!sfb->fb->screen_base) {
  1219. dev_err(&pdev->dev,
  1220. "%s: unable to map screen memory\n", sfb->fb->fix.id);
  1221. return -ENOMEM;
  1222. }
  1223. return 0;
  1224. }
  1225. /*
  1226. * Unmap in the screen memory
  1227. *
  1228. */
  1229. static void smtc_unmap_smem(struct smtcfb_info *sfb)
  1230. {
  1231. if (sfb && sfb->fb->screen_base) {
  1232. iounmap(sfb->fb->screen_base);
  1233. sfb->fb->screen_base = NULL;
  1234. }
  1235. }
  1236. /*
  1237. * We need to wake up the device and make sure its in linear memory mode.
  1238. */
  1239. static inline void sm7xx_init_hw(void)
  1240. {
  1241. outb_p(0x18, 0x3c4);
  1242. outb_p(0x11, 0x3c5);
  1243. }
  1244. static int smtcfb_pci_probe(struct pci_dev *pdev,
  1245. const struct pci_device_id *ent)
  1246. {
  1247. struct smtcfb_info *sfb;
  1248. struct fb_info *info;
  1249. u_long smem_size = 0x00800000; /* default 8MB */
  1250. int err;
  1251. unsigned long mmio_base;
  1252. dev_info(&pdev->dev, "Silicon Motion display driver.\n");
  1253. err = pci_enable_device(pdev); /* enable SMTC chip */
  1254. if (err)
  1255. return err;
  1256. err = pci_request_region(pdev, 0, "sm7xxfb");
  1257. if (err < 0) {
  1258. dev_err(&pdev->dev, "cannot reserve framebuffer region\n");
  1259. goto failed_regions;
  1260. }
  1261. sprintf(smtcfb_fix.id, "sm%Xfb", ent->device);
  1262. info = framebuffer_alloc(sizeof(*sfb), &pdev->dev);
  1263. if (!info) {
  1264. dev_err(&pdev->dev, "framebuffer_alloc failed\n");
  1265. err = -ENOMEM;
  1266. goto failed_free;
  1267. }
  1268. sfb = info->par;
  1269. sfb->fb = info;
  1270. sfb->chip_id = ent->device;
  1271. sfb->pdev = pdev;
  1272. info->flags = FBINFO_FLAG_DEFAULT;
  1273. info->fbops = &smtcfb_ops;
  1274. info->fix = smtcfb_fix;
  1275. info->var = smtcfb_var;
  1276. info->pseudo_palette = sfb->colreg;
  1277. info->par = sfb;
  1278. pci_set_drvdata(pdev, sfb);
  1279. sm7xx_init_hw();
  1280. /* get mode parameter from smtc_scr_info */
  1281. if (smtc_scr_info.lfb_width != 0) {
  1282. sfb->fb->var.xres = smtc_scr_info.lfb_width;
  1283. sfb->fb->var.yres = smtc_scr_info.lfb_height;
  1284. sfb->fb->var.bits_per_pixel = smtc_scr_info.lfb_depth;
  1285. } else {
  1286. /* default resolution 1024x600 16bit mode */
  1287. sfb->fb->var.xres = SCREEN_X_RES;
  1288. sfb->fb->var.yres = SCREEN_Y_RES;
  1289. sfb->fb->var.bits_per_pixel = SCREEN_BPP;
  1290. }
  1291. big_pixel_depth(sfb->fb->var.bits_per_pixel, smtc_scr_info.lfb_depth);
  1292. /* Map address and memory detection */
  1293. mmio_base = pci_resource_start(pdev, 0);
  1294. pci_read_config_byte(pdev, PCI_REVISION_ID, &sfb->chip_rev_id);
  1295. switch (sfb->chip_id) {
  1296. case 0x710:
  1297. case 0x712:
  1298. sfb->fb->fix.mmio_start = mmio_base + 0x00400000;
  1299. sfb->fb->fix.mmio_len = 0x00400000;
  1300. smem_size = SM712_VIDEOMEMORYSIZE;
  1301. sfb->lfb = ioremap(mmio_base, mmio_addr);
  1302. if (!sfb->lfb) {
  1303. dev_err(&pdev->dev,
  1304. "%s: unable to map memory mapped IO!\n",
  1305. sfb->fb->fix.id);
  1306. err = -ENOMEM;
  1307. goto failed_fb;
  1308. }
  1309. sfb->mmio = (smtc_regbaseaddress =
  1310. sfb->lfb + 0x00700000);
  1311. sfb->dp_regs = sfb->lfb + 0x00408000;
  1312. sfb->vp_regs = sfb->lfb + 0x0040c000;
  1313. if (sfb->fb->var.bits_per_pixel == 32) {
  1314. sfb->lfb += big_addr;
  1315. dev_info(&pdev->dev, "sfb->lfb=%p\n", sfb->lfb);
  1316. }
  1317. /* set MCLK = 14.31818 * (0x16 / 0x2) */
  1318. smtc_seqw(0x6a, 0x16);
  1319. smtc_seqw(0x6b, 0x02);
  1320. smtc_seqw(0x62, 0x3e);
  1321. /* enable PCI burst */
  1322. smtc_seqw(0x17, 0x20);
  1323. /* enable word swap */
  1324. if (sfb->fb->var.bits_per_pixel == 32)
  1325. seqw17();
  1326. break;
  1327. case 0x720:
  1328. sfb->fb->fix.mmio_start = mmio_base;
  1329. sfb->fb->fix.mmio_len = 0x00200000;
  1330. smem_size = SM722_VIDEOMEMORYSIZE;
  1331. sfb->dp_regs = ioremap(mmio_base, 0x00a00000);
  1332. sfb->lfb = sfb->dp_regs + 0x00200000;
  1333. sfb->mmio = (smtc_regbaseaddress =
  1334. sfb->dp_regs + 0x000c0000);
  1335. sfb->vp_regs = sfb->dp_regs + 0x800;
  1336. smtc_seqw(0x62, 0xff);
  1337. smtc_seqw(0x6a, 0x0d);
  1338. smtc_seqw(0x6b, 0x02);
  1339. break;
  1340. default:
  1341. dev_err(&pdev->dev,
  1342. "No valid Silicon Motion display chip was detected!\n");
  1343. goto failed_fb;
  1344. }
  1345. /* can support 32 bpp */
  1346. if (15 == sfb->fb->var.bits_per_pixel)
  1347. sfb->fb->var.bits_per_pixel = 16;
  1348. sfb->fb->var.xres_virtual = sfb->fb->var.xres;
  1349. sfb->fb->var.yres_virtual = sfb->fb->var.yres;
  1350. err = smtc_map_smem(sfb, pdev, smem_size);
  1351. if (err)
  1352. goto failed;
  1353. smtcfb_setmode(sfb);
  1354. err = register_framebuffer(info);
  1355. if (err < 0)
  1356. goto failed;
  1357. dev_info(&pdev->dev,
  1358. "Silicon Motion SM%X Rev%X primary display mode %dx%d-%d Init Complete.\n",
  1359. sfb->chip_id, sfb->chip_rev_id, sfb->fb->var.xres,
  1360. sfb->fb->var.yres, sfb->fb->var.bits_per_pixel);
  1361. return 0;
  1362. failed:
  1363. dev_err(&pdev->dev, "Silicon Motion, Inc. primary display init fail.\n");
  1364. smtc_unmap_smem(sfb);
  1365. smtc_unmap_mmio(sfb);
  1366. failed_fb:
  1367. framebuffer_release(info);
  1368. failed_free:
  1369. pci_release_region(pdev, 0);
  1370. failed_regions:
  1371. pci_disable_device(pdev);
  1372. return err;
  1373. }
  1374. /*
  1375. * 0x710 (LynxEM)
  1376. * 0x712 (LynxEM+)
  1377. * 0x720 (Lynx3DM, Lynx3DM+)
  1378. */
  1379. static const struct pci_device_id smtcfb_pci_table[] = {
  1380. { PCI_DEVICE(0x126f, 0x710), },
  1381. { PCI_DEVICE(0x126f, 0x712), },
  1382. { PCI_DEVICE(0x126f, 0x720), },
  1383. {0,}
  1384. };
  1385. MODULE_DEVICE_TABLE(pci, smtcfb_pci_table);
  1386. static void smtcfb_pci_remove(struct pci_dev *pdev)
  1387. {
  1388. struct smtcfb_info *sfb;
  1389. sfb = pci_get_drvdata(pdev);
  1390. smtc_unmap_smem(sfb);
  1391. smtc_unmap_mmio(sfb);
  1392. unregister_framebuffer(sfb->fb);
  1393. framebuffer_release(sfb->fb);
  1394. pci_release_region(pdev, 0);
  1395. pci_disable_device(pdev);
  1396. }
  1397. static int __maybe_unused smtcfb_pci_suspend(struct device *device)
  1398. {
  1399. struct pci_dev *pdev = to_pci_dev(device);
  1400. struct smtcfb_info *sfb;
  1401. sfb = pci_get_drvdata(pdev);
  1402. /* set the hw in sleep mode use external clock and self memory refresh
  1403. * so that we can turn off internal PLLs later on
  1404. */
  1405. smtc_seqw(0x20, (smtc_seqr(0x20) | 0xc0));
  1406. smtc_seqw(0x69, (smtc_seqr(0x69) & 0xf7));
  1407. console_lock();
  1408. fb_set_suspend(sfb->fb, 1);
  1409. console_unlock();
  1410. /* additionally turn off all function blocks including internal PLLs */
  1411. smtc_seqw(0x21, 0xff);
  1412. return 0;
  1413. }
  1414. static int __maybe_unused smtcfb_pci_resume(struct device *device)
  1415. {
  1416. struct pci_dev *pdev = to_pci_dev(device);
  1417. struct smtcfb_info *sfb;
  1418. sfb = pci_get_drvdata(pdev);
  1419. /* reinit hardware */
  1420. sm7xx_init_hw();
  1421. switch (sfb->chip_id) {
  1422. case 0x710:
  1423. case 0x712:
  1424. /* set MCLK = 14.31818 * (0x16 / 0x2) */
  1425. smtc_seqw(0x6a, 0x16);
  1426. smtc_seqw(0x6b, 0x02);
  1427. smtc_seqw(0x62, 0x3e);
  1428. /* enable PCI burst */
  1429. smtc_seqw(0x17, 0x20);
  1430. if (sfb->fb->var.bits_per_pixel == 32)
  1431. seqw17();
  1432. break;
  1433. case 0x720:
  1434. smtc_seqw(0x62, 0xff);
  1435. smtc_seqw(0x6a, 0x0d);
  1436. smtc_seqw(0x6b, 0x02);
  1437. break;
  1438. }
  1439. smtc_seqw(0x34, (smtc_seqr(0x34) | 0xc0));
  1440. smtc_seqw(0x33, ((smtc_seqr(0x33) | 0x08) & 0xfb));
  1441. smtcfb_setmode(sfb);
  1442. console_lock();
  1443. fb_set_suspend(sfb->fb, 0);
  1444. console_unlock();
  1445. return 0;
  1446. }
  1447. static SIMPLE_DEV_PM_OPS(sm7xx_pm_ops, smtcfb_pci_suspend, smtcfb_pci_resume);
  1448. static struct pci_driver smtcfb_driver = {
  1449. .name = "smtcfb",
  1450. .id_table = smtcfb_pci_table,
  1451. .probe = smtcfb_pci_probe,
  1452. .remove = smtcfb_pci_remove,
  1453. .driver.pm = &sm7xx_pm_ops,
  1454. };
  1455. static int __init sm712fb_init(void)
  1456. {
  1457. char *option = NULL;
  1458. if (fb_get_options("sm712fb", &option))
  1459. return -ENODEV;
  1460. if (option && *option)
  1461. mode_option = option;
  1462. sm7xx_vga_setup(mode_option);
  1463. return pci_register_driver(&smtcfb_driver);
  1464. }
  1465. module_init(sm712fb_init);
  1466. static void __exit sm712fb_exit(void)
  1467. {
  1468. pci_unregister_driver(&smtcfb_driver);
  1469. }
  1470. module_exit(sm712fb_exit);
  1471. MODULE_AUTHOR("Siliconmotion ");
  1472. MODULE_DESCRIPTION("Framebuffer driver for SMI Graphic Cards");
  1473. MODULE_LICENSE("GPL");