s3c-fb.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845
  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. ret = PTR_ERR(sfb->bus_clk);
  1126. goto err_sfb;
  1127. }
  1128. clk_enable(sfb->bus_clk);
  1129. pm_runtime_enable(sfb->dev);
  1130. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1131. if (!res) {
  1132. dev_err(dev, "failed to find registers\n");
  1133. ret = -ENOENT;
  1134. goto err_clk;
  1135. }
  1136. sfb->regs_res = request_mem_region(res->start, resource_size(res),
  1137. dev_name(dev));
  1138. if (!sfb->regs_res) {
  1139. dev_err(dev, "failed to claim register region\n");
  1140. ret = -ENOENT;
  1141. goto err_clk;
  1142. }
  1143. sfb->regs = ioremap(res->start, resource_size(res));
  1144. if (!sfb->regs) {
  1145. dev_err(dev, "failed to map registers\n");
  1146. ret = -ENXIO;
  1147. goto err_req_region;
  1148. }
  1149. res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  1150. if (!res) {
  1151. dev_err(dev, "failed to acquire irq resource\n");
  1152. ret = -ENOENT;
  1153. goto err_ioremap;
  1154. }
  1155. sfb->irq_no = res->start;
  1156. ret = request_irq(sfb->irq_no, s3c_fb_irq,
  1157. 0, "s3c_fb", sfb);
  1158. if (ret) {
  1159. dev_err(dev, "irq request failed\n");
  1160. goto err_ioremap;
  1161. }
  1162. dev_dbg(dev, "got resources (regs %p), probing windows\n", sfb->regs);
  1163. platform_set_drvdata(pdev, sfb);
  1164. pm_runtime_get_sync(sfb->dev);
  1165. /* setup gpio and output polarity controls */
  1166. pd->setup_gpio();
  1167. writel(pd->vidcon1, sfb->regs + VIDCON1);
  1168. /* zero all windows before we do anything */
  1169. for (win = 0; win < fbdrv->variant.nr_windows; win++)
  1170. s3c_fb_clear_win(sfb, win);
  1171. /* initialise colour key controls */
  1172. for (win = 0; win < (fbdrv->variant.nr_windows - 1); win++) {
  1173. void __iomem *regs = sfb->regs + sfb->variant.keycon;
  1174. regs += (win * 8);
  1175. writel(0xffffff, regs + WKEYCON0);
  1176. writel(0xffffff, regs + WKEYCON1);
  1177. }
  1178. /* we have the register setup, start allocating framebuffers */
  1179. for (win = 0; win < fbdrv->variant.nr_windows; win++) {
  1180. if (!pd->win[win])
  1181. continue;
  1182. if (!pd->win[win]->win_mode.pixclock)
  1183. s3c_fb_missing_pixclock(&pd->win[win]->win_mode);
  1184. ret = s3c_fb_probe_win(sfb, win, fbdrv->win[win],
  1185. &sfb->windows[win]);
  1186. if (ret < 0) {
  1187. dev_err(dev, "failed to create window %d\n", win);
  1188. for (; win >= 0; win--)
  1189. s3c_fb_release_win(sfb, sfb->windows[win]);
  1190. goto err_irq;
  1191. }
  1192. }
  1193. platform_set_drvdata(pdev, sfb);
  1194. pm_runtime_put_sync(sfb->dev);
  1195. return 0;
  1196. err_irq:
  1197. free_irq(sfb->irq_no, sfb);
  1198. err_ioremap:
  1199. iounmap(sfb->regs);
  1200. err_req_region:
  1201. release_resource(sfb->regs_res);
  1202. kfree(sfb->regs_res);
  1203. err_clk:
  1204. clk_disable(sfb->bus_clk);
  1205. clk_put(sfb->bus_clk);
  1206. err_sfb:
  1207. kfree(sfb);
  1208. return ret;
  1209. }
  1210. /**
  1211. * s3c_fb_remove() - Cleanup on module finalisation
  1212. * @pdev: The platform device we are bound to.
  1213. *
  1214. * Shutdown and then release all the resources that the driver allocated
  1215. * on initialisation.
  1216. */
  1217. static int __devexit s3c_fb_remove(struct platform_device *pdev)
  1218. {
  1219. struct s3c_fb *sfb = platform_get_drvdata(pdev);
  1220. int win;
  1221. pm_runtime_get_sync(sfb->dev);
  1222. for (win = 0; win < S3C_FB_MAX_WIN; win++)
  1223. if (sfb->windows[win])
  1224. s3c_fb_release_win(sfb, sfb->windows[win]);
  1225. free_irq(sfb->irq_no, sfb);
  1226. iounmap(sfb->regs);
  1227. clk_disable(sfb->bus_clk);
  1228. clk_put(sfb->bus_clk);
  1229. release_resource(sfb->regs_res);
  1230. kfree(sfb->regs_res);
  1231. kfree(sfb);
  1232. pm_runtime_put_sync(sfb->dev);
  1233. pm_runtime_disable(sfb->dev);
  1234. return 0;
  1235. }
  1236. #ifdef CONFIG_PM
  1237. static int s3c_fb_suspend(struct device *dev)
  1238. {
  1239. struct platform_device *pdev = to_platform_device(dev);
  1240. struct s3c_fb *sfb = platform_get_drvdata(pdev);
  1241. struct s3c_fb_win *win;
  1242. int win_no;
  1243. for (win_no = S3C_FB_MAX_WIN - 1; win_no >= 0; win_no--) {
  1244. win = sfb->windows[win_no];
  1245. if (!win)
  1246. continue;
  1247. /* use the blank function to push into power-down */
  1248. s3c_fb_blank(FB_BLANK_POWERDOWN, win->fbinfo);
  1249. }
  1250. clk_disable(sfb->bus_clk);
  1251. return 0;
  1252. }
  1253. static int s3c_fb_resume(struct device *dev)
  1254. {
  1255. struct platform_device *pdev = to_platform_device(dev);
  1256. struct s3c_fb *sfb = platform_get_drvdata(pdev);
  1257. struct s3c_fb_platdata *pd = sfb->pdata;
  1258. struct s3c_fb_win *win;
  1259. int win_no;
  1260. clk_enable(sfb->bus_clk);
  1261. /* setup registers */
  1262. writel(pd->vidcon1, sfb->regs + VIDCON1);
  1263. /* zero all windows before we do anything */
  1264. for (win_no = 0; win_no < sfb->variant.nr_windows; win_no++)
  1265. s3c_fb_clear_win(sfb, win_no);
  1266. for (win_no = 0; win_no < sfb->variant.nr_windows - 1; win_no++) {
  1267. void __iomem *regs = sfb->regs + sfb->variant.keycon;
  1268. regs += (win_no * 8);
  1269. writel(0xffffff, regs + WKEYCON0);
  1270. writel(0xffffff, regs + WKEYCON1);
  1271. }
  1272. /* restore framebuffers */
  1273. for (win_no = 0; win_no < S3C_FB_MAX_WIN; win_no++) {
  1274. win = sfb->windows[win_no];
  1275. if (!win)
  1276. continue;
  1277. dev_dbg(&pdev->dev, "resuming window %d\n", win_no);
  1278. s3c_fb_set_par(win->fbinfo);
  1279. }
  1280. return 0;
  1281. }
  1282. int s3c_fb_runtime_suspend(struct device *dev)
  1283. {
  1284. struct platform_device *pdev = to_platform_device(dev);
  1285. struct s3c_fb *sfb = platform_get_drvdata(pdev);
  1286. struct s3c_fb_win *win;
  1287. int win_no;
  1288. for (win_no = S3C_FB_MAX_WIN - 1; win_no >= 0; win_no--) {
  1289. win = sfb->windows[win_no];
  1290. if (!win)
  1291. continue;
  1292. /* use the blank function to push into power-down */
  1293. s3c_fb_blank(FB_BLANK_POWERDOWN, win->fbinfo);
  1294. }
  1295. clk_disable(sfb->bus_clk);
  1296. return 0;
  1297. }
  1298. int s3c_fb_runtime_resume(struct device *dev)
  1299. {
  1300. struct platform_device *pdev = to_platform_device(dev);
  1301. struct s3c_fb *sfb = platform_get_drvdata(pdev);
  1302. struct s3c_fb_platdata *pd = sfb->pdata;
  1303. struct s3c_fb_win *win;
  1304. int win_no;
  1305. clk_enable(sfb->bus_clk);
  1306. /* setup registers */
  1307. writel(pd->vidcon1, sfb->regs + VIDCON1);
  1308. /* zero all windows before we do anything */
  1309. for (win_no = 0; win_no < sfb->variant.nr_windows; win_no++)
  1310. s3c_fb_clear_win(sfb, win_no);
  1311. for (win_no = 0; win_no < sfb->variant.nr_windows - 1; win_no++) {
  1312. void __iomem *regs = sfb->regs + sfb->variant.keycon;
  1313. regs += (win_no * 8);
  1314. writel(0xffffff, regs + WKEYCON0);
  1315. writel(0xffffff, regs + WKEYCON1);
  1316. }
  1317. /* restore framebuffers */
  1318. for (win_no = 0; win_no < S3C_FB_MAX_WIN; win_no++) {
  1319. win = sfb->windows[win_no];
  1320. if (!win)
  1321. continue;
  1322. dev_dbg(&pdev->dev, "resuming window %d\n", win_no);
  1323. s3c_fb_set_par(win->fbinfo);
  1324. }
  1325. return 0;
  1326. }
  1327. #else
  1328. #define s3c_fb_suspend NULL
  1329. #define s3c_fb_resume NULL
  1330. #define s3c_fb_runtime_suspend NULL
  1331. #define s3c_fb_runtime_resume NULL
  1332. #endif
  1333. #define VALID_BPP124 (VALID_BPP(1) | VALID_BPP(2) | VALID_BPP(4))
  1334. #define VALID_BPP1248 (VALID_BPP124 | VALID_BPP(8))
  1335. static struct s3c_fb_win_variant s3c_fb_data_64xx_wins[] = {
  1336. [0] = {
  1337. .has_osd_c = 1,
  1338. .osd_size_off = 0x8,
  1339. .palette_sz = 256,
  1340. .valid_bpp = VALID_BPP1248 | VALID_BPP(16) | VALID_BPP(24),
  1341. },
  1342. [1] = {
  1343. .has_osd_c = 1,
  1344. .has_osd_d = 1,
  1345. .osd_size_off = 0x12,
  1346. .has_osd_alpha = 1,
  1347. .palette_sz = 256,
  1348. .valid_bpp = (VALID_BPP1248 | VALID_BPP(16) |
  1349. VALID_BPP(18) | VALID_BPP(19) |
  1350. VALID_BPP(24) | VALID_BPP(25)),
  1351. },
  1352. [2] = {
  1353. .has_osd_c = 1,
  1354. .has_osd_d = 1,
  1355. .osd_size_off = 0x12,
  1356. .has_osd_alpha = 1,
  1357. .palette_sz = 16,
  1358. .palette_16bpp = 1,
  1359. .valid_bpp = (VALID_BPP1248 | VALID_BPP(16) |
  1360. VALID_BPP(18) | VALID_BPP(19) |
  1361. VALID_BPP(24) | VALID_BPP(25)),
  1362. },
  1363. [3] = {
  1364. .has_osd_c = 1,
  1365. .has_osd_alpha = 1,
  1366. .palette_sz = 16,
  1367. .palette_16bpp = 1,
  1368. .valid_bpp = (VALID_BPP124 | VALID_BPP(16) |
  1369. VALID_BPP(18) | VALID_BPP(19) |
  1370. VALID_BPP(24) | VALID_BPP(25)),
  1371. },
  1372. [4] = {
  1373. .has_osd_c = 1,
  1374. .has_osd_alpha = 1,
  1375. .palette_sz = 4,
  1376. .palette_16bpp = 1,
  1377. .valid_bpp = (VALID_BPP(1) | VALID_BPP(2) |
  1378. VALID_BPP(16) | VALID_BPP(18) |
  1379. VALID_BPP(24) | VALID_BPP(25)),
  1380. },
  1381. };
  1382. static struct s3c_fb_driverdata s3c_fb_data_64xx = {
  1383. .variant = {
  1384. .nr_windows = 5,
  1385. .vidtcon = VIDTCON0,
  1386. .wincon = WINCON(0),
  1387. .winmap = WINxMAP(0),
  1388. .keycon = WKEYCON,
  1389. .osd = VIDOSD_BASE,
  1390. .osd_stride = 16,
  1391. .buf_start = VIDW_BUF_START(0),
  1392. .buf_size = VIDW_BUF_SIZE(0),
  1393. .buf_end = VIDW_BUF_END(0),
  1394. .palette = {
  1395. [0] = 0x400,
  1396. [1] = 0x800,
  1397. [2] = 0x300,
  1398. [3] = 0x320,
  1399. [4] = 0x340,
  1400. },
  1401. .has_prtcon = 1,
  1402. },
  1403. .win[0] = &s3c_fb_data_64xx_wins[0],
  1404. .win[1] = &s3c_fb_data_64xx_wins[1],
  1405. .win[2] = &s3c_fb_data_64xx_wins[2],
  1406. .win[3] = &s3c_fb_data_64xx_wins[3],
  1407. .win[4] = &s3c_fb_data_64xx_wins[4],
  1408. };
  1409. static struct s3c_fb_driverdata s3c_fb_data_s5pc100 = {
  1410. .variant = {
  1411. .nr_windows = 5,
  1412. .vidtcon = VIDTCON0,
  1413. .wincon = WINCON(0),
  1414. .winmap = WINxMAP(0),
  1415. .keycon = WKEYCON,
  1416. .osd = VIDOSD_BASE,
  1417. .osd_stride = 16,
  1418. .buf_start = VIDW_BUF_START(0),
  1419. .buf_size = VIDW_BUF_SIZE(0),
  1420. .buf_end = VIDW_BUF_END(0),
  1421. .palette = {
  1422. [0] = 0x2400,
  1423. [1] = 0x2800,
  1424. [2] = 0x2c00,
  1425. [3] = 0x3000,
  1426. [4] = 0x3400,
  1427. },
  1428. .has_prtcon = 1,
  1429. },
  1430. .win[0] = &s3c_fb_data_64xx_wins[0],
  1431. .win[1] = &s3c_fb_data_64xx_wins[1],
  1432. .win[2] = &s3c_fb_data_64xx_wins[2],
  1433. .win[3] = &s3c_fb_data_64xx_wins[3],
  1434. .win[4] = &s3c_fb_data_64xx_wins[4],
  1435. };
  1436. static struct s3c_fb_driverdata s3c_fb_data_s5pv210 = {
  1437. .variant = {
  1438. .nr_windows = 5,
  1439. .vidtcon = VIDTCON0,
  1440. .wincon = WINCON(0),
  1441. .winmap = WINxMAP(0),
  1442. .keycon = WKEYCON,
  1443. .osd = VIDOSD_BASE,
  1444. .osd_stride = 16,
  1445. .buf_start = VIDW_BUF_START(0),
  1446. .buf_size = VIDW_BUF_SIZE(0),
  1447. .buf_end = VIDW_BUF_END(0),
  1448. .palette = {
  1449. [0] = 0x2400,
  1450. [1] = 0x2800,
  1451. [2] = 0x2c00,
  1452. [3] = 0x3000,
  1453. [4] = 0x3400,
  1454. },
  1455. .has_shadowcon = 1,
  1456. },
  1457. .win[0] = &s3c_fb_data_64xx_wins[0],
  1458. .win[1] = &s3c_fb_data_64xx_wins[1],
  1459. .win[2] = &s3c_fb_data_64xx_wins[2],
  1460. .win[3] = &s3c_fb_data_64xx_wins[3],
  1461. .win[4] = &s3c_fb_data_64xx_wins[4],
  1462. };
  1463. /* S3C2443/S3C2416 style hardware */
  1464. static struct s3c_fb_driverdata s3c_fb_data_s3c2443 = {
  1465. .variant = {
  1466. .nr_windows = 2,
  1467. .is_2443 = 1,
  1468. .vidtcon = 0x08,
  1469. .wincon = 0x14,
  1470. .winmap = 0xd0,
  1471. .keycon = 0xb0,
  1472. .osd = 0x28,
  1473. .osd_stride = 12,
  1474. .buf_start = 0x64,
  1475. .buf_size = 0x94,
  1476. .buf_end = 0x7c,
  1477. .palette = {
  1478. [0] = 0x400,
  1479. [1] = 0x800,
  1480. },
  1481. },
  1482. .win[0] = &(struct s3c_fb_win_variant) {
  1483. .palette_sz = 256,
  1484. .valid_bpp = VALID_BPP1248 | VALID_BPP(16) | VALID_BPP(24),
  1485. },
  1486. .win[1] = &(struct s3c_fb_win_variant) {
  1487. .has_osd_c = 1,
  1488. .has_osd_alpha = 1,
  1489. .palette_sz = 256,
  1490. .valid_bpp = (VALID_BPP1248 | VALID_BPP(16) |
  1491. VALID_BPP(18) | VALID_BPP(19) |
  1492. VALID_BPP(24) | VALID_BPP(25) |
  1493. VALID_BPP(28)),
  1494. },
  1495. };
  1496. static struct platform_device_id s3c_fb_driver_ids[] = {
  1497. {
  1498. .name = "s3c-fb",
  1499. .driver_data = (unsigned long)&s3c_fb_data_64xx,
  1500. }, {
  1501. .name = "s5pc100-fb",
  1502. .driver_data = (unsigned long)&s3c_fb_data_s5pc100,
  1503. }, {
  1504. .name = "s5pv210-fb",
  1505. .driver_data = (unsigned long)&s3c_fb_data_s5pv210,
  1506. }, {
  1507. .name = "s3c2443-fb",
  1508. .driver_data = (unsigned long)&s3c_fb_data_s3c2443,
  1509. },
  1510. {},
  1511. };
  1512. MODULE_DEVICE_TABLE(platform, s3c_fb_driver_ids);
  1513. static const struct dev_pm_ops s3cfb_pm_ops = {
  1514. .suspend = s3c_fb_suspend,
  1515. .resume = s3c_fb_resume,
  1516. .runtime_suspend = s3c_fb_runtime_suspend,
  1517. .runtime_resume = s3c_fb_runtime_resume,
  1518. };
  1519. static struct platform_driver s3c_fb_driver = {
  1520. .probe = s3c_fb_probe,
  1521. .remove = __devexit_p(s3c_fb_remove),
  1522. .id_table = s3c_fb_driver_ids,
  1523. .driver = {
  1524. .name = "s3c-fb",
  1525. .owner = THIS_MODULE,
  1526. .pm = &s3cfb_pm_ops,
  1527. },
  1528. };
  1529. static int __init s3c_fb_init(void)
  1530. {
  1531. return platform_driver_register(&s3c_fb_driver);
  1532. }
  1533. static void __exit s3c_fb_cleanup(void)
  1534. {
  1535. platform_driver_unregister(&s3c_fb_driver);
  1536. }
  1537. module_init(s3c_fb_init);
  1538. module_exit(s3c_fb_cleanup);
  1539. MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
  1540. MODULE_DESCRIPTION("Samsung S3C SoC Framebuffer driver");
  1541. MODULE_LICENSE("GPL");
  1542. MODULE_ALIAS("platform:s3c-fb");