sh_mobile_lcdcfb.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200
  1. /*
  2. * SuperH Mobile LCDC Framebuffer
  3. *
  4. * Copyright (c) 2008 Magnus Damm
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/delay.h>
  13. #include <linux/mm.h>
  14. #include <linux/fb.h>
  15. #include <linux/clk.h>
  16. #include <linux/pm_runtime.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/dma-mapping.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/vmalloc.h>
  21. #include <linux/ioctl.h>
  22. #include <linux/slab.h>
  23. #include <video/sh_mobile_lcdc.h>
  24. #include <asm/atomic.h>
  25. #define PALETTE_NR 16
  26. #define SIDE_B_OFFSET 0x1000
  27. #define MIRROR_OFFSET 0x2000
  28. /* shared registers */
  29. #define _LDDCKR 0x410
  30. #define _LDDCKSTPR 0x414
  31. #define _LDINTR 0x468
  32. #define _LDSR 0x46c
  33. #define _LDCNT1R 0x470
  34. #define _LDCNT2R 0x474
  35. #define _LDRCNTR 0x478
  36. #define _LDDDSR 0x47c
  37. #define _LDDWD0R 0x800
  38. #define _LDDRDR 0x840
  39. #define _LDDWAR 0x900
  40. #define _LDDRAR 0x904
  41. /* shared registers and their order for context save/restore */
  42. static int lcdc_shared_regs[] = {
  43. _LDDCKR,
  44. _LDDCKSTPR,
  45. _LDINTR,
  46. _LDDDSR,
  47. _LDCNT1R,
  48. _LDCNT2R,
  49. };
  50. #define NR_SHARED_REGS ARRAY_SIZE(lcdc_shared_regs)
  51. /* per-channel registers */
  52. enum { LDDCKPAT1R, LDDCKPAT2R, LDMT1R, LDMT2R, LDMT3R, LDDFR, LDSM1R,
  53. LDSM2R, LDSA1R, LDMLSR, LDHCNR, LDHSYNR, LDVLNR, LDVSYNR, LDPMR,
  54. NR_CH_REGS };
  55. static unsigned long lcdc_offs_mainlcd[NR_CH_REGS] = {
  56. [LDDCKPAT1R] = 0x400,
  57. [LDDCKPAT2R] = 0x404,
  58. [LDMT1R] = 0x418,
  59. [LDMT2R] = 0x41c,
  60. [LDMT3R] = 0x420,
  61. [LDDFR] = 0x424,
  62. [LDSM1R] = 0x428,
  63. [LDSM2R] = 0x42c,
  64. [LDSA1R] = 0x430,
  65. [LDMLSR] = 0x438,
  66. [LDHCNR] = 0x448,
  67. [LDHSYNR] = 0x44c,
  68. [LDVLNR] = 0x450,
  69. [LDVSYNR] = 0x454,
  70. [LDPMR] = 0x460,
  71. };
  72. static unsigned long lcdc_offs_sublcd[NR_CH_REGS] = {
  73. [LDDCKPAT1R] = 0x408,
  74. [LDDCKPAT2R] = 0x40c,
  75. [LDMT1R] = 0x600,
  76. [LDMT2R] = 0x604,
  77. [LDMT3R] = 0x608,
  78. [LDDFR] = 0x60c,
  79. [LDSM1R] = 0x610,
  80. [LDSM2R] = 0x614,
  81. [LDSA1R] = 0x618,
  82. [LDMLSR] = 0x620,
  83. [LDHCNR] = 0x624,
  84. [LDHSYNR] = 0x628,
  85. [LDVLNR] = 0x62c,
  86. [LDVSYNR] = 0x630,
  87. [LDPMR] = 0x63c,
  88. };
  89. #define START_LCDC 0x00000001
  90. #define LCDC_RESET 0x00000100
  91. #define DISPLAY_BEU 0x00000008
  92. #define LCDC_ENABLE 0x00000001
  93. #define LDINTR_FE 0x00000400
  94. #define LDINTR_VSE 0x00000200
  95. #define LDINTR_VEE 0x00000100
  96. #define LDINTR_FS 0x00000004
  97. #define LDINTR_VSS 0x00000002
  98. #define LDINTR_VES 0x00000001
  99. #define LDRCNTR_SRS 0x00020000
  100. #define LDRCNTR_SRC 0x00010000
  101. #define LDRCNTR_MRS 0x00000002
  102. #define LDRCNTR_MRC 0x00000001
  103. #define LDSR_MRS 0x00000100
  104. struct sh_mobile_lcdc_priv;
  105. struct sh_mobile_lcdc_chan {
  106. struct sh_mobile_lcdc_priv *lcdc;
  107. unsigned long *reg_offs;
  108. unsigned long ldmt1r_value;
  109. unsigned long enabled; /* ME and SE in LDCNT2R */
  110. struct sh_mobile_lcdc_chan_cfg cfg;
  111. u32 pseudo_palette[PALETTE_NR];
  112. unsigned long saved_ch_regs[NR_CH_REGS];
  113. struct fb_info *info;
  114. dma_addr_t dma_handle;
  115. struct fb_deferred_io defio;
  116. struct scatterlist *sglist;
  117. unsigned long frame_end;
  118. unsigned long pan_offset;
  119. wait_queue_head_t frame_end_wait;
  120. struct completion vsync_completion;
  121. };
  122. struct sh_mobile_lcdc_priv {
  123. void __iomem *base;
  124. int irq;
  125. atomic_t hw_usecnt;
  126. struct device *dev;
  127. struct clk *dot_clk;
  128. unsigned long lddckr;
  129. struct sh_mobile_lcdc_chan ch[2];
  130. unsigned long saved_shared_regs[NR_SHARED_REGS];
  131. int started;
  132. };
  133. static bool banked(int reg_nr)
  134. {
  135. switch (reg_nr) {
  136. case LDMT1R:
  137. case LDMT2R:
  138. case LDMT3R:
  139. case LDDFR:
  140. case LDSM1R:
  141. case LDSA1R:
  142. case LDMLSR:
  143. case LDHCNR:
  144. case LDHSYNR:
  145. case LDVLNR:
  146. case LDVSYNR:
  147. return true;
  148. }
  149. return false;
  150. }
  151. static void lcdc_write_chan(struct sh_mobile_lcdc_chan *chan,
  152. int reg_nr, unsigned long data)
  153. {
  154. iowrite32(data, chan->lcdc->base + chan->reg_offs[reg_nr]);
  155. if (banked(reg_nr))
  156. iowrite32(data, chan->lcdc->base + chan->reg_offs[reg_nr] +
  157. SIDE_B_OFFSET);
  158. }
  159. static void lcdc_write_chan_mirror(struct sh_mobile_lcdc_chan *chan,
  160. int reg_nr, unsigned long data)
  161. {
  162. iowrite32(data, chan->lcdc->base + chan->reg_offs[reg_nr] +
  163. MIRROR_OFFSET);
  164. }
  165. static unsigned long lcdc_read_chan(struct sh_mobile_lcdc_chan *chan,
  166. int reg_nr)
  167. {
  168. return ioread32(chan->lcdc->base + chan->reg_offs[reg_nr]);
  169. }
  170. static void lcdc_write(struct sh_mobile_lcdc_priv *priv,
  171. unsigned long reg_offs, unsigned long data)
  172. {
  173. iowrite32(data, priv->base + reg_offs);
  174. }
  175. static unsigned long lcdc_read(struct sh_mobile_lcdc_priv *priv,
  176. unsigned long reg_offs)
  177. {
  178. return ioread32(priv->base + reg_offs);
  179. }
  180. static void lcdc_wait_bit(struct sh_mobile_lcdc_priv *priv,
  181. unsigned long reg_offs,
  182. unsigned long mask, unsigned long until)
  183. {
  184. while ((lcdc_read(priv, reg_offs) & mask) != until)
  185. cpu_relax();
  186. }
  187. static int lcdc_chan_is_sublcd(struct sh_mobile_lcdc_chan *chan)
  188. {
  189. return chan->cfg.chan == LCDC_CHAN_SUBLCD;
  190. }
  191. static void lcdc_sys_write_index(void *handle, unsigned long data)
  192. {
  193. struct sh_mobile_lcdc_chan *ch = handle;
  194. lcdc_write(ch->lcdc, _LDDWD0R, data | 0x10000000);
  195. lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0);
  196. lcdc_write(ch->lcdc, _LDDWAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0));
  197. lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0);
  198. }
  199. static void lcdc_sys_write_data(void *handle, unsigned long data)
  200. {
  201. struct sh_mobile_lcdc_chan *ch = handle;
  202. lcdc_write(ch->lcdc, _LDDWD0R, data | 0x11000000);
  203. lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0);
  204. lcdc_write(ch->lcdc, _LDDWAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0));
  205. lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0);
  206. }
  207. static unsigned long lcdc_sys_read_data(void *handle)
  208. {
  209. struct sh_mobile_lcdc_chan *ch = handle;
  210. lcdc_write(ch->lcdc, _LDDRDR, 0x01000000);
  211. lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0);
  212. lcdc_write(ch->lcdc, _LDDRAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0));
  213. udelay(1);
  214. lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0);
  215. return lcdc_read(ch->lcdc, _LDDRDR) & 0x3ffff;
  216. }
  217. struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = {
  218. lcdc_sys_write_index,
  219. lcdc_sys_write_data,
  220. lcdc_sys_read_data,
  221. };
  222. static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv)
  223. {
  224. if (atomic_inc_and_test(&priv->hw_usecnt)) {
  225. pm_runtime_get_sync(priv->dev);
  226. if (priv->dot_clk)
  227. clk_enable(priv->dot_clk);
  228. }
  229. }
  230. static void sh_mobile_lcdc_clk_off(struct sh_mobile_lcdc_priv *priv)
  231. {
  232. if (atomic_sub_return(1, &priv->hw_usecnt) == -1) {
  233. if (priv->dot_clk)
  234. clk_disable(priv->dot_clk);
  235. pm_runtime_put(priv->dev);
  236. }
  237. }
  238. static int sh_mobile_lcdc_sginit(struct fb_info *info,
  239. struct list_head *pagelist)
  240. {
  241. struct sh_mobile_lcdc_chan *ch = info->par;
  242. unsigned int nr_pages_max = info->fix.smem_len >> PAGE_SHIFT;
  243. struct page *page;
  244. int nr_pages = 0;
  245. sg_init_table(ch->sglist, nr_pages_max);
  246. list_for_each_entry(page, pagelist, lru)
  247. sg_set_page(&ch->sglist[nr_pages++], page, PAGE_SIZE, 0);
  248. return nr_pages;
  249. }
  250. static void sh_mobile_lcdc_deferred_io(struct fb_info *info,
  251. struct list_head *pagelist)
  252. {
  253. struct sh_mobile_lcdc_chan *ch = info->par;
  254. struct sh_mobile_lcdc_board_cfg *bcfg = &ch->cfg.board_cfg;
  255. /* enable clocks before accessing hardware */
  256. sh_mobile_lcdc_clk_on(ch->lcdc);
  257. /*
  258. * It's possible to get here without anything on the pagelist via
  259. * sh_mobile_lcdc_deferred_io_touch() or via a userspace fsync()
  260. * invocation. In the former case, the acceleration routines are
  261. * stepped in to when using the framebuffer console causing the
  262. * workqueue to be scheduled without any dirty pages on the list.
  263. *
  264. * Despite this, a panel update is still needed given that the
  265. * acceleration routines have their own methods for writing in
  266. * that still need to be updated.
  267. *
  268. * The fsync() and empty pagelist case could be optimized for,
  269. * but we don't bother, as any application exhibiting such
  270. * behaviour is fundamentally broken anyways.
  271. */
  272. if (!list_empty(pagelist)) {
  273. unsigned int nr_pages = sh_mobile_lcdc_sginit(info, pagelist);
  274. /* trigger panel update */
  275. dma_map_sg(info->dev, ch->sglist, nr_pages, DMA_TO_DEVICE);
  276. if (bcfg->start_transfer)
  277. bcfg->start_transfer(bcfg->board_data, ch,
  278. &sh_mobile_lcdc_sys_bus_ops);
  279. lcdc_write_chan(ch, LDSM2R, 1);
  280. dma_unmap_sg(info->dev, ch->sglist, nr_pages, DMA_TO_DEVICE);
  281. } else {
  282. if (bcfg->start_transfer)
  283. bcfg->start_transfer(bcfg->board_data, ch,
  284. &sh_mobile_lcdc_sys_bus_ops);
  285. lcdc_write_chan(ch, LDSM2R, 1);
  286. }
  287. }
  288. static void sh_mobile_lcdc_deferred_io_touch(struct fb_info *info)
  289. {
  290. struct fb_deferred_io *fbdefio = info->fbdefio;
  291. if (fbdefio)
  292. schedule_delayed_work(&info->deferred_work, fbdefio->delay);
  293. }
  294. static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data)
  295. {
  296. struct sh_mobile_lcdc_priv *priv = data;
  297. struct sh_mobile_lcdc_chan *ch;
  298. unsigned long tmp;
  299. unsigned long ldintr;
  300. int is_sub;
  301. int k;
  302. /* acknowledge interrupt */
  303. ldintr = tmp = lcdc_read(priv, _LDINTR);
  304. /*
  305. * disable further VSYNC End IRQs, preserve all other enabled IRQs,
  306. * write 0 to bits 0-6 to ack all triggered IRQs.
  307. */
  308. tmp &= 0xffffff00 & ~LDINTR_VEE;
  309. lcdc_write(priv, _LDINTR, tmp);
  310. /* figure out if this interrupt is for main or sub lcd */
  311. is_sub = (lcdc_read(priv, _LDSR) & (1 << 10)) ? 1 : 0;
  312. /* wake up channel and disable clocks */
  313. for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
  314. ch = &priv->ch[k];
  315. if (!ch->enabled)
  316. continue;
  317. /* Frame Start */
  318. if (ldintr & LDINTR_FS) {
  319. if (is_sub == lcdc_chan_is_sublcd(ch)) {
  320. ch->frame_end = 1;
  321. wake_up(&ch->frame_end_wait);
  322. sh_mobile_lcdc_clk_off(priv);
  323. }
  324. }
  325. /* VSYNC End */
  326. if (ldintr & LDINTR_VES)
  327. complete(&ch->vsync_completion);
  328. }
  329. return IRQ_HANDLED;
  330. }
  331. static void sh_mobile_lcdc_start_stop(struct sh_mobile_lcdc_priv *priv,
  332. int start)
  333. {
  334. unsigned long tmp = lcdc_read(priv, _LDCNT2R);
  335. int k;
  336. /* start or stop the lcdc */
  337. if (start)
  338. lcdc_write(priv, _LDCNT2R, tmp | START_LCDC);
  339. else
  340. lcdc_write(priv, _LDCNT2R, tmp & ~START_LCDC);
  341. /* wait until power is applied/stopped on all channels */
  342. for (k = 0; k < ARRAY_SIZE(priv->ch); k++)
  343. if (lcdc_read(priv, _LDCNT2R) & priv->ch[k].enabled)
  344. while (1) {
  345. tmp = lcdc_read_chan(&priv->ch[k], LDPMR) & 3;
  346. if (start && tmp == 3)
  347. break;
  348. if (!start && tmp == 0)
  349. break;
  350. cpu_relax();
  351. }
  352. if (!start)
  353. lcdc_write(priv, _LDDCKSTPR, 1); /* stop dotclock */
  354. }
  355. static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
  356. {
  357. struct sh_mobile_lcdc_chan *ch;
  358. struct fb_videomode *lcd_cfg;
  359. struct sh_mobile_lcdc_board_cfg *board_cfg;
  360. unsigned long tmp;
  361. int k, m;
  362. int ret = 0;
  363. /* enable clocks before accessing the hardware */
  364. for (k = 0; k < ARRAY_SIZE(priv->ch); k++)
  365. if (priv->ch[k].enabled)
  366. sh_mobile_lcdc_clk_on(priv);
  367. /* reset */
  368. lcdc_write(priv, _LDCNT2R, lcdc_read(priv, _LDCNT2R) | LCDC_RESET);
  369. lcdc_wait_bit(priv, _LDCNT2R, LCDC_RESET, 0);
  370. /* enable LCDC channels */
  371. tmp = lcdc_read(priv, _LDCNT2R);
  372. tmp |= priv->ch[0].enabled;
  373. tmp |= priv->ch[1].enabled;
  374. lcdc_write(priv, _LDCNT2R, tmp);
  375. /* read data from external memory, avoid using the BEU for now */
  376. lcdc_write(priv, _LDCNT2R, lcdc_read(priv, _LDCNT2R) & ~DISPLAY_BEU);
  377. /* stop the lcdc first */
  378. sh_mobile_lcdc_start_stop(priv, 0);
  379. /* configure clocks */
  380. tmp = priv->lddckr;
  381. for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
  382. ch = &priv->ch[k];
  383. if (!priv->ch[k].enabled)
  384. continue;
  385. m = ch->cfg.clock_divider;
  386. if (!m)
  387. continue;
  388. if (m == 1)
  389. m = 1 << 6;
  390. tmp |= m << (lcdc_chan_is_sublcd(ch) ? 8 : 0);
  391. lcdc_write_chan(ch, LDDCKPAT1R, 0x00000000);
  392. lcdc_write_chan(ch, LDDCKPAT2R, (1 << (m/2)) - 1);
  393. }
  394. lcdc_write(priv, _LDDCKR, tmp);
  395. /* start dotclock again */
  396. lcdc_write(priv, _LDDCKSTPR, 0);
  397. lcdc_wait_bit(priv, _LDDCKSTPR, ~0, 0);
  398. /* interrupts are disabled to begin with */
  399. lcdc_write(priv, _LDINTR, 0);
  400. for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
  401. ch = &priv->ch[k];
  402. lcd_cfg = &ch->cfg.lcd_cfg;
  403. if (!ch->enabled)
  404. continue;
  405. tmp = ch->ldmt1r_value;
  406. tmp |= (lcd_cfg->sync & FB_SYNC_VERT_HIGH_ACT) ? 0 : 1 << 28;
  407. tmp |= (lcd_cfg->sync & FB_SYNC_HOR_HIGH_ACT) ? 0 : 1 << 27;
  408. tmp |= (ch->cfg.flags & LCDC_FLAGS_DWPOL) ? 1 << 26 : 0;
  409. tmp |= (ch->cfg.flags & LCDC_FLAGS_DIPOL) ? 1 << 25 : 0;
  410. tmp |= (ch->cfg.flags & LCDC_FLAGS_DAPOL) ? 1 << 24 : 0;
  411. tmp |= (ch->cfg.flags & LCDC_FLAGS_HSCNT) ? 1 << 17 : 0;
  412. tmp |= (ch->cfg.flags & LCDC_FLAGS_DWCNT) ? 1 << 16 : 0;
  413. lcdc_write_chan(ch, LDMT1R, tmp);
  414. /* setup SYS bus */
  415. lcdc_write_chan(ch, LDMT2R, ch->cfg.sys_bus_cfg.ldmt2r);
  416. lcdc_write_chan(ch, LDMT3R, ch->cfg.sys_bus_cfg.ldmt3r);
  417. /* horizontal configuration */
  418. tmp = lcd_cfg->xres + lcd_cfg->hsync_len;
  419. tmp += lcd_cfg->left_margin;
  420. tmp += lcd_cfg->right_margin;
  421. tmp /= 8; /* HTCN */
  422. tmp |= (lcd_cfg->xres / 8) << 16; /* HDCN */
  423. lcdc_write_chan(ch, LDHCNR, tmp);
  424. tmp = lcd_cfg->xres;
  425. tmp += lcd_cfg->right_margin;
  426. tmp /= 8; /* HSYNP */
  427. tmp |= (lcd_cfg->hsync_len / 8) << 16; /* HSYNW */
  428. lcdc_write_chan(ch, LDHSYNR, tmp);
  429. /* power supply */
  430. lcdc_write_chan(ch, LDPMR, 0);
  431. /* vertical configuration */
  432. tmp = lcd_cfg->yres + lcd_cfg->vsync_len;
  433. tmp += lcd_cfg->upper_margin;
  434. tmp += lcd_cfg->lower_margin; /* VTLN */
  435. tmp |= lcd_cfg->yres << 16; /* VDLN */
  436. lcdc_write_chan(ch, LDVLNR, tmp);
  437. tmp = lcd_cfg->yres;
  438. tmp += lcd_cfg->lower_margin; /* VSYNP */
  439. tmp |= lcd_cfg->vsync_len << 16; /* VSYNW */
  440. lcdc_write_chan(ch, LDVSYNR, tmp);
  441. board_cfg = &ch->cfg.board_cfg;
  442. if (board_cfg->setup_sys)
  443. ret = board_cfg->setup_sys(board_cfg->board_data, ch,
  444. &sh_mobile_lcdc_sys_bus_ops);
  445. if (ret)
  446. return ret;
  447. }
  448. /* word and long word swap */
  449. lcdc_write(priv, _LDDDSR, lcdc_read(priv, _LDDDSR) | 6);
  450. for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
  451. ch = &priv->ch[k];
  452. if (!priv->ch[k].enabled)
  453. continue;
  454. /* set bpp format in PKF[4:0] */
  455. tmp = lcdc_read_chan(ch, LDDFR);
  456. tmp &= ~(0x0001001f);
  457. tmp |= (ch->info->var.bits_per_pixel == 16) ? 3 : 0;
  458. lcdc_write_chan(ch, LDDFR, tmp);
  459. /* point out our frame buffer */
  460. lcdc_write_chan(ch, LDSA1R, ch->info->fix.smem_start);
  461. /* set line size */
  462. lcdc_write_chan(ch, LDMLSR, ch->info->fix.line_length);
  463. /* setup deferred io if SYS bus */
  464. tmp = ch->cfg.sys_bus_cfg.deferred_io_msec;
  465. if (ch->ldmt1r_value & (1 << 12) && tmp) {
  466. ch->defio.deferred_io = sh_mobile_lcdc_deferred_io;
  467. ch->defio.delay = msecs_to_jiffies(tmp);
  468. ch->info->fbdefio = &ch->defio;
  469. fb_deferred_io_init(ch->info);
  470. /* one-shot mode */
  471. lcdc_write_chan(ch, LDSM1R, 1);
  472. /* enable "Frame End Interrupt Enable" bit */
  473. lcdc_write(priv, _LDINTR, LDINTR_FE);
  474. } else {
  475. /* continuous read mode */
  476. lcdc_write_chan(ch, LDSM1R, 0);
  477. }
  478. }
  479. /* display output */
  480. lcdc_write(priv, _LDCNT1R, LCDC_ENABLE);
  481. /* start the lcdc */
  482. sh_mobile_lcdc_start_stop(priv, 1);
  483. priv->started = 1;
  484. /* tell the board code to enable the panel */
  485. for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
  486. ch = &priv->ch[k];
  487. if (!ch->enabled)
  488. continue;
  489. board_cfg = &ch->cfg.board_cfg;
  490. if (board_cfg->display_on)
  491. board_cfg->display_on(board_cfg->board_data);
  492. }
  493. return 0;
  494. }
  495. static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
  496. {
  497. struct sh_mobile_lcdc_chan *ch;
  498. struct sh_mobile_lcdc_board_cfg *board_cfg;
  499. int k;
  500. /* clean up deferred io and ask board code to disable panel */
  501. for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
  502. ch = &priv->ch[k];
  503. if (!ch->enabled)
  504. continue;
  505. /* deferred io mode:
  506. * flush frame, and wait for frame end interrupt
  507. * clean up deferred io and enable clock
  508. */
  509. if (ch->info->fbdefio) {
  510. ch->frame_end = 0;
  511. schedule_delayed_work(&ch->info->deferred_work, 0);
  512. wait_event(ch->frame_end_wait, ch->frame_end);
  513. fb_deferred_io_cleanup(ch->info);
  514. ch->info->fbdefio = NULL;
  515. sh_mobile_lcdc_clk_on(priv);
  516. }
  517. board_cfg = &ch->cfg.board_cfg;
  518. if (board_cfg->display_off)
  519. board_cfg->display_off(board_cfg->board_data);
  520. }
  521. /* stop the lcdc */
  522. if (priv->started) {
  523. sh_mobile_lcdc_start_stop(priv, 0);
  524. priv->started = 0;
  525. }
  526. /* stop clocks */
  527. for (k = 0; k < ARRAY_SIZE(priv->ch); k++)
  528. if (priv->ch[k].enabled)
  529. sh_mobile_lcdc_clk_off(priv);
  530. }
  531. static int sh_mobile_lcdc_check_interface(struct sh_mobile_lcdc_chan *ch)
  532. {
  533. int ifm, miftyp;
  534. switch (ch->cfg.interface_type) {
  535. case RGB8: ifm = 0; miftyp = 0; break;
  536. case RGB9: ifm = 0; miftyp = 4; break;
  537. case RGB12A: ifm = 0; miftyp = 5; break;
  538. case RGB12B: ifm = 0; miftyp = 6; break;
  539. case RGB16: ifm = 0; miftyp = 7; break;
  540. case RGB18: ifm = 0; miftyp = 10; break;
  541. case RGB24: ifm = 0; miftyp = 11; break;
  542. case SYS8A: ifm = 1; miftyp = 0; break;
  543. case SYS8B: ifm = 1; miftyp = 1; break;
  544. case SYS8C: ifm = 1; miftyp = 2; break;
  545. case SYS8D: ifm = 1; miftyp = 3; break;
  546. case SYS9: ifm = 1; miftyp = 4; break;
  547. case SYS12: ifm = 1; miftyp = 5; break;
  548. case SYS16A: ifm = 1; miftyp = 7; break;
  549. case SYS16B: ifm = 1; miftyp = 8; break;
  550. case SYS16C: ifm = 1; miftyp = 9; break;
  551. case SYS18: ifm = 1; miftyp = 10; break;
  552. case SYS24: ifm = 1; miftyp = 11; break;
  553. default: goto bad;
  554. }
  555. /* SUBLCD only supports SYS interface */
  556. if (lcdc_chan_is_sublcd(ch)) {
  557. if (ifm == 0)
  558. goto bad;
  559. else
  560. ifm = 0;
  561. }
  562. ch->ldmt1r_value = (ifm << 12) | miftyp;
  563. return 0;
  564. bad:
  565. return -EINVAL;
  566. }
  567. static int sh_mobile_lcdc_setup_clocks(struct platform_device *pdev,
  568. int clock_source,
  569. struct sh_mobile_lcdc_priv *priv)
  570. {
  571. char *str;
  572. int icksel;
  573. switch (clock_source) {
  574. case LCDC_CLK_BUS: str = "bus_clk"; icksel = 0; break;
  575. case LCDC_CLK_PERIPHERAL: str = "peripheral_clk"; icksel = 1; break;
  576. case LCDC_CLK_EXTERNAL: str = NULL; icksel = 2; break;
  577. default:
  578. return -EINVAL;
  579. }
  580. priv->lddckr = icksel << 16;
  581. if (str) {
  582. priv->dot_clk = clk_get(&pdev->dev, str);
  583. if (IS_ERR(priv->dot_clk)) {
  584. dev_err(&pdev->dev, "cannot get dot clock %s\n", str);
  585. return PTR_ERR(priv->dot_clk);
  586. }
  587. }
  588. atomic_set(&priv->hw_usecnt, -1);
  589. /* Runtime PM support involves two step for this driver:
  590. * 1) Enable Runtime PM
  591. * 2) Force Runtime PM Resume since hardware is accessed from probe()
  592. */
  593. priv->dev = &pdev->dev;
  594. pm_runtime_enable(priv->dev);
  595. pm_runtime_resume(priv->dev);
  596. return 0;
  597. }
  598. static int sh_mobile_lcdc_setcolreg(u_int regno,
  599. u_int red, u_int green, u_int blue,
  600. u_int transp, struct fb_info *info)
  601. {
  602. u32 *palette = info->pseudo_palette;
  603. if (regno >= PALETTE_NR)
  604. return -EINVAL;
  605. /* only FB_VISUAL_TRUECOLOR supported */
  606. red >>= 16 - info->var.red.length;
  607. green >>= 16 - info->var.green.length;
  608. blue >>= 16 - info->var.blue.length;
  609. transp >>= 16 - info->var.transp.length;
  610. palette[regno] = (red << info->var.red.offset) |
  611. (green << info->var.green.offset) |
  612. (blue << info->var.blue.offset) |
  613. (transp << info->var.transp.offset);
  614. return 0;
  615. }
  616. static struct fb_fix_screeninfo sh_mobile_lcdc_fix = {
  617. .id = "SH Mobile LCDC",
  618. .type = FB_TYPE_PACKED_PIXELS,
  619. .visual = FB_VISUAL_TRUECOLOR,
  620. .accel = FB_ACCEL_NONE,
  621. .xpanstep = 0,
  622. .ypanstep = 1,
  623. .ywrapstep = 0,
  624. };
  625. static void sh_mobile_lcdc_fillrect(struct fb_info *info,
  626. const struct fb_fillrect *rect)
  627. {
  628. sys_fillrect(info, rect);
  629. sh_mobile_lcdc_deferred_io_touch(info);
  630. }
  631. static void sh_mobile_lcdc_copyarea(struct fb_info *info,
  632. const struct fb_copyarea *area)
  633. {
  634. sys_copyarea(info, area);
  635. sh_mobile_lcdc_deferred_io_touch(info);
  636. }
  637. static void sh_mobile_lcdc_imageblit(struct fb_info *info,
  638. const struct fb_image *image)
  639. {
  640. sys_imageblit(info, image);
  641. sh_mobile_lcdc_deferred_io_touch(info);
  642. }
  643. static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
  644. struct fb_info *info)
  645. {
  646. struct sh_mobile_lcdc_chan *ch = info->par;
  647. struct sh_mobile_lcdc_priv *priv = ch->lcdc;
  648. unsigned long ldrcntr;
  649. unsigned long new_pan_offset;
  650. new_pan_offset = (var->yoffset * info->fix.line_length) +
  651. (var->xoffset * (info->var.bits_per_pixel / 8));
  652. if (new_pan_offset == ch->pan_offset)
  653. return 0; /* No change, do nothing */
  654. ldrcntr = lcdc_read(priv, _LDRCNTR);
  655. /* Set the source address for the next refresh */
  656. lcdc_write_chan_mirror(ch, LDSA1R, ch->dma_handle + new_pan_offset);
  657. if (lcdc_chan_is_sublcd(ch))
  658. lcdc_write(ch->lcdc, _LDRCNTR, ldrcntr ^ LDRCNTR_SRS);
  659. else
  660. lcdc_write(ch->lcdc, _LDRCNTR, ldrcntr ^ LDRCNTR_MRS);
  661. ch->pan_offset = new_pan_offset;
  662. sh_mobile_lcdc_deferred_io_touch(info);
  663. return 0;
  664. }
  665. static int sh_mobile_wait_for_vsync(struct fb_info *info)
  666. {
  667. struct sh_mobile_lcdc_chan *ch = info->par;
  668. unsigned long ldintr;
  669. int ret;
  670. /* Enable VSync End interrupt */
  671. ldintr = lcdc_read(ch->lcdc, _LDINTR);
  672. ldintr |= LDINTR_VEE;
  673. lcdc_write(ch->lcdc, _LDINTR, ldintr);
  674. ret = wait_for_completion_interruptible_timeout(&ch->vsync_completion,
  675. msecs_to_jiffies(100));
  676. if (!ret)
  677. return -ETIMEDOUT;
  678. return 0;
  679. }
  680. static int sh_mobile_ioctl(struct fb_info *info, unsigned int cmd,
  681. unsigned long arg)
  682. {
  683. int retval;
  684. switch (cmd) {
  685. case FBIO_WAITFORVSYNC:
  686. retval = sh_mobile_wait_for_vsync(info);
  687. break;
  688. default:
  689. retval = -ENOIOCTLCMD;
  690. break;
  691. }
  692. return retval;
  693. }
  694. static struct fb_ops sh_mobile_lcdc_ops = {
  695. .owner = THIS_MODULE,
  696. .fb_setcolreg = sh_mobile_lcdc_setcolreg,
  697. .fb_read = fb_sys_read,
  698. .fb_write = fb_sys_write,
  699. .fb_fillrect = sh_mobile_lcdc_fillrect,
  700. .fb_copyarea = sh_mobile_lcdc_copyarea,
  701. .fb_imageblit = sh_mobile_lcdc_imageblit,
  702. .fb_pan_display = sh_mobile_fb_pan_display,
  703. .fb_ioctl = sh_mobile_ioctl,
  704. };
  705. static int sh_mobile_lcdc_set_bpp(struct fb_var_screeninfo *var, int bpp)
  706. {
  707. switch (bpp) {
  708. case 16: /* PKF[4:0] = 00011 - RGB 565 */
  709. var->red.offset = 11;
  710. var->red.length = 5;
  711. var->green.offset = 5;
  712. var->green.length = 6;
  713. var->blue.offset = 0;
  714. var->blue.length = 5;
  715. var->transp.offset = 0;
  716. var->transp.length = 0;
  717. break;
  718. case 32: /* PKF[4:0] = 00000 - RGB 888
  719. * sh7722 pdf says 00RRGGBB but reality is GGBB00RR
  720. * this may be because LDDDSR has word swap enabled..
  721. */
  722. var->red.offset = 0;
  723. var->red.length = 8;
  724. var->green.offset = 24;
  725. var->green.length = 8;
  726. var->blue.offset = 16;
  727. var->blue.length = 8;
  728. var->transp.offset = 0;
  729. var->transp.length = 0;
  730. break;
  731. default:
  732. return -EINVAL;
  733. }
  734. var->bits_per_pixel = bpp;
  735. var->red.msb_right = 0;
  736. var->green.msb_right = 0;
  737. var->blue.msb_right = 0;
  738. var->transp.msb_right = 0;
  739. return 0;
  740. }
  741. static int sh_mobile_lcdc_suspend(struct device *dev)
  742. {
  743. struct platform_device *pdev = to_platform_device(dev);
  744. sh_mobile_lcdc_stop(platform_get_drvdata(pdev));
  745. return 0;
  746. }
  747. static int sh_mobile_lcdc_resume(struct device *dev)
  748. {
  749. struct platform_device *pdev = to_platform_device(dev);
  750. return sh_mobile_lcdc_start(platform_get_drvdata(pdev));
  751. }
  752. static int sh_mobile_lcdc_runtime_suspend(struct device *dev)
  753. {
  754. struct platform_device *pdev = to_platform_device(dev);
  755. struct sh_mobile_lcdc_priv *p = platform_get_drvdata(pdev);
  756. struct sh_mobile_lcdc_chan *ch;
  757. int k, n;
  758. /* save per-channel registers */
  759. for (k = 0; k < ARRAY_SIZE(p->ch); k++) {
  760. ch = &p->ch[k];
  761. if (!ch->enabled)
  762. continue;
  763. for (n = 0; n < NR_CH_REGS; n++)
  764. ch->saved_ch_regs[n] = lcdc_read_chan(ch, n);
  765. }
  766. /* save shared registers */
  767. for (n = 0; n < NR_SHARED_REGS; n++)
  768. p->saved_shared_regs[n] = lcdc_read(p, lcdc_shared_regs[n]);
  769. /* turn off LCDC hardware */
  770. lcdc_write(p, _LDCNT1R, 0);
  771. return 0;
  772. }
  773. static int sh_mobile_lcdc_runtime_resume(struct device *dev)
  774. {
  775. struct platform_device *pdev = to_platform_device(dev);
  776. struct sh_mobile_lcdc_priv *p = platform_get_drvdata(pdev);
  777. struct sh_mobile_lcdc_chan *ch;
  778. int k, n;
  779. /* restore per-channel registers */
  780. for (k = 0; k < ARRAY_SIZE(p->ch); k++) {
  781. ch = &p->ch[k];
  782. if (!ch->enabled)
  783. continue;
  784. for (n = 0; n < NR_CH_REGS; n++)
  785. lcdc_write_chan(ch, n, ch->saved_ch_regs[n]);
  786. }
  787. /* restore shared registers */
  788. for (n = 0; n < NR_SHARED_REGS; n++)
  789. lcdc_write(p, lcdc_shared_regs[n], p->saved_shared_regs[n]);
  790. return 0;
  791. }
  792. static const struct dev_pm_ops sh_mobile_lcdc_dev_pm_ops = {
  793. .suspend = sh_mobile_lcdc_suspend,
  794. .resume = sh_mobile_lcdc_resume,
  795. .runtime_suspend = sh_mobile_lcdc_runtime_suspend,
  796. .runtime_resume = sh_mobile_lcdc_runtime_resume,
  797. };
  798. static int sh_mobile_lcdc_remove(struct platform_device *pdev);
  799. static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
  800. {
  801. struct fb_info *info;
  802. struct sh_mobile_lcdc_priv *priv;
  803. struct sh_mobile_lcdc_info *pdata;
  804. struct sh_mobile_lcdc_chan_cfg *cfg;
  805. struct resource *res;
  806. int error;
  807. void *buf;
  808. int i, j;
  809. if (!pdev->dev.platform_data) {
  810. dev_err(&pdev->dev, "no platform data defined\n");
  811. return -EINVAL;
  812. }
  813. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  814. i = platform_get_irq(pdev, 0);
  815. if (!res || i < 0) {
  816. dev_err(&pdev->dev, "cannot get platform resources\n");
  817. return -ENOENT;
  818. }
  819. priv = kzalloc(sizeof(*priv), GFP_KERNEL);
  820. if (!priv) {
  821. dev_err(&pdev->dev, "cannot allocate device data\n");
  822. return -ENOMEM;
  823. }
  824. platform_set_drvdata(pdev, priv);
  825. error = request_irq(i, sh_mobile_lcdc_irq, IRQF_DISABLED,
  826. dev_name(&pdev->dev), priv);
  827. if (error) {
  828. dev_err(&pdev->dev, "unable to request irq\n");
  829. goto err1;
  830. }
  831. priv->irq = i;
  832. pdata = pdev->dev.platform_data;
  833. j = 0;
  834. for (i = 0; i < ARRAY_SIZE(pdata->ch); i++) {
  835. priv->ch[j].lcdc = priv;
  836. memcpy(&priv->ch[j].cfg, &pdata->ch[i], sizeof(pdata->ch[i]));
  837. error = sh_mobile_lcdc_check_interface(&priv->ch[j]);
  838. if (error) {
  839. dev_err(&pdev->dev, "unsupported interface type\n");
  840. goto err1;
  841. }
  842. init_waitqueue_head(&priv->ch[j].frame_end_wait);
  843. init_completion(&priv->ch[j].vsync_completion);
  844. priv->ch[j].pan_offset = 0;
  845. switch (pdata->ch[i].chan) {
  846. case LCDC_CHAN_MAINLCD:
  847. priv->ch[j].enabled = 1 << 1;
  848. priv->ch[j].reg_offs = lcdc_offs_mainlcd;
  849. j++;
  850. break;
  851. case LCDC_CHAN_SUBLCD:
  852. priv->ch[j].enabled = 1 << 2;
  853. priv->ch[j].reg_offs = lcdc_offs_sublcd;
  854. j++;
  855. break;
  856. }
  857. }
  858. if (!j) {
  859. dev_err(&pdev->dev, "no channels defined\n");
  860. error = -EINVAL;
  861. goto err1;
  862. }
  863. error = sh_mobile_lcdc_setup_clocks(pdev, pdata->clock_source, priv);
  864. if (error) {
  865. dev_err(&pdev->dev, "unable to setup clocks\n");
  866. goto err1;
  867. }
  868. priv->base = ioremap_nocache(res->start, (res->end - res->start) + 1);
  869. for (i = 0; i < j; i++) {
  870. cfg = &priv->ch[i].cfg;
  871. priv->ch[i].info = framebuffer_alloc(0, &pdev->dev);
  872. if (!priv->ch[i].info) {
  873. dev_err(&pdev->dev, "unable to allocate fb_info\n");
  874. error = -ENOMEM;
  875. break;
  876. }
  877. info = priv->ch[i].info;
  878. info->fbops = &sh_mobile_lcdc_ops;
  879. info->var.xres = info->var.xres_virtual = cfg->lcd_cfg.xres;
  880. info->var.yres = cfg->lcd_cfg.yres;
  881. /* Default Y virtual resolution is 2x panel size */
  882. info->var.yres_virtual = info->var.yres * 2;
  883. info->var.width = cfg->lcd_size_cfg.width;
  884. info->var.height = cfg->lcd_size_cfg.height;
  885. info->var.activate = FB_ACTIVATE_NOW;
  886. error = sh_mobile_lcdc_set_bpp(&info->var, cfg->bpp);
  887. if (error)
  888. break;
  889. info->fix = sh_mobile_lcdc_fix;
  890. info->fix.line_length = cfg->lcd_cfg.xres * (cfg->bpp / 8);
  891. info->fix.smem_len = info->fix.line_length *
  892. info->var.yres_virtual;
  893. buf = dma_alloc_coherent(&pdev->dev, info->fix.smem_len,
  894. &priv->ch[i].dma_handle, GFP_KERNEL);
  895. if (!buf) {
  896. dev_err(&pdev->dev, "unable to allocate buffer\n");
  897. error = -ENOMEM;
  898. break;
  899. }
  900. info->pseudo_palette = &priv->ch[i].pseudo_palette;
  901. info->flags = FBINFO_FLAG_DEFAULT;
  902. error = fb_alloc_cmap(&info->cmap, PALETTE_NR, 0);
  903. if (error < 0) {
  904. dev_err(&pdev->dev, "unable to allocate cmap\n");
  905. dma_free_coherent(&pdev->dev, info->fix.smem_len,
  906. buf, priv->ch[i].dma_handle);
  907. break;
  908. }
  909. memset(buf, 0, info->fix.smem_len);
  910. info->fix.smem_start = priv->ch[i].dma_handle;
  911. info->screen_base = buf;
  912. info->device = &pdev->dev;
  913. info->par = &priv->ch[i];
  914. }
  915. if (error)
  916. goto err1;
  917. error = sh_mobile_lcdc_start(priv);
  918. if (error) {
  919. dev_err(&pdev->dev, "unable to start hardware\n");
  920. goto err1;
  921. }
  922. for (i = 0; i < j; i++) {
  923. struct sh_mobile_lcdc_chan *ch = priv->ch + i;
  924. info = ch->info;
  925. if (info->fbdefio) {
  926. ch->sglist = vmalloc(sizeof(struct scatterlist) *
  927. info->fix.smem_len >> PAGE_SHIFT);
  928. if (!ch->sglist) {
  929. dev_err(&pdev->dev, "cannot allocate sglist\n");
  930. goto err1;
  931. }
  932. }
  933. error = register_framebuffer(info);
  934. if (error < 0)
  935. goto err1;
  936. dev_info(info->dev,
  937. "registered %s/%s as %dx%d %dbpp.\n",
  938. pdev->name,
  939. (ch->cfg.chan == LCDC_CHAN_MAINLCD) ?
  940. "mainlcd" : "sublcd",
  941. (int) ch->cfg.lcd_cfg.xres,
  942. (int) ch->cfg.lcd_cfg.yres,
  943. ch->cfg.bpp);
  944. /* deferred io mode: disable clock to save power */
  945. if (info->fbdefio)
  946. sh_mobile_lcdc_clk_off(priv);
  947. }
  948. return 0;
  949. err1:
  950. sh_mobile_lcdc_remove(pdev);
  951. return error;
  952. }
  953. static int sh_mobile_lcdc_remove(struct platform_device *pdev)
  954. {
  955. struct sh_mobile_lcdc_priv *priv = platform_get_drvdata(pdev);
  956. struct fb_info *info;
  957. int i;
  958. for (i = 0; i < ARRAY_SIZE(priv->ch); i++)
  959. if (priv->ch[i].info && priv->ch[i].info->dev)
  960. unregister_framebuffer(priv->ch[i].info);
  961. sh_mobile_lcdc_stop(priv);
  962. for (i = 0; i < ARRAY_SIZE(priv->ch); i++) {
  963. info = priv->ch[i].info;
  964. if (!info || !info->device)
  965. continue;
  966. if (priv->ch[i].sglist)
  967. vfree(priv->ch[i].sglist);
  968. dma_free_coherent(&pdev->dev, info->fix.smem_len,
  969. info->screen_base, priv->ch[i].dma_handle);
  970. fb_dealloc_cmap(&info->cmap);
  971. framebuffer_release(info);
  972. }
  973. if (priv->dot_clk)
  974. clk_put(priv->dot_clk);
  975. if (priv->dev)
  976. pm_runtime_disable(priv->dev);
  977. if (priv->base)
  978. iounmap(priv->base);
  979. if (priv->irq)
  980. free_irq(priv->irq, priv);
  981. kfree(priv);
  982. return 0;
  983. }
  984. static struct platform_driver sh_mobile_lcdc_driver = {
  985. .driver = {
  986. .name = "sh_mobile_lcdc_fb",
  987. .owner = THIS_MODULE,
  988. .pm = &sh_mobile_lcdc_dev_pm_ops,
  989. },
  990. .probe = sh_mobile_lcdc_probe,
  991. .remove = sh_mobile_lcdc_remove,
  992. };
  993. static int __init sh_mobile_lcdc_init(void)
  994. {
  995. return platform_driver_register(&sh_mobile_lcdc_driver);
  996. }
  997. static void __exit sh_mobile_lcdc_exit(void)
  998. {
  999. platform_driver_unregister(&sh_mobile_lcdc_driver);
  1000. }
  1001. module_init(sh_mobile_lcdc_init);
  1002. module_exit(sh_mobile_lcdc_exit);
  1003. MODULE_DESCRIPTION("SuperH Mobile LCDC Framebuffer driver");
  1004. MODULE_AUTHOR("Magnus Damm <damm@opensource.se>");
  1005. MODULE_LICENSE("GPL v2");