s3c-fb.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844
  1. /* linux/drivers/video/s3c-fb.c
  2. *
  3. * Copyright 2008 Openmoko Inc.
  4. * Copyright 2008-2010 Simtec Electronics
  5. * Ben Dooks <ben@simtec.co.uk>
  6. * http://armlinux.simtec.co.uk/
  7. *
  8. * Samsung SoC Framebuffer driver
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software FoundatIon.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/dma-mapping.h>
  18. #include <linux/slab.h>
  19. #include <linux/init.h>
  20. #include <linux/clk.h>
  21. #include <linux/fb.h>
  22. #include <linux/io.h>
  23. #include <linux/uaccess.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/pm_runtime.h>
  26. #include <mach/map.h>
  27. #include <plat/regs-fb-v4.h>
  28. #include <plat/fb.h>
  29. /* This driver will export a number of framebuffer interfaces depending
  30. * on the configuration passed in via the platform data. Each fb instance
  31. * maps to a hardware window. Currently there is no support for runtime
  32. * setting of the alpha-blending functions that each window has, so only
  33. * window 0 is actually useful.
  34. *
  35. * Window 0 is treated specially, it is used for the basis of the LCD
  36. * output timings and as the control for the output power-down state.
  37. */
  38. /* note, the previous use of <mach/regs-fb.h> to get platform specific data
  39. * has been replaced by using the platform device name to pick the correct
  40. * configuration data for the system.
  41. */
  42. #ifdef CONFIG_FB_S3C_DEBUG_REGWRITE
  43. #undef writel
  44. #define writel(v, r) do { \
  45. printk(KERN_DEBUG "%s: %08x => %p\n", __func__, (unsigned int)v, r); \
  46. __raw_writel(v, r); } while(0)
  47. #endif /* FB_S3C_DEBUG_REGWRITE */
  48. /* irq_flags bits */
  49. #define S3C_FB_VSYNC_IRQ_EN 0
  50. #define VSYNC_TIMEOUT_MSEC 50
  51. struct s3c_fb;
  52. #define VALID_BPP(x) (1 << ((x) - 1))
  53. #define OSD_BASE(win, variant) ((variant).osd + ((win) * (variant).osd_stride))
  54. #define VIDOSD_A(win, variant) (OSD_BASE(win, variant) + 0x00)
  55. #define VIDOSD_B(win, variant) (OSD_BASE(win, variant) + 0x04)
  56. #define VIDOSD_C(win, variant) (OSD_BASE(win, variant) + 0x08)
  57. #define VIDOSD_D(win, variant) (OSD_BASE(win, variant) + 0x0C)
  58. /**
  59. * struct s3c_fb_variant - fb variant information
  60. * @is_2443: Set if S3C2443/S3C2416 style hardware.
  61. * @nr_windows: The number of windows.
  62. * @vidtcon: The base for the VIDTCONx registers
  63. * @wincon: The base for the WINxCON registers.
  64. * @winmap: The base for the WINxMAP registers.
  65. * @keycon: The abse for the WxKEYCON registers.
  66. * @buf_start: Offset of buffer start registers.
  67. * @buf_size: Offset of buffer size registers.
  68. * @buf_end: Offset of buffer end registers.
  69. * @osd: The base for the OSD registers.
  70. * @palette: Address of palette memory, or 0 if none.
  71. * @has_prtcon: Set if has PRTCON register.
  72. * @has_shadowcon: Set if has SHADOWCON register.
  73. */
  74. struct s3c_fb_variant {
  75. unsigned int is_2443:1;
  76. unsigned short nr_windows;
  77. unsigned short vidtcon;
  78. unsigned short wincon;
  79. unsigned short winmap;
  80. unsigned short keycon;
  81. unsigned short buf_start;
  82. unsigned short buf_end;
  83. unsigned short buf_size;
  84. unsigned short osd;
  85. unsigned short osd_stride;
  86. unsigned short palette[S3C_FB_MAX_WIN];
  87. unsigned int has_prtcon:1;
  88. unsigned int has_shadowcon:1;
  89. };
  90. /**
  91. * struct s3c_fb_win_variant
  92. * @has_osd_c: Set if has OSD C register.
  93. * @has_osd_d: Set if has OSD D register.
  94. * @has_osd_alpha: Set if can change alpha transparency for a window.
  95. * @palette_sz: Size of palette in entries.
  96. * @palette_16bpp: Set if palette is 16bits wide.
  97. * @osd_size_off: If != 0, supports setting up OSD for a window; the appropriate
  98. * register is located at the given offset from OSD_BASE.
  99. * @valid_bpp: 1 bit per BPP setting to show valid bits-per-pixel.
  100. *
  101. * valid_bpp bit x is set if (x+1)BPP is supported.
  102. */
  103. struct s3c_fb_win_variant {
  104. unsigned int has_osd_c:1;
  105. unsigned int has_osd_d:1;
  106. unsigned int has_osd_alpha:1;
  107. unsigned int palette_16bpp:1;
  108. unsigned short osd_size_off;
  109. unsigned short palette_sz;
  110. u32 valid_bpp;
  111. };
  112. /**
  113. * struct s3c_fb_driverdata - per-device type driver data for init time.
  114. * @variant: The variant information for this driver.
  115. * @win: The window information for each window.
  116. */
  117. struct s3c_fb_driverdata {
  118. struct s3c_fb_variant variant;
  119. struct s3c_fb_win_variant *win[S3C_FB_MAX_WIN];
  120. };
  121. /**
  122. * struct s3c_fb_palette - palette information
  123. * @r: Red bitfield.
  124. * @g: Green bitfield.
  125. * @b: Blue bitfield.
  126. * @a: Alpha bitfield.
  127. */
  128. struct s3c_fb_palette {
  129. struct fb_bitfield r;
  130. struct fb_bitfield g;
  131. struct fb_bitfield b;
  132. struct fb_bitfield a;
  133. };
  134. /**
  135. * struct s3c_fb_win - per window private data for each framebuffer.
  136. * @windata: The platform data supplied for the window configuration.
  137. * @parent: The hardware that this window is part of.
  138. * @fbinfo: Pointer pack to the framebuffer info for this window.
  139. * @varint: The variant information for this window.
  140. * @palette_buffer: Buffer/cache to hold palette entries.
  141. * @pseudo_palette: For use in TRUECOLOUR modes for entries 0..15/
  142. * @index: The window number of this window.
  143. * @palette: The bitfields for changing r/g/b into a hardware palette entry.
  144. */
  145. struct s3c_fb_win {
  146. struct s3c_fb_pd_win *windata;
  147. struct s3c_fb *parent;
  148. struct fb_info *fbinfo;
  149. struct s3c_fb_palette palette;
  150. struct s3c_fb_win_variant variant;
  151. u32 *palette_buffer;
  152. u32 pseudo_palette[16];
  153. unsigned int index;
  154. };
  155. /**
  156. * struct s3c_fb_vsync - vsync information
  157. * @wait: a queue for processes waiting for vsync
  158. * @count: vsync interrupt count
  159. */
  160. struct s3c_fb_vsync {
  161. wait_queue_head_t wait;
  162. unsigned int count;
  163. };
  164. /**
  165. * struct s3c_fb - overall hardware state of the hardware
  166. * @dev: The device that we bound to, for printing, etc.
  167. * @regs_res: The resource we claimed for the IO registers.
  168. * @bus_clk: The clk (hclk) feeding our interface and possibly pixclk.
  169. * @regs: The mapped hardware registers.
  170. * @variant: Variant information for this hardware.
  171. * @enabled: A bitmask of enabled hardware windows.
  172. * @pdata: The platform configuration data passed with the device.
  173. * @windows: The hardware windows that have been claimed.
  174. * @irq_no: IRQ line number
  175. * @irq_flags: irq flags
  176. * @vsync_info: VSYNC-related information (count, queues...)
  177. */
  178. struct s3c_fb {
  179. struct device *dev;
  180. struct resource *regs_res;
  181. struct clk *bus_clk;
  182. void __iomem *regs;
  183. struct s3c_fb_variant variant;
  184. unsigned char enabled;
  185. struct s3c_fb_platdata *pdata;
  186. struct s3c_fb_win *windows[S3C_FB_MAX_WIN];
  187. int irq_no;
  188. unsigned long irq_flags;
  189. struct s3c_fb_vsync vsync_info;
  190. };
  191. /**
  192. * s3c_fb_validate_win_bpp - validate the bits-per-pixel for this mode.
  193. * @win: The device window.
  194. * @bpp: The bit depth.
  195. */
  196. static bool s3c_fb_validate_win_bpp(struct s3c_fb_win *win, unsigned int bpp)
  197. {
  198. return win->variant.valid_bpp & VALID_BPP(bpp);
  199. }
  200. /**
  201. * s3c_fb_check_var() - framebuffer layer request to verify a given mode.
  202. * @var: The screen information to verify.
  203. * @info: The framebuffer device.
  204. *
  205. * Framebuffer layer call to verify the given information and allow us to
  206. * update various information depending on the hardware capabilities.
  207. */
  208. static int s3c_fb_check_var(struct fb_var_screeninfo *var,
  209. struct fb_info *info)
  210. {
  211. struct s3c_fb_win *win = info->par;
  212. struct s3c_fb_pd_win *windata = win->windata;
  213. struct s3c_fb *sfb = win->parent;
  214. dev_dbg(sfb->dev, "checking parameters\n");
  215. var->xres_virtual = max((unsigned int)windata->virtual_x, var->xres);
  216. var->yres_virtual = max((unsigned int)windata->virtual_y, var->yres);
  217. if (!s3c_fb_validate_win_bpp(win, var->bits_per_pixel)) {
  218. dev_dbg(sfb->dev, "win %d: unsupported bpp %d\n",
  219. win->index, var->bits_per_pixel);
  220. return -EINVAL;
  221. }
  222. /* always ensure these are zero, for drop through cases below */
  223. var->transp.offset = 0;
  224. var->transp.length = 0;
  225. switch (var->bits_per_pixel) {
  226. case 1:
  227. case 2:
  228. case 4:
  229. case 8:
  230. if (sfb->variant.palette[win->index] != 0) {
  231. /* non palletised, A:1,R:2,G:3,B:2 mode */
  232. var->red.offset = 4;
  233. var->green.offset = 2;
  234. var->blue.offset = 0;
  235. var->red.length = 5;
  236. var->green.length = 3;
  237. var->blue.length = 2;
  238. var->transp.offset = 7;
  239. var->transp.length = 1;
  240. } else {
  241. var->red.offset = 0;
  242. var->red.length = var->bits_per_pixel;
  243. var->green = var->red;
  244. var->blue = var->red;
  245. }
  246. break;
  247. case 19:
  248. /* 666 with one bit alpha/transparency */
  249. var->transp.offset = 18;
  250. var->transp.length = 1;
  251. case 18:
  252. var->bits_per_pixel = 32;
  253. /* 666 format */
  254. var->red.offset = 12;
  255. var->green.offset = 6;
  256. var->blue.offset = 0;
  257. var->red.length = 6;
  258. var->green.length = 6;
  259. var->blue.length = 6;
  260. break;
  261. case 16:
  262. /* 16 bpp, 565 format */
  263. var->red.offset = 11;
  264. var->green.offset = 5;
  265. var->blue.offset = 0;
  266. var->red.length = 5;
  267. var->green.length = 6;
  268. var->blue.length = 5;
  269. break;
  270. case 28:
  271. case 25:
  272. var->transp.length = var->bits_per_pixel - 24;
  273. var->transp.offset = 24;
  274. /* drop through */
  275. case 24:
  276. /* our 24bpp is unpacked, so 32bpp */
  277. var->bits_per_pixel = 32;
  278. case 32:
  279. var->red.offset = 16;
  280. var->red.length = 8;
  281. var->green.offset = 8;
  282. var->green.length = 8;
  283. var->blue.offset = 0;
  284. var->blue.length = 8;
  285. break;
  286. default:
  287. dev_err(sfb->dev, "invalid bpp\n");
  288. }
  289. dev_dbg(sfb->dev, "%s: verified parameters\n", __func__);
  290. return 0;
  291. }
  292. /**
  293. * s3c_fb_calc_pixclk() - calculate the divider to create the pixel clock.
  294. * @sfb: The hardware state.
  295. * @pixclock: The pixel clock wanted, in picoseconds.
  296. *
  297. * Given the specified pixel clock, work out the necessary divider to get
  298. * close to the output frequency.
  299. */
  300. static int s3c_fb_calc_pixclk(struct s3c_fb *sfb, unsigned int pixclk)
  301. {
  302. unsigned long clk = clk_get_rate(sfb->bus_clk);
  303. unsigned long long tmp;
  304. unsigned int result;
  305. tmp = (unsigned long long)clk;
  306. tmp *= pixclk;
  307. do_div(tmp, 1000000000UL);
  308. result = (unsigned int)tmp / 1000;
  309. dev_dbg(sfb->dev, "pixclk=%u, clk=%lu, div=%d (%lu)\n",
  310. pixclk, clk, result, clk / result);
  311. return result;
  312. }
  313. /**
  314. * s3c_fb_align_word() - align pixel count to word boundary
  315. * @bpp: The number of bits per pixel
  316. * @pix: The value to be aligned.
  317. *
  318. * Align the given pixel count so that it will start on an 32bit word
  319. * boundary.
  320. */
  321. static int s3c_fb_align_word(unsigned int bpp, unsigned int pix)
  322. {
  323. int pix_per_word;
  324. if (bpp > 16)
  325. return pix;
  326. pix_per_word = (8 * 32) / bpp;
  327. return ALIGN(pix, pix_per_word);
  328. }
  329. /**
  330. * vidosd_set_size() - set OSD size for a window
  331. *
  332. * @win: the window to set OSD size for
  333. * @size: OSD size register value
  334. */
  335. static void vidosd_set_size(struct s3c_fb_win *win, u32 size)
  336. {
  337. struct s3c_fb *sfb = win->parent;
  338. /* OSD can be set up if osd_size_off != 0 for this window */
  339. if (win->variant.osd_size_off)
  340. writel(size, sfb->regs + OSD_BASE(win->index, sfb->variant)
  341. + win->variant.osd_size_off);
  342. }
  343. /**
  344. * vidosd_set_alpha() - set alpha transparency for a window
  345. *
  346. * @win: the window to set OSD size for
  347. * @alpha: alpha register value
  348. */
  349. static void vidosd_set_alpha(struct s3c_fb_win *win, u32 alpha)
  350. {
  351. struct s3c_fb *sfb = win->parent;
  352. if (win->variant.has_osd_alpha)
  353. writel(alpha, sfb->regs + VIDOSD_C(win->index, sfb->variant));
  354. }
  355. /**
  356. * shadow_protect_win() - disable updating values from shadow registers at vsync
  357. *
  358. * @win: window to protect registers for
  359. * @protect: 1 to protect (disable updates)
  360. */
  361. static void shadow_protect_win(struct s3c_fb_win *win, bool protect)
  362. {
  363. struct s3c_fb *sfb = win->parent;
  364. u32 reg;
  365. if (protect) {
  366. if (sfb->variant.has_prtcon) {
  367. writel(PRTCON_PROTECT, sfb->regs + PRTCON);
  368. } else if (sfb->variant.has_shadowcon) {
  369. reg = readl(sfb->regs + SHADOWCON);
  370. writel(reg | SHADOWCON_WINx_PROTECT(win->index),
  371. sfb->regs + SHADOWCON);
  372. }
  373. } else {
  374. if (sfb->variant.has_prtcon) {
  375. writel(0, sfb->regs + PRTCON);
  376. } else if (sfb->variant.has_shadowcon) {
  377. reg = readl(sfb->regs + SHADOWCON);
  378. writel(reg & ~SHADOWCON_WINx_PROTECT(win->index),
  379. sfb->regs + SHADOWCON);
  380. }
  381. }
  382. }
  383. /**
  384. * s3c_fb_set_par() - framebuffer request to set new framebuffer state.
  385. * @info: The framebuffer to change.
  386. *
  387. * Framebuffer layer request to set a new mode for the specified framebuffer
  388. */
  389. static int s3c_fb_set_par(struct fb_info *info)
  390. {
  391. struct fb_var_screeninfo *var = &info->var;
  392. struct s3c_fb_win *win = info->par;
  393. struct s3c_fb *sfb = win->parent;
  394. void __iomem *regs = sfb->regs;
  395. void __iomem *buf = regs;
  396. int win_no = win->index;
  397. u32 alpha = 0;
  398. u32 data;
  399. u32 pagewidth;
  400. int clkdiv;
  401. dev_dbg(sfb->dev, "setting framebuffer parameters\n");
  402. shadow_protect_win(win, 1);
  403. switch (var->bits_per_pixel) {
  404. case 32:
  405. case 24:
  406. case 16:
  407. case 12:
  408. info->fix.visual = FB_VISUAL_TRUECOLOR;
  409. break;
  410. case 8:
  411. if (win->variant.palette_sz >= 256)
  412. info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
  413. else
  414. info->fix.visual = FB_VISUAL_TRUECOLOR;
  415. break;
  416. case 1:
  417. info->fix.visual = FB_VISUAL_MONO01;
  418. break;
  419. default:
  420. info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
  421. break;
  422. }
  423. info->fix.line_length = (var->xres_virtual * var->bits_per_pixel) / 8;
  424. info->fix.xpanstep = info->var.xres_virtual > info->var.xres ? 1 : 0;
  425. info->fix.ypanstep = info->var.yres_virtual > info->var.yres ? 1 : 0;
  426. /* disable the window whilst we update it */
  427. writel(0, regs + WINCON(win_no));
  428. /* use platform specified window as the basis for the lcd timings */
  429. if (win_no == sfb->pdata->default_win) {
  430. clkdiv = s3c_fb_calc_pixclk(sfb, var->pixclock);
  431. data = sfb->pdata->vidcon0;
  432. data &= ~(VIDCON0_CLKVAL_F_MASK | VIDCON0_CLKDIR);
  433. if (clkdiv > 1)
  434. data |= VIDCON0_CLKVAL_F(clkdiv-1) | VIDCON0_CLKDIR;
  435. else
  436. data &= ~VIDCON0_CLKDIR; /* 1:1 clock */
  437. /* write the timing data to the panel */
  438. if (sfb->variant.is_2443)
  439. data |= (1 << 5);
  440. data |= VIDCON0_ENVID | VIDCON0_ENVID_F;
  441. writel(data, regs + VIDCON0);
  442. data = VIDTCON0_VBPD(var->upper_margin - 1) |
  443. VIDTCON0_VFPD(var->lower_margin - 1) |
  444. VIDTCON0_VSPW(var->vsync_len - 1);
  445. writel(data, regs + sfb->variant.vidtcon);
  446. data = VIDTCON1_HBPD(var->left_margin - 1) |
  447. VIDTCON1_HFPD(var->right_margin - 1) |
  448. VIDTCON1_HSPW(var->hsync_len - 1);
  449. /* VIDTCON1 */
  450. writel(data, regs + sfb->variant.vidtcon + 4);
  451. data = VIDTCON2_LINEVAL(var->yres - 1) |
  452. VIDTCON2_HOZVAL(var->xres - 1);
  453. writel(data, regs +sfb->variant.vidtcon + 8 );
  454. }
  455. /* write the buffer address */
  456. /* start and end registers stride is 8 */
  457. buf = regs + win_no * 8;
  458. writel(info->fix.smem_start, buf + sfb->variant.buf_start);
  459. data = info->fix.smem_start + info->fix.line_length * var->yres;
  460. writel(data, buf + sfb->variant.buf_end);
  461. pagewidth = (var->xres * var->bits_per_pixel) >> 3;
  462. data = VIDW_BUF_SIZE_OFFSET(info->fix.line_length - pagewidth) |
  463. VIDW_BUF_SIZE_PAGEWIDTH(pagewidth);
  464. writel(data, regs + sfb->variant.buf_size + (win_no * 4));
  465. /* write 'OSD' registers to control position of framebuffer */
  466. data = VIDOSDxA_TOPLEFT_X(0) | VIDOSDxA_TOPLEFT_Y(0);
  467. writel(data, regs + VIDOSD_A(win_no, sfb->variant));
  468. data = VIDOSDxB_BOTRIGHT_X(s3c_fb_align_word(var->bits_per_pixel,
  469. var->xres - 1)) |
  470. VIDOSDxB_BOTRIGHT_Y(var->yres - 1);
  471. writel(data, regs + VIDOSD_B(win_no, sfb->variant));
  472. data = var->xres * var->yres;
  473. alpha = VIDISD14C_ALPHA1_R(0xf) |
  474. VIDISD14C_ALPHA1_G(0xf) |
  475. VIDISD14C_ALPHA1_B(0xf);
  476. vidosd_set_alpha(win, alpha);
  477. vidosd_set_size(win, data);
  478. data = WINCONx_ENWIN;
  479. /* note, since we have to round up the bits-per-pixel, we end up
  480. * relying on the bitfield information for r/g/b/a to work out
  481. * exactly which mode of operation is intended. */
  482. switch (var->bits_per_pixel) {
  483. case 1:
  484. data |= WINCON0_BPPMODE_1BPP;
  485. data |= WINCONx_BITSWP;
  486. data |= WINCONx_BURSTLEN_4WORD;
  487. break;
  488. case 2:
  489. data |= WINCON0_BPPMODE_2BPP;
  490. data |= WINCONx_BITSWP;
  491. data |= WINCONx_BURSTLEN_8WORD;
  492. break;
  493. case 4:
  494. data |= WINCON0_BPPMODE_4BPP;
  495. data |= WINCONx_BITSWP;
  496. data |= WINCONx_BURSTLEN_8WORD;
  497. break;
  498. case 8:
  499. if (var->transp.length != 0)
  500. data |= WINCON1_BPPMODE_8BPP_1232;
  501. else
  502. data |= WINCON0_BPPMODE_8BPP_PALETTE;
  503. data |= WINCONx_BURSTLEN_8WORD;
  504. data |= WINCONx_BYTSWP;
  505. break;
  506. case 16:
  507. if (var->transp.length != 0)
  508. data |= WINCON1_BPPMODE_16BPP_A1555;
  509. else
  510. data |= WINCON0_BPPMODE_16BPP_565;
  511. data |= WINCONx_HAWSWP;
  512. data |= WINCONx_BURSTLEN_16WORD;
  513. break;
  514. case 24:
  515. case 32:
  516. if (var->red.length == 6) {
  517. if (var->transp.length != 0)
  518. data |= WINCON1_BPPMODE_19BPP_A1666;
  519. else
  520. data |= WINCON1_BPPMODE_18BPP_666;
  521. } else if (var->transp.length == 1)
  522. data |= WINCON1_BPPMODE_25BPP_A1888
  523. | WINCON1_BLD_PIX;
  524. else if (var->transp.length == 4)
  525. data |= WINCON1_BPPMODE_28BPP_A4888
  526. | WINCON1_BLD_PIX | WINCON1_ALPHA_SEL;
  527. else
  528. data |= WINCON0_BPPMODE_24BPP_888;
  529. data |= WINCONx_WSWP;
  530. data |= WINCONx_BURSTLEN_16WORD;
  531. break;
  532. }
  533. /* Enable the colour keying for the window below this one */
  534. if (win_no > 0) {
  535. u32 keycon0_data = 0, keycon1_data = 0;
  536. void __iomem *keycon = regs + sfb->variant.keycon;
  537. keycon0_data = ~(WxKEYCON0_KEYBL_EN |
  538. WxKEYCON0_KEYEN_F |
  539. WxKEYCON0_DIRCON) | WxKEYCON0_COMPKEY(0);
  540. keycon1_data = WxKEYCON1_COLVAL(0xffffff);
  541. keycon += (win_no - 1) * 8;
  542. writel(keycon0_data, keycon + WKEYCON0);
  543. writel(keycon1_data, keycon + WKEYCON1);
  544. }
  545. writel(data, regs + sfb->variant.wincon + (win_no * 4));
  546. writel(0x0, regs + sfb->variant.winmap + (win_no * 4));
  547. /* Enable DMA channel for this window */
  548. if (sfb->variant.has_shadowcon) {
  549. data = readl(sfb->regs + SHADOWCON);
  550. data |= SHADOWCON_CHx_ENABLE(win_no);
  551. writel(data, sfb->regs + SHADOWCON);
  552. }
  553. shadow_protect_win(win, 0);
  554. return 0;
  555. }
  556. /**
  557. * s3c_fb_update_palette() - set or schedule a palette update.
  558. * @sfb: The hardware information.
  559. * @win: The window being updated.
  560. * @reg: The palette index being changed.
  561. * @value: The computed palette value.
  562. *
  563. * Change the value of a palette register, either by directly writing to
  564. * the palette (this requires the palette RAM to be disconnected from the
  565. * hardware whilst this is in progress) or schedule the update for later.
  566. *
  567. * At the moment, since we have no VSYNC interrupt support, we simply set
  568. * the palette entry directly.
  569. */
  570. static void s3c_fb_update_palette(struct s3c_fb *sfb,
  571. struct s3c_fb_win *win,
  572. unsigned int reg,
  573. u32 value)
  574. {
  575. void __iomem *palreg;
  576. u32 palcon;
  577. palreg = sfb->regs + sfb->variant.palette[win->index];
  578. dev_dbg(sfb->dev, "%s: win %d, reg %d (%p): %08x\n",
  579. __func__, win->index, reg, palreg, value);
  580. win->palette_buffer[reg] = value;
  581. palcon = readl(sfb->regs + WPALCON);
  582. writel(palcon | WPALCON_PAL_UPDATE, sfb->regs + WPALCON);
  583. if (win->variant.palette_16bpp)
  584. writew(value, palreg + (reg * 2));
  585. else
  586. writel(value, palreg + (reg * 4));
  587. writel(palcon, sfb->regs + WPALCON);
  588. }
  589. static inline unsigned int chan_to_field(unsigned int chan,
  590. struct fb_bitfield *bf)
  591. {
  592. chan &= 0xffff;
  593. chan >>= 16 - bf->length;
  594. return chan << bf->offset;
  595. }
  596. /**
  597. * s3c_fb_setcolreg() - framebuffer layer request to change palette.
  598. * @regno: The palette index to change.
  599. * @red: The red field for the palette data.
  600. * @green: The green field for the palette data.
  601. * @blue: The blue field for the palette data.
  602. * @trans: The transparency (alpha) field for the palette data.
  603. * @info: The framebuffer being changed.
  604. */
  605. static int s3c_fb_setcolreg(unsigned regno,
  606. unsigned red, unsigned green, unsigned blue,
  607. unsigned transp, struct fb_info *info)
  608. {
  609. struct s3c_fb_win *win = info->par;
  610. struct s3c_fb *sfb = win->parent;
  611. unsigned int val;
  612. dev_dbg(sfb->dev, "%s: win %d: %d => rgb=%d/%d/%d\n",
  613. __func__, win->index, regno, red, green, blue);
  614. switch (info->fix.visual) {
  615. case FB_VISUAL_TRUECOLOR:
  616. /* true-colour, use pseudo-palette */
  617. if (regno < 16) {
  618. u32 *pal = info->pseudo_palette;
  619. val = chan_to_field(red, &info->var.red);
  620. val |= chan_to_field(green, &info->var.green);
  621. val |= chan_to_field(blue, &info->var.blue);
  622. pal[regno] = val;
  623. }
  624. break;
  625. case FB_VISUAL_PSEUDOCOLOR:
  626. if (regno < win->variant.palette_sz) {
  627. val = chan_to_field(red, &win->palette.r);
  628. val |= chan_to_field(green, &win->palette.g);
  629. val |= chan_to_field(blue, &win->palette.b);
  630. s3c_fb_update_palette(sfb, win, regno, val);
  631. }
  632. break;
  633. default:
  634. return 1; /* unknown type */
  635. }
  636. return 0;
  637. }
  638. /**
  639. * s3c_fb_enable() - Set the state of the main LCD output
  640. * @sfb: The main framebuffer state.
  641. * @enable: The state to set.
  642. */
  643. static void s3c_fb_enable(struct s3c_fb *sfb, int enable)
  644. {
  645. u32 vidcon0 = readl(sfb->regs + VIDCON0);
  646. if (enable)
  647. vidcon0 |= VIDCON0_ENVID | VIDCON0_ENVID_F;
  648. else {
  649. /* see the note in the framebuffer datasheet about
  650. * why you cannot take both of these bits down at the
  651. * same time. */
  652. if (!(vidcon0 & VIDCON0_ENVID))
  653. return;
  654. vidcon0 |= VIDCON0_ENVID;
  655. vidcon0 &= ~VIDCON0_ENVID_F;
  656. }
  657. writel(vidcon0, sfb->regs + VIDCON0);
  658. }
  659. /**
  660. * s3c_fb_blank() - blank or unblank the given window
  661. * @blank_mode: The blank state from FB_BLANK_*
  662. * @info: The framebuffer to blank.
  663. *
  664. * Framebuffer layer request to change the power state.
  665. */
  666. static int s3c_fb_blank(int blank_mode, struct fb_info *info)
  667. {
  668. struct s3c_fb_win *win = info->par;
  669. struct s3c_fb *sfb = win->parent;
  670. unsigned int index = win->index;
  671. u32 wincon;
  672. dev_dbg(sfb->dev, "blank mode %d\n", blank_mode);
  673. wincon = readl(sfb->regs + sfb->variant.wincon + (index * 4));
  674. switch (blank_mode) {
  675. case FB_BLANK_POWERDOWN:
  676. wincon &= ~WINCONx_ENWIN;
  677. sfb->enabled &= ~(1 << index);
  678. /* fall through to FB_BLANK_NORMAL */
  679. case FB_BLANK_NORMAL:
  680. /* disable the DMA and display 0x0 (black) */
  681. writel(WINxMAP_MAP | WINxMAP_MAP_COLOUR(0x0),
  682. sfb->regs + sfb->variant.winmap + (index * 4));
  683. break;
  684. case FB_BLANK_UNBLANK:
  685. writel(0x0, sfb->regs + sfb->variant.winmap + (index * 4));
  686. wincon |= WINCONx_ENWIN;
  687. sfb->enabled |= (1 << index);
  688. break;
  689. case FB_BLANK_VSYNC_SUSPEND:
  690. case FB_BLANK_HSYNC_SUSPEND:
  691. default:
  692. return 1;
  693. }
  694. writel(wincon, sfb->regs + sfb->variant.wincon + (index * 4));
  695. /* Check the enabled state to see if we need to be running the
  696. * main LCD interface, as if there are no active windows then
  697. * it is highly likely that we also do not need to output
  698. * anything.
  699. */
  700. /* We could do something like the following code, but the current
  701. * system of using framebuffer events means that we cannot make
  702. * the distinction between just window 0 being inactive and all
  703. * the windows being down.
  704. *
  705. * s3c_fb_enable(sfb, sfb->enabled ? 1 : 0);
  706. */
  707. /* we're stuck with this until we can do something about overriding
  708. * the power control using the blanking event for a single fb.
  709. */
  710. if (index == sfb->pdata->default_win)
  711. s3c_fb_enable(sfb, blank_mode != FB_BLANK_POWERDOWN ? 1 : 0);
  712. return 0;
  713. }
  714. /**
  715. * s3c_fb_pan_display() - Pan the display.
  716. *
  717. * Note that the offsets can be written to the device at any time, as their
  718. * values are latched at each vsync automatically. This also means that only
  719. * the last call to this function will have any effect on next vsync, but
  720. * there is no need to sleep waiting for it to prevent tearing.
  721. *
  722. * @var: The screen information to verify.
  723. * @info: The framebuffer device.
  724. */
  725. static int s3c_fb_pan_display(struct fb_var_screeninfo *var,
  726. struct fb_info *info)
  727. {
  728. struct s3c_fb_win *win = info->par;
  729. struct s3c_fb *sfb = win->parent;
  730. void __iomem *buf = sfb->regs + win->index * 8;
  731. unsigned int start_boff, end_boff;
  732. /* Offset in bytes to the start of the displayed area */
  733. start_boff = var->yoffset * info->fix.line_length;
  734. /* X offset depends on the current bpp */
  735. if (info->var.bits_per_pixel >= 8) {
  736. start_boff += var->xoffset * (info->var.bits_per_pixel >> 3);
  737. } else {
  738. switch (info->var.bits_per_pixel) {
  739. case 4:
  740. start_boff += var->xoffset >> 1;
  741. break;
  742. case 2:
  743. start_boff += var->xoffset >> 2;
  744. break;
  745. case 1:
  746. start_boff += var->xoffset >> 3;
  747. break;
  748. default:
  749. dev_err(sfb->dev, "invalid bpp\n");
  750. return -EINVAL;
  751. }
  752. }
  753. /* Offset in bytes to the end of the displayed area */
  754. end_boff = start_boff + var->yres * info->fix.line_length;
  755. /* Temporarily turn off per-vsync update from shadow registers until
  756. * both start and end addresses are updated to prevent corruption */
  757. shadow_protect_win(win, 1);
  758. writel(info->fix.smem_start + start_boff, buf + sfb->variant.buf_start);
  759. writel(info->fix.smem_start + end_boff, buf + sfb->variant.buf_end);
  760. shadow_protect_win(win, 0);
  761. return 0;
  762. }
  763. /**
  764. * s3c_fb_enable_irq() - enable framebuffer interrupts
  765. * @sfb: main hardware state
  766. */
  767. static void s3c_fb_enable_irq(struct s3c_fb *sfb)
  768. {
  769. void __iomem *regs = sfb->regs;
  770. u32 irq_ctrl_reg;
  771. if (!test_and_set_bit(S3C_FB_VSYNC_IRQ_EN, &sfb->irq_flags)) {
  772. /* IRQ disabled, enable it */
  773. irq_ctrl_reg = readl(regs + VIDINTCON0);
  774. irq_ctrl_reg |= VIDINTCON0_INT_ENABLE;
  775. irq_ctrl_reg |= VIDINTCON0_INT_FRAME;
  776. irq_ctrl_reg &= ~VIDINTCON0_FRAMESEL0_MASK;
  777. irq_ctrl_reg |= VIDINTCON0_FRAMESEL0_VSYNC;
  778. irq_ctrl_reg &= ~VIDINTCON0_FRAMESEL1_MASK;
  779. irq_ctrl_reg |= VIDINTCON0_FRAMESEL1_NONE;
  780. writel(irq_ctrl_reg, regs + VIDINTCON0);
  781. }
  782. }
  783. /**
  784. * s3c_fb_disable_irq() - disable framebuffer interrupts
  785. * @sfb: main hardware state
  786. */
  787. static void s3c_fb_disable_irq(struct s3c_fb *sfb)
  788. {
  789. void __iomem *regs = sfb->regs;
  790. u32 irq_ctrl_reg;
  791. if (test_and_clear_bit(S3C_FB_VSYNC_IRQ_EN, &sfb->irq_flags)) {
  792. /* IRQ enabled, disable it */
  793. irq_ctrl_reg = readl(regs + VIDINTCON0);
  794. irq_ctrl_reg &= ~VIDINTCON0_INT_FRAME;
  795. irq_ctrl_reg &= ~VIDINTCON0_INT_ENABLE;
  796. writel(irq_ctrl_reg, regs + VIDINTCON0);
  797. }
  798. }
  799. static irqreturn_t s3c_fb_irq(int irq, void *dev_id)
  800. {
  801. struct s3c_fb *sfb = dev_id;
  802. void __iomem *regs = sfb->regs;
  803. u32 irq_sts_reg;
  804. irq_sts_reg = readl(regs + VIDINTCON1);
  805. if (irq_sts_reg & VIDINTCON1_INT_FRAME) {
  806. /* VSYNC interrupt, accept it */
  807. writel(VIDINTCON1_INT_FRAME, regs + VIDINTCON1);
  808. sfb->vsync_info.count++;
  809. wake_up_interruptible(&sfb->vsync_info.wait);
  810. }
  811. /* We only support waiting for VSYNC for now, so it's safe
  812. * to always disable irqs here.
  813. */
  814. s3c_fb_disable_irq(sfb);
  815. return IRQ_HANDLED;
  816. }
  817. /**
  818. * s3c_fb_wait_for_vsync() - sleep until next VSYNC interrupt or timeout
  819. * @sfb: main hardware state
  820. * @crtc: head index.
  821. */
  822. static int s3c_fb_wait_for_vsync(struct s3c_fb *sfb, u32 crtc)
  823. {
  824. unsigned long count;
  825. int ret;
  826. if (crtc != 0)
  827. return -ENODEV;
  828. count = sfb->vsync_info.count;
  829. s3c_fb_enable_irq(sfb);
  830. ret = wait_event_interruptible_timeout(sfb->vsync_info.wait,
  831. count != sfb->vsync_info.count,
  832. msecs_to_jiffies(VSYNC_TIMEOUT_MSEC));
  833. if (ret == 0)
  834. return -ETIMEDOUT;
  835. return 0;
  836. }
  837. static int s3c_fb_ioctl(struct fb_info *info, unsigned int cmd,
  838. unsigned long arg)
  839. {
  840. struct s3c_fb_win *win = info->par;
  841. struct s3c_fb *sfb = win->parent;
  842. int ret;
  843. u32 crtc;
  844. switch (cmd) {
  845. case FBIO_WAITFORVSYNC:
  846. if (get_user(crtc, (u32 __user *)arg)) {
  847. ret = -EFAULT;
  848. break;
  849. }
  850. ret = s3c_fb_wait_for_vsync(sfb, crtc);
  851. break;
  852. default:
  853. ret = -ENOTTY;
  854. }
  855. return ret;
  856. }
  857. static int s3c_fb_open(struct fb_info *info, int user)
  858. {
  859. struct s3c_fb_win *win = info->par;
  860. struct s3c_fb *sfb = win->parent;
  861. pm_runtime_get_sync(sfb->dev);
  862. return 0;
  863. }
  864. static int s3c_fb_release(struct fb_info *info, int user)
  865. {
  866. struct s3c_fb_win *win = info->par;
  867. struct s3c_fb *sfb = win->parent;
  868. pm_runtime_put_sync(sfb->dev);
  869. return 0;
  870. }
  871. static struct fb_ops s3c_fb_ops = {
  872. .owner = THIS_MODULE,
  873. .fb_open = s3c_fb_open,
  874. .fb_release = s3c_fb_release,
  875. .fb_check_var = s3c_fb_check_var,
  876. .fb_set_par = s3c_fb_set_par,
  877. .fb_blank = s3c_fb_blank,
  878. .fb_setcolreg = s3c_fb_setcolreg,
  879. .fb_fillrect = cfb_fillrect,
  880. .fb_copyarea = cfb_copyarea,
  881. .fb_imageblit = cfb_imageblit,
  882. .fb_pan_display = s3c_fb_pan_display,
  883. .fb_ioctl = s3c_fb_ioctl,
  884. };
  885. /**
  886. * s3c_fb_missing_pixclock() - calculates pixel clock
  887. * @mode: The video mode to change.
  888. *
  889. * Calculate the pixel clock when none has been given through platform data.
  890. */
  891. static void __devinit s3c_fb_missing_pixclock(struct fb_videomode *mode)
  892. {
  893. u64 pixclk = 1000000000000ULL;
  894. u32 div;
  895. div = mode->left_margin + mode->hsync_len + mode->right_margin +
  896. mode->xres;
  897. div *= mode->upper_margin + mode->vsync_len + mode->lower_margin +
  898. mode->yres;
  899. div *= mode->refresh ? : 60;
  900. do_div(pixclk, div);
  901. mode->pixclock = pixclk;
  902. }
  903. /**
  904. * s3c_fb_alloc_memory() - allocate display memory for framebuffer window
  905. * @sfb: The base resources for the hardware.
  906. * @win: The window to initialise memory for.
  907. *
  908. * Allocate memory for the given framebuffer.
  909. */
  910. static int __devinit s3c_fb_alloc_memory(struct s3c_fb *sfb,
  911. struct s3c_fb_win *win)
  912. {
  913. struct s3c_fb_pd_win *windata = win->windata;
  914. unsigned int real_size, virt_size, size;
  915. struct fb_info *fbi = win->fbinfo;
  916. dma_addr_t map_dma;
  917. dev_dbg(sfb->dev, "allocating memory for display\n");
  918. real_size = windata->win_mode.xres * windata->win_mode.yres;
  919. virt_size = windata->virtual_x * windata->virtual_y;
  920. dev_dbg(sfb->dev, "real_size=%u (%u.%u), virt_size=%u (%u.%u)\n",
  921. real_size, windata->win_mode.xres, windata->win_mode.yres,
  922. virt_size, windata->virtual_x, windata->virtual_y);
  923. size = (real_size > virt_size) ? real_size : virt_size;
  924. size *= (windata->max_bpp > 16) ? 32 : windata->max_bpp;
  925. size /= 8;
  926. fbi->fix.smem_len = size;
  927. size = PAGE_ALIGN(size);
  928. dev_dbg(sfb->dev, "want %u bytes for window\n", size);
  929. fbi->screen_base = dma_alloc_writecombine(sfb->dev, size,
  930. &map_dma, GFP_KERNEL);
  931. if (!fbi->screen_base)
  932. return -ENOMEM;
  933. dev_dbg(sfb->dev, "mapped %x to %p\n",
  934. (unsigned int)map_dma, fbi->screen_base);
  935. memset(fbi->screen_base, 0x0, size);
  936. fbi->fix.smem_start = map_dma;
  937. return 0;
  938. }
  939. /**
  940. * s3c_fb_free_memory() - free the display memory for the given window
  941. * @sfb: The base resources for the hardware.
  942. * @win: The window to free the display memory for.
  943. *
  944. * Free the display memory allocated by s3c_fb_alloc_memory().
  945. */
  946. static void s3c_fb_free_memory(struct s3c_fb *sfb, struct s3c_fb_win *win)
  947. {
  948. struct fb_info *fbi = win->fbinfo;
  949. if (fbi->screen_base)
  950. dma_free_writecombine(sfb->dev, PAGE_ALIGN(fbi->fix.smem_len),
  951. fbi->screen_base, fbi->fix.smem_start);
  952. }
  953. /**
  954. * s3c_fb_release_win() - release resources for a framebuffer window.
  955. * @win: The window to cleanup the resources for.
  956. *
  957. * Release the resources that where claimed for the hardware window,
  958. * such as the framebuffer instance and any memory claimed for it.
  959. */
  960. static void s3c_fb_release_win(struct s3c_fb *sfb, struct s3c_fb_win *win)
  961. {
  962. u32 data;
  963. if (win->fbinfo) {
  964. if (sfb->variant.has_shadowcon) {
  965. data = readl(sfb->regs + SHADOWCON);
  966. data &= ~SHADOWCON_CHx_ENABLE(win->index);
  967. data &= ~SHADOWCON_CHx_LOCAL_ENABLE(win->index);
  968. writel(data, sfb->regs + SHADOWCON);
  969. }
  970. unregister_framebuffer(win->fbinfo);
  971. if (win->fbinfo->cmap.len)
  972. fb_dealloc_cmap(&win->fbinfo->cmap);
  973. s3c_fb_free_memory(sfb, win);
  974. framebuffer_release(win->fbinfo);
  975. }
  976. }
  977. /**
  978. * s3c_fb_probe_win() - register an hardware window
  979. * @sfb: The base resources for the hardware
  980. * @variant: The variant information for this window.
  981. * @res: Pointer to where to place the resultant window.
  982. *
  983. * Allocate and do the basic initialisation for one of the hardware's graphics
  984. * windows.
  985. */
  986. static int __devinit s3c_fb_probe_win(struct s3c_fb *sfb, unsigned int win_no,
  987. struct s3c_fb_win_variant *variant,
  988. struct s3c_fb_win **res)
  989. {
  990. struct fb_var_screeninfo *var;
  991. struct fb_videomode *initmode;
  992. struct s3c_fb_pd_win *windata;
  993. struct s3c_fb_win *win;
  994. struct fb_info *fbinfo;
  995. int palette_size;
  996. int ret;
  997. dev_dbg(sfb->dev, "probing window %d, variant %p\n", win_no, variant);
  998. init_waitqueue_head(&sfb->vsync_info.wait);
  999. palette_size = variant->palette_sz * 4;
  1000. fbinfo = framebuffer_alloc(sizeof(struct s3c_fb_win) +
  1001. palette_size * sizeof(u32), sfb->dev);
  1002. if (!fbinfo) {
  1003. dev_err(sfb->dev, "failed to allocate framebuffer\n");
  1004. return -ENOENT;
  1005. }
  1006. windata = sfb->pdata->win[win_no];
  1007. initmode = &windata->win_mode;
  1008. WARN_ON(windata->max_bpp == 0);
  1009. WARN_ON(windata->win_mode.xres == 0);
  1010. WARN_ON(windata->win_mode.yres == 0);
  1011. win = fbinfo->par;
  1012. *res = win;
  1013. var = &fbinfo->var;
  1014. win->variant = *variant;
  1015. win->fbinfo = fbinfo;
  1016. win->parent = sfb;
  1017. win->windata = windata;
  1018. win->index = win_no;
  1019. win->palette_buffer = (u32 *)(win + 1);
  1020. ret = s3c_fb_alloc_memory(sfb, win);
  1021. if (ret) {
  1022. dev_err(sfb->dev, "failed to allocate display memory\n");
  1023. return ret;
  1024. }
  1025. /* setup the r/b/g positions for the window's palette */
  1026. if (win->variant.palette_16bpp) {
  1027. /* Set RGB 5:6:5 as default */
  1028. win->palette.r.offset = 11;
  1029. win->palette.r.length = 5;
  1030. win->palette.g.offset = 5;
  1031. win->palette.g.length = 6;
  1032. win->palette.b.offset = 0;
  1033. win->palette.b.length = 5;
  1034. } else {
  1035. /* Set 8bpp or 8bpp and 1bit alpha */
  1036. win->palette.r.offset = 16;
  1037. win->palette.r.length = 8;
  1038. win->palette.g.offset = 8;
  1039. win->palette.g.length = 8;
  1040. win->palette.b.offset = 0;
  1041. win->palette.b.length = 8;
  1042. }
  1043. /* setup the initial video mode from the window */
  1044. fb_videomode_to_var(&fbinfo->var, initmode);
  1045. fbinfo->fix.type = FB_TYPE_PACKED_PIXELS;
  1046. fbinfo->fix.accel = FB_ACCEL_NONE;
  1047. fbinfo->var.activate = FB_ACTIVATE_NOW;
  1048. fbinfo->var.vmode = FB_VMODE_NONINTERLACED;
  1049. fbinfo->var.bits_per_pixel = windata->default_bpp;
  1050. fbinfo->fbops = &s3c_fb_ops;
  1051. fbinfo->flags = FBINFO_FLAG_DEFAULT;
  1052. fbinfo->pseudo_palette = &win->pseudo_palette;
  1053. /* prepare to actually start the framebuffer */
  1054. ret = s3c_fb_check_var(&fbinfo->var, fbinfo);
  1055. if (ret < 0) {
  1056. dev_err(sfb->dev, "check_var failed on initial video params\n");
  1057. return ret;
  1058. }
  1059. /* create initial colour map */
  1060. ret = fb_alloc_cmap(&fbinfo->cmap, win->variant.palette_sz, 1);
  1061. if (ret == 0)
  1062. fb_set_cmap(&fbinfo->cmap, fbinfo);
  1063. else
  1064. dev_err(sfb->dev, "failed to allocate fb cmap\n");
  1065. s3c_fb_set_par(fbinfo);
  1066. dev_dbg(sfb->dev, "about to register framebuffer\n");
  1067. /* run the check_var and set_par on our configuration. */
  1068. ret = register_framebuffer(fbinfo);
  1069. if (ret < 0) {
  1070. dev_err(sfb->dev, "failed to register framebuffer\n");
  1071. return ret;
  1072. }
  1073. dev_info(sfb->dev, "window %d: fb %s\n", win_no, fbinfo->fix.id);
  1074. return 0;
  1075. }
  1076. /**
  1077. * s3c_fb_clear_win() - clear hardware window registers.
  1078. * @sfb: The base resources for the hardware.
  1079. * @win: The window to process.
  1080. *
  1081. * Reset the specific window registers to a known state.
  1082. */
  1083. static void s3c_fb_clear_win(struct s3c_fb *sfb, int win)
  1084. {
  1085. void __iomem *regs = sfb->regs;
  1086. u32 reg;
  1087. writel(0, regs + sfb->variant.wincon + (win * 4));
  1088. writel(0, regs + VIDOSD_A(win, sfb->variant));
  1089. writel(0, regs + VIDOSD_B(win, sfb->variant));
  1090. writel(0, regs + VIDOSD_C(win, sfb->variant));
  1091. reg = readl(regs + SHADOWCON);
  1092. writel(reg & ~SHADOWCON_WINx_PROTECT(win), regs + SHADOWCON);
  1093. }
  1094. static int __devinit s3c_fb_probe(struct platform_device *pdev)
  1095. {
  1096. struct s3c_fb_driverdata *fbdrv;
  1097. struct device *dev = &pdev->dev;
  1098. struct s3c_fb_platdata *pd;
  1099. struct s3c_fb *sfb;
  1100. struct resource *res;
  1101. int win;
  1102. int ret = 0;
  1103. fbdrv = (struct s3c_fb_driverdata *)platform_get_device_id(pdev)->driver_data;
  1104. if (fbdrv->variant.nr_windows > S3C_FB_MAX_WIN) {
  1105. dev_err(dev, "too many windows, cannot attach\n");
  1106. return -EINVAL;
  1107. }
  1108. pd = pdev->dev.platform_data;
  1109. if (!pd) {
  1110. dev_err(dev, "no platform data specified\n");
  1111. return -EINVAL;
  1112. }
  1113. sfb = kzalloc(sizeof(struct s3c_fb), GFP_KERNEL);
  1114. if (!sfb) {
  1115. dev_err(dev, "no memory for framebuffers\n");
  1116. return -ENOMEM;
  1117. }
  1118. dev_dbg(dev, "allocate new framebuffer %p\n", sfb);
  1119. sfb->dev = dev;
  1120. sfb->pdata = pd;
  1121. sfb->variant = fbdrv->variant;
  1122. sfb->bus_clk = clk_get(dev, "lcd");
  1123. if (IS_ERR(sfb->bus_clk)) {
  1124. dev_err(dev, "failed to get bus clock\n");
  1125. goto err_sfb;
  1126. }
  1127. clk_enable(sfb->bus_clk);
  1128. pm_runtime_enable(sfb->dev);
  1129. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1130. if (!res) {
  1131. dev_err(dev, "failed to find registers\n");
  1132. ret = -ENOENT;
  1133. goto err_clk;
  1134. }
  1135. sfb->regs_res = request_mem_region(res->start, resource_size(res),
  1136. dev_name(dev));
  1137. if (!sfb->regs_res) {
  1138. dev_err(dev, "failed to claim register region\n");
  1139. ret = -ENOENT;
  1140. goto err_clk;
  1141. }
  1142. sfb->regs = ioremap(res->start, resource_size(res));
  1143. if (!sfb->regs) {
  1144. dev_err(dev, "failed to map registers\n");
  1145. ret = -ENXIO;
  1146. goto err_req_region;
  1147. }
  1148. res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  1149. if (!res) {
  1150. dev_err(dev, "failed to acquire irq resource\n");
  1151. ret = -ENOENT;
  1152. goto err_ioremap;
  1153. }
  1154. sfb->irq_no = res->start;
  1155. ret = request_irq(sfb->irq_no, s3c_fb_irq,
  1156. 0, "s3c_fb", sfb);
  1157. if (ret) {
  1158. dev_err(dev, "irq request failed\n");
  1159. goto err_ioremap;
  1160. }
  1161. dev_dbg(dev, "got resources (regs %p), probing windows\n", sfb->regs);
  1162. platform_set_drvdata(pdev, sfb);
  1163. pm_runtime_get_sync(sfb->dev);
  1164. /* setup gpio and output polarity controls */
  1165. pd->setup_gpio();
  1166. writel(pd->vidcon1, sfb->regs + VIDCON1);
  1167. /* zero all windows before we do anything */
  1168. for (win = 0; win < fbdrv->variant.nr_windows; win++)
  1169. s3c_fb_clear_win(sfb, win);
  1170. /* initialise colour key controls */
  1171. for (win = 0; win < (fbdrv->variant.nr_windows - 1); win++) {
  1172. void __iomem *regs = sfb->regs + sfb->variant.keycon;
  1173. regs += (win * 8);
  1174. writel(0xffffff, regs + WKEYCON0);
  1175. writel(0xffffff, regs + WKEYCON1);
  1176. }
  1177. /* we have the register setup, start allocating framebuffers */
  1178. for (win = 0; win < fbdrv->variant.nr_windows; win++) {
  1179. if (!pd->win[win])
  1180. continue;
  1181. if (!pd->win[win]->win_mode.pixclock)
  1182. s3c_fb_missing_pixclock(&pd->win[win]->win_mode);
  1183. ret = s3c_fb_probe_win(sfb, win, fbdrv->win[win],
  1184. &sfb->windows[win]);
  1185. if (ret < 0) {
  1186. dev_err(dev, "failed to create window %d\n", win);
  1187. for (; win >= 0; win--)
  1188. s3c_fb_release_win(sfb, sfb->windows[win]);
  1189. goto err_irq;
  1190. }
  1191. }
  1192. platform_set_drvdata(pdev, sfb);
  1193. pm_runtime_put_sync(sfb->dev);
  1194. return 0;
  1195. err_irq:
  1196. free_irq(sfb->irq_no, sfb);
  1197. err_ioremap:
  1198. iounmap(sfb->regs);
  1199. err_req_region:
  1200. release_resource(sfb->regs_res);
  1201. kfree(sfb->regs_res);
  1202. err_clk:
  1203. clk_disable(sfb->bus_clk);
  1204. clk_put(sfb->bus_clk);
  1205. err_sfb:
  1206. kfree(sfb);
  1207. return ret;
  1208. }
  1209. /**
  1210. * s3c_fb_remove() - Cleanup on module finalisation
  1211. * @pdev: The platform device we are bound to.
  1212. *
  1213. * Shutdown and then release all the resources that the driver allocated
  1214. * on initialisation.
  1215. */
  1216. static int __devexit s3c_fb_remove(struct platform_device *pdev)
  1217. {
  1218. struct s3c_fb *sfb = platform_get_drvdata(pdev);
  1219. int win;
  1220. pm_runtime_get_sync(sfb->dev);
  1221. for (win = 0; win < S3C_FB_MAX_WIN; win++)
  1222. if (sfb->windows[win])
  1223. s3c_fb_release_win(sfb, sfb->windows[win]);
  1224. free_irq(sfb->irq_no, sfb);
  1225. iounmap(sfb->regs);
  1226. clk_disable(sfb->bus_clk);
  1227. clk_put(sfb->bus_clk);
  1228. release_resource(sfb->regs_res);
  1229. kfree(sfb->regs_res);
  1230. kfree(sfb);
  1231. pm_runtime_put_sync(sfb->dev);
  1232. pm_runtime_disable(sfb->dev);
  1233. return 0;
  1234. }
  1235. #ifdef CONFIG_PM
  1236. static int s3c_fb_suspend(struct device *dev)
  1237. {
  1238. struct platform_device *pdev = to_platform_device(dev);
  1239. struct s3c_fb *sfb = platform_get_drvdata(pdev);
  1240. struct s3c_fb_win *win;
  1241. int win_no;
  1242. for (win_no = S3C_FB_MAX_WIN - 1; win_no >= 0; win_no--) {
  1243. win = sfb->windows[win_no];
  1244. if (!win)
  1245. continue;
  1246. /* use the blank function to push into power-down */
  1247. s3c_fb_blank(FB_BLANK_POWERDOWN, win->fbinfo);
  1248. }
  1249. clk_disable(sfb->bus_clk);
  1250. return 0;
  1251. }
  1252. static int s3c_fb_resume(struct device *dev)
  1253. {
  1254. struct platform_device *pdev = to_platform_device(dev);
  1255. struct s3c_fb *sfb = platform_get_drvdata(pdev);
  1256. struct s3c_fb_platdata *pd = sfb->pdata;
  1257. struct s3c_fb_win *win;
  1258. int win_no;
  1259. clk_enable(sfb->bus_clk);
  1260. /* setup registers */
  1261. writel(pd->vidcon1, sfb->regs + VIDCON1);
  1262. /* zero all windows before we do anything */
  1263. for (win_no = 0; win_no < sfb->variant.nr_windows; win_no++)
  1264. s3c_fb_clear_win(sfb, win_no);
  1265. for (win_no = 0; win_no < sfb->variant.nr_windows - 1; win_no++) {
  1266. void __iomem *regs = sfb->regs + sfb->variant.keycon;
  1267. regs += (win_no * 8);
  1268. writel(0xffffff, regs + WKEYCON0);
  1269. writel(0xffffff, regs + WKEYCON1);
  1270. }
  1271. /* restore framebuffers */
  1272. for (win_no = 0; win_no < S3C_FB_MAX_WIN; win_no++) {
  1273. win = sfb->windows[win_no];
  1274. if (!win)
  1275. continue;
  1276. dev_dbg(&pdev->dev, "resuming window %d\n", win_no);
  1277. s3c_fb_set_par(win->fbinfo);
  1278. }
  1279. return 0;
  1280. }
  1281. int s3c_fb_runtime_suspend(struct device *dev)
  1282. {
  1283. struct platform_device *pdev = to_platform_device(dev);
  1284. struct s3c_fb *sfb = platform_get_drvdata(pdev);
  1285. struct s3c_fb_win *win;
  1286. int win_no;
  1287. for (win_no = S3C_FB_MAX_WIN - 1; win_no >= 0; win_no--) {
  1288. win = sfb->windows[win_no];
  1289. if (!win)
  1290. continue;
  1291. /* use the blank function to push into power-down */
  1292. s3c_fb_blank(FB_BLANK_POWERDOWN, win->fbinfo);
  1293. }
  1294. clk_disable(sfb->bus_clk);
  1295. return 0;
  1296. }
  1297. int s3c_fb_runtime_resume(struct device *dev)
  1298. {
  1299. struct platform_device *pdev = to_platform_device(dev);
  1300. struct s3c_fb *sfb = platform_get_drvdata(pdev);
  1301. struct s3c_fb_platdata *pd = sfb->pdata;
  1302. struct s3c_fb_win *win;
  1303. int win_no;
  1304. clk_enable(sfb->bus_clk);
  1305. /* setup registers */
  1306. writel(pd->vidcon1, sfb->regs + VIDCON1);
  1307. /* zero all windows before we do anything */
  1308. for (win_no = 0; win_no < sfb->variant.nr_windows; win_no++)
  1309. s3c_fb_clear_win(sfb, win_no);
  1310. for (win_no = 0; win_no < sfb->variant.nr_windows - 1; win_no++) {
  1311. void __iomem *regs = sfb->regs + sfb->variant.keycon;
  1312. regs += (win_no * 8);
  1313. writel(0xffffff, regs + WKEYCON0);
  1314. writel(0xffffff, regs + WKEYCON1);
  1315. }
  1316. /* restore framebuffers */
  1317. for (win_no = 0; win_no < S3C_FB_MAX_WIN; win_no++) {
  1318. win = sfb->windows[win_no];
  1319. if (!win)
  1320. continue;
  1321. dev_dbg(&pdev->dev, "resuming window %d\n", win_no);
  1322. s3c_fb_set_par(win->fbinfo);
  1323. }
  1324. return 0;
  1325. }
  1326. #else
  1327. #define s3c_fb_suspend NULL
  1328. #define s3c_fb_resume NULL
  1329. #define s3c_fb_runtime_suspend NULL
  1330. #define s3c_fb_runtime_resume NULL
  1331. #endif
  1332. #define VALID_BPP124 (VALID_BPP(1) | VALID_BPP(2) | VALID_BPP(4))
  1333. #define VALID_BPP1248 (VALID_BPP124 | VALID_BPP(8))
  1334. static struct s3c_fb_win_variant s3c_fb_data_64xx_wins[] = {
  1335. [0] = {
  1336. .has_osd_c = 1,
  1337. .osd_size_off = 0x8,
  1338. .palette_sz = 256,
  1339. .valid_bpp = VALID_BPP1248 | VALID_BPP(16) | VALID_BPP(24),
  1340. },
  1341. [1] = {
  1342. .has_osd_c = 1,
  1343. .has_osd_d = 1,
  1344. .osd_size_off = 0x12,
  1345. .has_osd_alpha = 1,
  1346. .palette_sz = 256,
  1347. .valid_bpp = (VALID_BPP1248 | VALID_BPP(16) |
  1348. VALID_BPP(18) | VALID_BPP(19) |
  1349. VALID_BPP(24) | VALID_BPP(25)),
  1350. },
  1351. [2] = {
  1352. .has_osd_c = 1,
  1353. .has_osd_d = 1,
  1354. .osd_size_off = 0x12,
  1355. .has_osd_alpha = 1,
  1356. .palette_sz = 16,
  1357. .palette_16bpp = 1,
  1358. .valid_bpp = (VALID_BPP1248 | VALID_BPP(16) |
  1359. VALID_BPP(18) | VALID_BPP(19) |
  1360. VALID_BPP(24) | VALID_BPP(25)),
  1361. },
  1362. [3] = {
  1363. .has_osd_c = 1,
  1364. .has_osd_alpha = 1,
  1365. .palette_sz = 16,
  1366. .palette_16bpp = 1,
  1367. .valid_bpp = (VALID_BPP124 | VALID_BPP(16) |
  1368. VALID_BPP(18) | VALID_BPP(19) |
  1369. VALID_BPP(24) | VALID_BPP(25)),
  1370. },
  1371. [4] = {
  1372. .has_osd_c = 1,
  1373. .has_osd_alpha = 1,
  1374. .palette_sz = 4,
  1375. .palette_16bpp = 1,
  1376. .valid_bpp = (VALID_BPP(1) | VALID_BPP(2) |
  1377. VALID_BPP(16) | VALID_BPP(18) |
  1378. VALID_BPP(24) | VALID_BPP(25)),
  1379. },
  1380. };
  1381. static struct s3c_fb_driverdata s3c_fb_data_64xx = {
  1382. .variant = {
  1383. .nr_windows = 5,
  1384. .vidtcon = VIDTCON0,
  1385. .wincon = WINCON(0),
  1386. .winmap = WINxMAP(0),
  1387. .keycon = WKEYCON,
  1388. .osd = VIDOSD_BASE,
  1389. .osd_stride = 16,
  1390. .buf_start = VIDW_BUF_START(0),
  1391. .buf_size = VIDW_BUF_SIZE(0),
  1392. .buf_end = VIDW_BUF_END(0),
  1393. .palette = {
  1394. [0] = 0x400,
  1395. [1] = 0x800,
  1396. [2] = 0x300,
  1397. [3] = 0x320,
  1398. [4] = 0x340,
  1399. },
  1400. .has_prtcon = 1,
  1401. },
  1402. .win[0] = &s3c_fb_data_64xx_wins[0],
  1403. .win[1] = &s3c_fb_data_64xx_wins[1],
  1404. .win[2] = &s3c_fb_data_64xx_wins[2],
  1405. .win[3] = &s3c_fb_data_64xx_wins[3],
  1406. .win[4] = &s3c_fb_data_64xx_wins[4],
  1407. };
  1408. static struct s3c_fb_driverdata s3c_fb_data_s5pc100 = {
  1409. .variant = {
  1410. .nr_windows = 5,
  1411. .vidtcon = VIDTCON0,
  1412. .wincon = WINCON(0),
  1413. .winmap = WINxMAP(0),
  1414. .keycon = WKEYCON,
  1415. .osd = VIDOSD_BASE,
  1416. .osd_stride = 16,
  1417. .buf_start = VIDW_BUF_START(0),
  1418. .buf_size = VIDW_BUF_SIZE(0),
  1419. .buf_end = VIDW_BUF_END(0),
  1420. .palette = {
  1421. [0] = 0x2400,
  1422. [1] = 0x2800,
  1423. [2] = 0x2c00,
  1424. [3] = 0x3000,
  1425. [4] = 0x3400,
  1426. },
  1427. .has_prtcon = 1,
  1428. },
  1429. .win[0] = &s3c_fb_data_64xx_wins[0],
  1430. .win[1] = &s3c_fb_data_64xx_wins[1],
  1431. .win[2] = &s3c_fb_data_64xx_wins[2],
  1432. .win[3] = &s3c_fb_data_64xx_wins[3],
  1433. .win[4] = &s3c_fb_data_64xx_wins[4],
  1434. };
  1435. static struct s3c_fb_driverdata s3c_fb_data_s5pv210 = {
  1436. .variant = {
  1437. .nr_windows = 5,
  1438. .vidtcon = VIDTCON0,
  1439. .wincon = WINCON(0),
  1440. .winmap = WINxMAP(0),
  1441. .keycon = WKEYCON,
  1442. .osd = VIDOSD_BASE,
  1443. .osd_stride = 16,
  1444. .buf_start = VIDW_BUF_START(0),
  1445. .buf_size = VIDW_BUF_SIZE(0),
  1446. .buf_end = VIDW_BUF_END(0),
  1447. .palette = {
  1448. [0] = 0x2400,
  1449. [1] = 0x2800,
  1450. [2] = 0x2c00,
  1451. [3] = 0x3000,
  1452. [4] = 0x3400,
  1453. },
  1454. .has_shadowcon = 1,
  1455. },
  1456. .win[0] = &s3c_fb_data_64xx_wins[0],
  1457. .win[1] = &s3c_fb_data_64xx_wins[1],
  1458. .win[2] = &s3c_fb_data_64xx_wins[2],
  1459. .win[3] = &s3c_fb_data_64xx_wins[3],
  1460. .win[4] = &s3c_fb_data_64xx_wins[4],
  1461. };
  1462. /* S3C2443/S3C2416 style hardware */
  1463. static struct s3c_fb_driverdata s3c_fb_data_s3c2443 = {
  1464. .variant = {
  1465. .nr_windows = 2,
  1466. .is_2443 = 1,
  1467. .vidtcon = 0x08,
  1468. .wincon = 0x14,
  1469. .winmap = 0xd0,
  1470. .keycon = 0xb0,
  1471. .osd = 0x28,
  1472. .osd_stride = 12,
  1473. .buf_start = 0x64,
  1474. .buf_size = 0x94,
  1475. .buf_end = 0x7c,
  1476. .palette = {
  1477. [0] = 0x400,
  1478. [1] = 0x800,
  1479. },
  1480. },
  1481. .win[0] = &(struct s3c_fb_win_variant) {
  1482. .palette_sz = 256,
  1483. .valid_bpp = VALID_BPP1248 | VALID_BPP(16) | VALID_BPP(24),
  1484. },
  1485. .win[1] = &(struct s3c_fb_win_variant) {
  1486. .has_osd_c = 1,
  1487. .has_osd_alpha = 1,
  1488. .palette_sz = 256,
  1489. .valid_bpp = (VALID_BPP1248 | VALID_BPP(16) |
  1490. VALID_BPP(18) | VALID_BPP(19) |
  1491. VALID_BPP(24) | VALID_BPP(25) |
  1492. VALID_BPP(28)),
  1493. },
  1494. };
  1495. static struct platform_device_id s3c_fb_driver_ids[] = {
  1496. {
  1497. .name = "s3c-fb",
  1498. .driver_data = (unsigned long)&s3c_fb_data_64xx,
  1499. }, {
  1500. .name = "s5pc100-fb",
  1501. .driver_data = (unsigned long)&s3c_fb_data_s5pc100,
  1502. }, {
  1503. .name = "s5pv210-fb",
  1504. .driver_data = (unsigned long)&s3c_fb_data_s5pv210,
  1505. }, {
  1506. .name = "s3c2443-fb",
  1507. .driver_data = (unsigned long)&s3c_fb_data_s3c2443,
  1508. },
  1509. {},
  1510. };
  1511. MODULE_DEVICE_TABLE(platform, s3c_fb_driver_ids);
  1512. static const struct dev_pm_ops s3cfb_pm_ops = {
  1513. .suspend = s3c_fb_suspend,
  1514. .resume = s3c_fb_resume,
  1515. .runtime_suspend = s3c_fb_runtime_suspend,
  1516. .runtime_resume = s3c_fb_runtime_resume,
  1517. };
  1518. static struct platform_driver s3c_fb_driver = {
  1519. .probe = s3c_fb_probe,
  1520. .remove = __devexit_p(s3c_fb_remove),
  1521. .id_table = s3c_fb_driver_ids,
  1522. .driver = {
  1523. .name = "s3c-fb",
  1524. .owner = THIS_MODULE,
  1525. .pm = &s3cfb_pm_ops,
  1526. },
  1527. };
  1528. static int __init s3c_fb_init(void)
  1529. {
  1530. return platform_driver_register(&s3c_fb_driver);
  1531. }
  1532. static void __exit s3c_fb_cleanup(void)
  1533. {
  1534. platform_driver_unregister(&s3c_fb_driver);
  1535. }
  1536. module_init(s3c_fb_init);
  1537. module_exit(s3c_fb_cleanup);
  1538. MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
  1539. MODULE_DESCRIPTION("Samsung S3C SoC Framebuffer driver");
  1540. MODULE_LICENSE("GPL");
  1541. MODULE_ALIAS("platform:s3c-fb");