sm7xxfb.c 45 KB

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