sm712fb.c 48 KB

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