atmel_lcdfb.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151
  1. /*
  2. * Driver for AT91/AT32 LCD Controller
  3. *
  4. * Copyright (C) 2007 Atmel Corporation
  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 for
  8. * more details.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/dma-mapping.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/clk.h>
  15. #include <linux/fb.h>
  16. #include <linux/init.h>
  17. #include <linux/delay.h>
  18. #include <linux/backlight.h>
  19. #include <linux/gfp.h>
  20. #include <mach/board.h>
  21. #include <mach/cpu.h>
  22. #include <asm/gpio.h>
  23. #include <video/atmel_lcdc.h>
  24. #define lcdc_readl(sinfo, reg) __raw_readl((sinfo)->mmio+(reg))
  25. #define lcdc_writel(sinfo, reg, val) __raw_writel((val), (sinfo)->mmio+(reg))
  26. /* configurable parameters */
  27. #define ATMEL_LCDC_CVAL_DEFAULT 0xc8
  28. #define ATMEL_LCDC_DMA_BURST_LEN 8 /* words */
  29. #define ATMEL_LCDC_FIFO_SIZE 512 /* words */
  30. #if defined(CONFIG_ARCH_AT91)
  31. #define ATMEL_LCDFB_FBINFO_DEFAULT (FBINFO_DEFAULT \
  32. | FBINFO_PARTIAL_PAN_OK \
  33. | FBINFO_HWACCEL_YPAN)
  34. static inline void atmel_lcdfb_update_dma2d(struct atmel_lcdfb_info *sinfo,
  35. struct fb_var_screeninfo *var,
  36. struct fb_info *info)
  37. {
  38. }
  39. #elif defined(CONFIG_AVR32)
  40. #define ATMEL_LCDFB_FBINFO_DEFAULT (FBINFO_DEFAULT \
  41. | FBINFO_PARTIAL_PAN_OK \
  42. | FBINFO_HWACCEL_XPAN \
  43. | FBINFO_HWACCEL_YPAN)
  44. static void atmel_lcdfb_update_dma2d(struct atmel_lcdfb_info *sinfo,
  45. struct fb_var_screeninfo *var,
  46. struct fb_info *info)
  47. {
  48. u32 dma2dcfg;
  49. u32 pixeloff;
  50. pixeloff = (var->xoffset * info->var.bits_per_pixel) & 0x1f;
  51. dma2dcfg = (info->var.xres_virtual - info->var.xres)
  52. * info->var.bits_per_pixel / 8;
  53. dma2dcfg |= pixeloff << ATMEL_LCDC_PIXELOFF_OFFSET;
  54. lcdc_writel(sinfo, ATMEL_LCDC_DMA2DCFG, dma2dcfg);
  55. /* Update configuration */
  56. lcdc_writel(sinfo, ATMEL_LCDC_DMACON,
  57. lcdc_readl(sinfo, ATMEL_LCDC_DMACON)
  58. | ATMEL_LCDC_DMAUPDT);
  59. }
  60. #endif
  61. static u32 contrast_ctr = ATMEL_LCDC_PS_DIV8
  62. | ATMEL_LCDC_POL_POSITIVE
  63. | ATMEL_LCDC_ENA_PWMENABLE;
  64. #ifdef CONFIG_BACKLIGHT_ATMEL_LCDC
  65. /* some bl->props field just changed */
  66. static int atmel_bl_update_status(struct backlight_device *bl)
  67. {
  68. struct atmel_lcdfb_info *sinfo = bl_get_data(bl);
  69. int power = sinfo->bl_power;
  70. int brightness = bl->props.brightness;
  71. /* REVISIT there may be a meaningful difference between
  72. * fb_blank and power ... there seem to be some cases
  73. * this doesn't handle correctly.
  74. */
  75. if (bl->props.fb_blank != sinfo->bl_power)
  76. power = bl->props.fb_blank;
  77. else if (bl->props.power != sinfo->bl_power)
  78. power = bl->props.power;
  79. if (brightness < 0 && power == FB_BLANK_UNBLANK)
  80. brightness = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL);
  81. else if (power != FB_BLANK_UNBLANK)
  82. brightness = 0;
  83. lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, brightness);
  84. lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR,
  85. brightness ? contrast_ctr : 0);
  86. bl->props.fb_blank = bl->props.power = sinfo->bl_power = power;
  87. return 0;
  88. }
  89. static int atmel_bl_get_brightness(struct backlight_device *bl)
  90. {
  91. struct atmel_lcdfb_info *sinfo = bl_get_data(bl);
  92. return lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL);
  93. }
  94. static const struct backlight_ops atmel_lcdc_bl_ops = {
  95. .update_status = atmel_bl_update_status,
  96. .get_brightness = atmel_bl_get_brightness,
  97. };
  98. static void init_backlight(struct atmel_lcdfb_info *sinfo)
  99. {
  100. struct backlight_properties props;
  101. struct backlight_device *bl;
  102. sinfo->bl_power = FB_BLANK_UNBLANK;
  103. if (sinfo->backlight)
  104. return;
  105. memset(&props, 0, sizeof(struct backlight_properties));
  106. props.type = BACKLIGHT_RAW;
  107. props.max_brightness = 0xff;
  108. bl = backlight_device_register("backlight", &sinfo->pdev->dev, sinfo,
  109. &atmel_lcdc_bl_ops, &props);
  110. if (IS_ERR(bl)) {
  111. dev_err(&sinfo->pdev->dev, "error %ld on backlight register\n",
  112. PTR_ERR(bl));
  113. return;
  114. }
  115. sinfo->backlight = bl;
  116. bl->props.power = FB_BLANK_UNBLANK;
  117. bl->props.fb_blank = FB_BLANK_UNBLANK;
  118. bl->props.brightness = atmel_bl_get_brightness(bl);
  119. }
  120. static void exit_backlight(struct atmel_lcdfb_info *sinfo)
  121. {
  122. if (sinfo->backlight)
  123. backlight_device_unregister(sinfo->backlight);
  124. }
  125. #else
  126. static void init_backlight(struct atmel_lcdfb_info *sinfo)
  127. {
  128. dev_warn(&sinfo->pdev->dev, "backlight control is not available\n");
  129. }
  130. static void exit_backlight(struct atmel_lcdfb_info *sinfo)
  131. {
  132. }
  133. #endif
  134. static void init_contrast(struct atmel_lcdfb_info *sinfo)
  135. {
  136. /* contrast pwm can be 'inverted' */
  137. if (sinfo->lcdcon_pol_negative)
  138. contrast_ctr &= ~(ATMEL_LCDC_POL_POSITIVE);
  139. /* have some default contrast/backlight settings */
  140. lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, contrast_ctr);
  141. lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, ATMEL_LCDC_CVAL_DEFAULT);
  142. if (sinfo->lcdcon_is_backlight)
  143. init_backlight(sinfo);
  144. }
  145. static struct fb_fix_screeninfo atmel_lcdfb_fix __initdata = {
  146. .type = FB_TYPE_PACKED_PIXELS,
  147. .visual = FB_VISUAL_TRUECOLOR,
  148. .xpanstep = 0,
  149. .ypanstep = 1,
  150. .ywrapstep = 0,
  151. .accel = FB_ACCEL_NONE,
  152. };
  153. static unsigned long compute_hozval(unsigned long xres, unsigned long lcdcon2)
  154. {
  155. unsigned long value;
  156. if (!(cpu_is_at91sam9261() || cpu_is_at91sam9g10()
  157. || cpu_is_at32ap7000()))
  158. return xres;
  159. value = xres;
  160. if ((lcdcon2 & ATMEL_LCDC_DISTYPE) != ATMEL_LCDC_DISTYPE_TFT) {
  161. /* STN display */
  162. if ((lcdcon2 & ATMEL_LCDC_DISTYPE) == ATMEL_LCDC_DISTYPE_STNCOLOR) {
  163. value *= 3;
  164. }
  165. if ( (lcdcon2 & ATMEL_LCDC_IFWIDTH) == ATMEL_LCDC_IFWIDTH_4
  166. || ( (lcdcon2 & ATMEL_LCDC_IFWIDTH) == ATMEL_LCDC_IFWIDTH_8
  167. && (lcdcon2 & ATMEL_LCDC_SCANMOD) == ATMEL_LCDC_SCANMOD_DUAL ))
  168. value = DIV_ROUND_UP(value, 4);
  169. else
  170. value = DIV_ROUND_UP(value, 8);
  171. }
  172. return value;
  173. }
  174. static void atmel_lcdfb_stop_nowait(struct atmel_lcdfb_info *sinfo)
  175. {
  176. /* Turn off the LCD controller and the DMA controller */
  177. lcdc_writel(sinfo, ATMEL_LCDC_PWRCON,
  178. sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET);
  179. /* Wait for the LCDC core to become idle */
  180. while (lcdc_readl(sinfo, ATMEL_LCDC_PWRCON) & ATMEL_LCDC_BUSY)
  181. msleep(10);
  182. lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0);
  183. }
  184. static void atmel_lcdfb_stop(struct atmel_lcdfb_info *sinfo)
  185. {
  186. atmel_lcdfb_stop_nowait(sinfo);
  187. /* Wait for DMA engine to become idle... */
  188. while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY)
  189. msleep(10);
  190. }
  191. static void atmel_lcdfb_start(struct atmel_lcdfb_info *sinfo)
  192. {
  193. lcdc_writel(sinfo, ATMEL_LCDC_DMACON, sinfo->default_dmacon);
  194. lcdc_writel(sinfo, ATMEL_LCDC_PWRCON,
  195. (sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET)
  196. | ATMEL_LCDC_PWR);
  197. }
  198. static void atmel_lcdfb_update_dma(struct fb_info *info,
  199. struct fb_var_screeninfo *var)
  200. {
  201. struct atmel_lcdfb_info *sinfo = info->par;
  202. struct fb_fix_screeninfo *fix = &info->fix;
  203. unsigned long dma_addr;
  204. dma_addr = (fix->smem_start + var->yoffset * fix->line_length
  205. + var->xoffset * info->var.bits_per_pixel / 8);
  206. dma_addr &= ~3UL;
  207. /* Set framebuffer DMA base address and pixel offset */
  208. lcdc_writel(sinfo, ATMEL_LCDC_DMABADDR1, dma_addr);
  209. atmel_lcdfb_update_dma2d(sinfo, var, info);
  210. }
  211. static inline void atmel_lcdfb_free_video_memory(struct atmel_lcdfb_info *sinfo)
  212. {
  213. struct fb_info *info = sinfo->info;
  214. dma_free_writecombine(info->device, info->fix.smem_len,
  215. info->screen_base, info->fix.smem_start);
  216. }
  217. /**
  218. * atmel_lcdfb_alloc_video_memory - Allocate framebuffer memory
  219. * @sinfo: the frame buffer to allocate memory for
  220. *
  221. * This function is called only from the atmel_lcdfb_probe()
  222. * so no locking by fb_info->mm_lock around smem_len setting is needed.
  223. */
  224. static int atmel_lcdfb_alloc_video_memory(struct atmel_lcdfb_info *sinfo)
  225. {
  226. struct fb_info *info = sinfo->info;
  227. struct fb_var_screeninfo *var = &info->var;
  228. unsigned int smem_len;
  229. smem_len = (var->xres_virtual * var->yres_virtual
  230. * ((var->bits_per_pixel + 7) / 8));
  231. info->fix.smem_len = max(smem_len, sinfo->smem_len);
  232. info->screen_base = dma_alloc_writecombine(info->device, info->fix.smem_len,
  233. (dma_addr_t *)&info->fix.smem_start, GFP_KERNEL);
  234. if (!info->screen_base) {
  235. return -ENOMEM;
  236. }
  237. memset(info->screen_base, 0, info->fix.smem_len);
  238. return 0;
  239. }
  240. static const struct fb_videomode *atmel_lcdfb_choose_mode(struct fb_var_screeninfo *var,
  241. struct fb_info *info)
  242. {
  243. struct fb_videomode varfbmode;
  244. const struct fb_videomode *fbmode = NULL;
  245. fb_var_to_videomode(&varfbmode, var);
  246. fbmode = fb_find_nearest_mode(&varfbmode, &info->modelist);
  247. if (fbmode)
  248. fb_videomode_to_var(var, fbmode);
  249. return fbmode;
  250. }
  251. /**
  252. * atmel_lcdfb_check_var - Validates a var passed in.
  253. * @var: frame buffer variable screen structure
  254. * @info: frame buffer structure that represents a single frame buffer
  255. *
  256. * Checks to see if the hardware supports the state requested by
  257. * var passed in. This function does not alter the hardware
  258. * state!!! This means the data stored in struct fb_info and
  259. * struct atmel_lcdfb_info do not change. This includes the var
  260. * inside of struct fb_info. Do NOT change these. This function
  261. * can be called on its own if we intent to only test a mode and
  262. * not actually set it. The stuff in modedb.c is a example of
  263. * this. If the var passed in is slightly off by what the
  264. * hardware can support then we alter the var PASSED in to what
  265. * we can do. If the hardware doesn't support mode change a
  266. * -EINVAL will be returned by the upper layers. You don't need
  267. * to implement this function then. If you hardware doesn't
  268. * support changing the resolution then this function is not
  269. * needed. In this case the driver would just provide a var that
  270. * represents the static state the screen is in.
  271. *
  272. * Returns negative errno on error, or zero on success.
  273. */
  274. static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
  275. struct fb_info *info)
  276. {
  277. struct device *dev = info->device;
  278. struct atmel_lcdfb_info *sinfo = info->par;
  279. unsigned long clk_value_khz;
  280. clk_value_khz = clk_get_rate(sinfo->lcdc_clk) / 1000;
  281. dev_dbg(dev, "%s:\n", __func__);
  282. if (!(var->pixclock && var->bits_per_pixel)) {
  283. /* choose a suitable mode if possible */
  284. if (!atmel_lcdfb_choose_mode(var, info)) {
  285. dev_err(dev, "needed value not specified\n");
  286. return -EINVAL;
  287. }
  288. }
  289. dev_dbg(dev, " resolution: %ux%u\n", var->xres, var->yres);
  290. dev_dbg(dev, " pixclk: %lu KHz\n", PICOS2KHZ(var->pixclock));
  291. dev_dbg(dev, " bpp: %u\n", var->bits_per_pixel);
  292. dev_dbg(dev, " clk: %lu KHz\n", clk_value_khz);
  293. if (PICOS2KHZ(var->pixclock) > clk_value_khz) {
  294. dev_err(dev, "%lu KHz pixel clock is too fast\n", PICOS2KHZ(var->pixclock));
  295. return -EINVAL;
  296. }
  297. /* Do not allow to have real resoulution larger than virtual */
  298. if (var->xres > var->xres_virtual)
  299. var->xres_virtual = var->xres;
  300. if (var->yres > var->yres_virtual)
  301. var->yres_virtual = var->yres;
  302. /* Force same alignment for each line */
  303. var->xres = (var->xres + 3) & ~3UL;
  304. var->xres_virtual = (var->xres_virtual + 3) & ~3UL;
  305. var->red.msb_right = var->green.msb_right = var->blue.msb_right = 0;
  306. var->transp.msb_right = 0;
  307. var->transp.offset = var->transp.length = 0;
  308. var->xoffset = var->yoffset = 0;
  309. if (info->fix.smem_len) {
  310. unsigned int smem_len = (var->xres_virtual * var->yres_virtual
  311. * ((var->bits_per_pixel + 7) / 8));
  312. if (smem_len > info->fix.smem_len)
  313. return -EINVAL;
  314. }
  315. /* Saturate vertical and horizontal timings at maximum values */
  316. var->vsync_len = min_t(u32, var->vsync_len,
  317. (ATMEL_LCDC_VPW >> ATMEL_LCDC_VPW_OFFSET) + 1);
  318. var->upper_margin = min_t(u32, var->upper_margin,
  319. ATMEL_LCDC_VBP >> ATMEL_LCDC_VBP_OFFSET);
  320. var->lower_margin = min_t(u32, var->lower_margin,
  321. ATMEL_LCDC_VFP);
  322. var->right_margin = min_t(u32, var->right_margin,
  323. (ATMEL_LCDC_HFP >> ATMEL_LCDC_HFP_OFFSET) + 1);
  324. var->hsync_len = min_t(u32, var->hsync_len,
  325. (ATMEL_LCDC_HPW >> ATMEL_LCDC_HPW_OFFSET) + 1);
  326. var->left_margin = min_t(u32, var->left_margin,
  327. ATMEL_LCDC_HBP + 1);
  328. /* Some parameters can't be zero */
  329. var->vsync_len = max_t(u32, var->vsync_len, 1);
  330. var->right_margin = max_t(u32, var->right_margin, 1);
  331. var->hsync_len = max_t(u32, var->hsync_len, 1);
  332. var->left_margin = max_t(u32, var->left_margin, 1);
  333. switch (var->bits_per_pixel) {
  334. case 1:
  335. case 2:
  336. case 4:
  337. case 8:
  338. var->red.offset = var->green.offset = var->blue.offset = 0;
  339. var->red.length = var->green.length = var->blue.length
  340. = var->bits_per_pixel;
  341. break;
  342. case 15:
  343. case 16:
  344. if (sinfo->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
  345. /* RGB:565 mode */
  346. var->red.offset = 11;
  347. var->blue.offset = 0;
  348. var->green.length = 6;
  349. } else if (sinfo->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB555) {
  350. var->red.offset = 10;
  351. var->blue.offset = 0;
  352. var->green.length = 5;
  353. } else {
  354. /* BGR:555 mode */
  355. var->red.offset = 0;
  356. var->blue.offset = 10;
  357. var->green.length = 5;
  358. }
  359. var->green.offset = 5;
  360. var->red.length = var->blue.length = 5;
  361. break;
  362. case 32:
  363. var->transp.offset = 24;
  364. var->transp.length = 8;
  365. /* fall through */
  366. case 24:
  367. if (sinfo->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
  368. /* RGB:888 mode */
  369. var->red.offset = 16;
  370. var->blue.offset = 0;
  371. } else {
  372. /* BGR:888 mode */
  373. var->red.offset = 0;
  374. var->blue.offset = 16;
  375. }
  376. var->green.offset = 8;
  377. var->red.length = var->green.length = var->blue.length = 8;
  378. break;
  379. default:
  380. dev_err(dev, "color depth %d not supported\n",
  381. var->bits_per_pixel);
  382. return -EINVAL;
  383. }
  384. return 0;
  385. }
  386. /*
  387. * LCD reset sequence
  388. */
  389. static void atmel_lcdfb_reset(struct atmel_lcdfb_info *sinfo)
  390. {
  391. might_sleep();
  392. atmel_lcdfb_stop(sinfo);
  393. atmel_lcdfb_start(sinfo);
  394. }
  395. /**
  396. * atmel_lcdfb_set_par - Alters the hardware state.
  397. * @info: frame buffer structure that represents a single frame buffer
  398. *
  399. * Using the fb_var_screeninfo in fb_info we set the resolution
  400. * of the this particular framebuffer. This function alters the
  401. * par AND the fb_fix_screeninfo stored in fb_info. It doesn't
  402. * not alter var in fb_info since we are using that data. This
  403. * means we depend on the data in var inside fb_info to be
  404. * supported by the hardware. atmel_lcdfb_check_var is always called
  405. * before atmel_lcdfb_set_par to ensure this. Again if you can't
  406. * change the resolution you don't need this function.
  407. *
  408. */
  409. static int atmel_lcdfb_set_par(struct fb_info *info)
  410. {
  411. struct atmel_lcdfb_info *sinfo = info->par;
  412. unsigned long hozval_linesz;
  413. unsigned long value;
  414. unsigned long clk_value_khz;
  415. unsigned long bits_per_line;
  416. unsigned long pix_factor = 2;
  417. might_sleep();
  418. dev_dbg(info->device, "%s:\n", __func__);
  419. dev_dbg(info->device, " * resolution: %ux%u (%ux%u virtual)\n",
  420. info->var.xres, info->var.yres,
  421. info->var.xres_virtual, info->var.yres_virtual);
  422. atmel_lcdfb_stop_nowait(sinfo);
  423. if (info->var.bits_per_pixel == 1)
  424. info->fix.visual = FB_VISUAL_MONO01;
  425. else if (info->var.bits_per_pixel <= 8)
  426. info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
  427. else
  428. info->fix.visual = FB_VISUAL_TRUECOLOR;
  429. bits_per_line = info->var.xres_virtual * info->var.bits_per_pixel;
  430. info->fix.line_length = DIV_ROUND_UP(bits_per_line, 8);
  431. /* Re-initialize the DMA engine... */
  432. dev_dbg(info->device, " * update DMA engine\n");
  433. atmel_lcdfb_update_dma(info, &info->var);
  434. /* ...set frame size and burst length = 8 words (?) */
  435. value = (info->var.yres * info->var.xres * info->var.bits_per_pixel) / 32;
  436. value |= ((ATMEL_LCDC_DMA_BURST_LEN - 1) << ATMEL_LCDC_BLENGTH_OFFSET);
  437. lcdc_writel(sinfo, ATMEL_LCDC_DMAFRMCFG, value);
  438. /* Now, the LCDC core... */
  439. /* Set pixel clock */
  440. if (cpu_is_at91sam9g45() && !cpu_is_at91sam9g45es())
  441. pix_factor = 1;
  442. clk_value_khz = clk_get_rate(sinfo->lcdc_clk) / 1000;
  443. value = DIV_ROUND_UP(clk_value_khz, PICOS2KHZ(info->var.pixclock));
  444. if (value < pix_factor) {
  445. dev_notice(info->device, "Bypassing pixel clock divider\n");
  446. lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, ATMEL_LCDC_BYPASS);
  447. } else {
  448. value = (value / pix_factor) - 1;
  449. dev_dbg(info->device, " * programming CLKVAL = 0x%08lx\n",
  450. value);
  451. lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1,
  452. value << ATMEL_LCDC_CLKVAL_OFFSET);
  453. info->var.pixclock =
  454. KHZ2PICOS(clk_value_khz / (pix_factor * (value + 1)));
  455. dev_dbg(info->device, " updated pixclk: %lu KHz\n",
  456. PICOS2KHZ(info->var.pixclock));
  457. }
  458. /* Initialize control register 2 */
  459. value = sinfo->default_lcdcon2;
  460. if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT))
  461. value |= ATMEL_LCDC_INVLINE_INVERTED;
  462. if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT))
  463. value |= ATMEL_LCDC_INVFRAME_INVERTED;
  464. switch (info->var.bits_per_pixel) {
  465. case 1: value |= ATMEL_LCDC_PIXELSIZE_1; break;
  466. case 2: value |= ATMEL_LCDC_PIXELSIZE_2; break;
  467. case 4: value |= ATMEL_LCDC_PIXELSIZE_4; break;
  468. case 8: value |= ATMEL_LCDC_PIXELSIZE_8; break;
  469. case 15: /* fall through */
  470. case 16: value |= ATMEL_LCDC_PIXELSIZE_16; break;
  471. case 24: value |= ATMEL_LCDC_PIXELSIZE_24; break;
  472. case 32: value |= ATMEL_LCDC_PIXELSIZE_32; break;
  473. default: BUG(); break;
  474. }
  475. dev_dbg(info->device, " * LCDCON2 = %08lx\n", value);
  476. lcdc_writel(sinfo, ATMEL_LCDC_LCDCON2, value);
  477. /* Vertical timing */
  478. value = (info->var.vsync_len - 1) << ATMEL_LCDC_VPW_OFFSET;
  479. value |= info->var.upper_margin << ATMEL_LCDC_VBP_OFFSET;
  480. value |= info->var.lower_margin;
  481. dev_dbg(info->device, " * LCDTIM1 = %08lx\n", value);
  482. lcdc_writel(sinfo, ATMEL_LCDC_TIM1, value);
  483. /* Horizontal timing */
  484. value = (info->var.right_margin - 1) << ATMEL_LCDC_HFP_OFFSET;
  485. value |= (info->var.hsync_len - 1) << ATMEL_LCDC_HPW_OFFSET;
  486. value |= (info->var.left_margin - 1);
  487. dev_dbg(info->device, " * LCDTIM2 = %08lx\n", value);
  488. lcdc_writel(sinfo, ATMEL_LCDC_TIM2, value);
  489. /* Horizontal value (aka line size) */
  490. hozval_linesz = compute_hozval(info->var.xres,
  491. lcdc_readl(sinfo, ATMEL_LCDC_LCDCON2));
  492. /* Display size */
  493. value = (hozval_linesz - 1) << ATMEL_LCDC_HOZVAL_OFFSET;
  494. value |= info->var.yres - 1;
  495. dev_dbg(info->device, " * LCDFRMCFG = %08lx\n", value);
  496. lcdc_writel(sinfo, ATMEL_LCDC_LCDFRMCFG, value);
  497. /* FIFO Threshold: Use formula from data sheet */
  498. value = ATMEL_LCDC_FIFO_SIZE - (2 * ATMEL_LCDC_DMA_BURST_LEN + 3);
  499. lcdc_writel(sinfo, ATMEL_LCDC_FIFO, value);
  500. /* Toggle LCD_MODE every frame */
  501. lcdc_writel(sinfo, ATMEL_LCDC_MVAL, 0);
  502. /* Disable all interrupts */
  503. lcdc_writel(sinfo, ATMEL_LCDC_IDR, ~0UL);
  504. /* Enable FIFO & DMA errors */
  505. lcdc_writel(sinfo, ATMEL_LCDC_IER, ATMEL_LCDC_UFLWI | ATMEL_LCDC_OWRI | ATMEL_LCDC_MERI);
  506. /* ...wait for DMA engine to become idle... */
  507. while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY)
  508. msleep(10);
  509. atmel_lcdfb_start(sinfo);
  510. dev_dbg(info->device, " * DONE\n");
  511. return 0;
  512. }
  513. static inline unsigned int chan_to_field(unsigned int chan, const struct fb_bitfield *bf)
  514. {
  515. chan &= 0xffff;
  516. chan >>= 16 - bf->length;
  517. return chan << bf->offset;
  518. }
  519. /**
  520. * atmel_lcdfb_setcolreg - Optional function. Sets a color register.
  521. * @regno: Which register in the CLUT we are programming
  522. * @red: The red value which can be up to 16 bits wide
  523. * @green: The green value which can be up to 16 bits wide
  524. * @blue: The blue value which can be up to 16 bits wide.
  525. * @transp: If supported the alpha value which can be up to 16 bits wide.
  526. * @info: frame buffer info structure
  527. *
  528. * Set a single color register. The values supplied have a 16 bit
  529. * magnitude which needs to be scaled in this function for the hardware.
  530. * Things to take into consideration are how many color registers, if
  531. * any, are supported with the current color visual. With truecolor mode
  532. * no color palettes are supported. Here a pseudo palette is created
  533. * which we store the value in pseudo_palette in struct fb_info. For
  534. * pseudocolor mode we have a limited color palette. To deal with this
  535. * we can program what color is displayed for a particular pixel value.
  536. * DirectColor is similar in that we can program each color field. If
  537. * we have a static colormap we don't need to implement this function.
  538. *
  539. * Returns negative errno on error, or zero on success. In an
  540. * ideal world, this would have been the case, but as it turns
  541. * out, the other drivers return 1 on failure, so that's what
  542. * we're going to do.
  543. */
  544. static int atmel_lcdfb_setcolreg(unsigned int regno, unsigned int red,
  545. unsigned int green, unsigned int blue,
  546. unsigned int transp, struct fb_info *info)
  547. {
  548. struct atmel_lcdfb_info *sinfo = info->par;
  549. unsigned int val;
  550. u32 *pal;
  551. int ret = 1;
  552. if (info->var.grayscale)
  553. red = green = blue = (19595 * red + 38470 * green
  554. + 7471 * blue) >> 16;
  555. switch (info->fix.visual) {
  556. case FB_VISUAL_TRUECOLOR:
  557. if (regno < 16) {
  558. pal = info->pseudo_palette;
  559. val = chan_to_field(red, &info->var.red);
  560. val |= chan_to_field(green, &info->var.green);
  561. val |= chan_to_field(blue, &info->var.blue);
  562. pal[regno] = val;
  563. ret = 0;
  564. }
  565. break;
  566. case FB_VISUAL_PSEUDOCOLOR:
  567. if (regno < 256) {
  568. val = ((red >> 11) & 0x001f);
  569. val |= ((green >> 6) & 0x03e0);
  570. val |= ((blue >> 1) & 0x7c00);
  571. /*
  572. * TODO: intensity bit. Maybe something like
  573. * ~(red[10] ^ green[10] ^ blue[10]) & 1
  574. */
  575. lcdc_writel(sinfo, ATMEL_LCDC_LUT(regno), val);
  576. ret = 0;
  577. }
  578. break;
  579. case FB_VISUAL_MONO01:
  580. if (regno < 2) {
  581. val = (regno == 0) ? 0x00 : 0x1F;
  582. lcdc_writel(sinfo, ATMEL_LCDC_LUT(regno), val);
  583. ret = 0;
  584. }
  585. break;
  586. }
  587. return ret;
  588. }
  589. static int atmel_lcdfb_pan_display(struct fb_var_screeninfo *var,
  590. struct fb_info *info)
  591. {
  592. dev_dbg(info->device, "%s\n", __func__);
  593. atmel_lcdfb_update_dma(info, var);
  594. return 0;
  595. }
  596. static int atmel_lcdfb_blank(int blank_mode, struct fb_info *info)
  597. {
  598. struct atmel_lcdfb_info *sinfo = info->par;
  599. switch (blank_mode) {
  600. case FB_BLANK_UNBLANK:
  601. case FB_BLANK_NORMAL:
  602. atmel_lcdfb_start(sinfo);
  603. break;
  604. case FB_BLANK_VSYNC_SUSPEND:
  605. case FB_BLANK_HSYNC_SUSPEND:
  606. break;
  607. case FB_BLANK_POWERDOWN:
  608. atmel_lcdfb_stop(sinfo);
  609. break;
  610. default:
  611. return -EINVAL;
  612. }
  613. /* let fbcon do a soft blank for us */
  614. return ((blank_mode == FB_BLANK_NORMAL) ? 1 : 0);
  615. }
  616. static struct fb_ops atmel_lcdfb_ops = {
  617. .owner = THIS_MODULE,
  618. .fb_check_var = atmel_lcdfb_check_var,
  619. .fb_set_par = atmel_lcdfb_set_par,
  620. .fb_setcolreg = atmel_lcdfb_setcolreg,
  621. .fb_blank = atmel_lcdfb_blank,
  622. .fb_pan_display = atmel_lcdfb_pan_display,
  623. .fb_fillrect = cfb_fillrect,
  624. .fb_copyarea = cfb_copyarea,
  625. .fb_imageblit = cfb_imageblit,
  626. };
  627. static irqreturn_t atmel_lcdfb_interrupt(int irq, void *dev_id)
  628. {
  629. struct fb_info *info = dev_id;
  630. struct atmel_lcdfb_info *sinfo = info->par;
  631. u32 status;
  632. status = lcdc_readl(sinfo, ATMEL_LCDC_ISR);
  633. if (status & ATMEL_LCDC_UFLWI) {
  634. dev_warn(info->device, "FIFO underflow %#x\n", status);
  635. /* reset DMA and FIFO to avoid screen shifting */
  636. schedule_work(&sinfo->task);
  637. }
  638. lcdc_writel(sinfo, ATMEL_LCDC_ICR, status);
  639. return IRQ_HANDLED;
  640. }
  641. /*
  642. * LCD controller task (to reset the LCD)
  643. */
  644. static void atmel_lcdfb_task(struct work_struct *work)
  645. {
  646. struct atmel_lcdfb_info *sinfo =
  647. container_of(work, struct atmel_lcdfb_info, task);
  648. atmel_lcdfb_reset(sinfo);
  649. }
  650. static int __init atmel_lcdfb_init_fbinfo(struct atmel_lcdfb_info *sinfo)
  651. {
  652. struct fb_info *info = sinfo->info;
  653. int ret = 0;
  654. info->var.activate |= FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW;
  655. dev_info(info->device,
  656. "%luKiB frame buffer at %08lx (mapped at %p)\n",
  657. (unsigned long)info->fix.smem_len / 1024,
  658. (unsigned long)info->fix.smem_start,
  659. info->screen_base);
  660. /* Allocate colormap */
  661. ret = fb_alloc_cmap(&info->cmap, 256, 0);
  662. if (ret < 0)
  663. dev_err(info->device, "Alloc color map failed\n");
  664. return ret;
  665. }
  666. static void atmel_lcdfb_start_clock(struct atmel_lcdfb_info *sinfo)
  667. {
  668. if (sinfo->bus_clk)
  669. clk_enable(sinfo->bus_clk);
  670. clk_enable(sinfo->lcdc_clk);
  671. }
  672. static void atmel_lcdfb_stop_clock(struct atmel_lcdfb_info *sinfo)
  673. {
  674. if (sinfo->bus_clk)
  675. clk_disable(sinfo->bus_clk);
  676. clk_disable(sinfo->lcdc_clk);
  677. }
  678. static int __init atmel_lcdfb_probe(struct platform_device *pdev)
  679. {
  680. struct device *dev = &pdev->dev;
  681. struct fb_info *info;
  682. struct atmel_lcdfb_info *sinfo;
  683. struct atmel_lcdfb_info *pdata_sinfo;
  684. struct fb_videomode fbmode;
  685. struct resource *regs = NULL;
  686. struct resource *map = NULL;
  687. int ret;
  688. dev_dbg(dev, "%s BEGIN\n", __func__);
  689. ret = -ENOMEM;
  690. info = framebuffer_alloc(sizeof(struct atmel_lcdfb_info), dev);
  691. if (!info) {
  692. dev_err(dev, "cannot allocate memory\n");
  693. goto out;
  694. }
  695. sinfo = info->par;
  696. if (dev->platform_data) {
  697. pdata_sinfo = (struct atmel_lcdfb_info *)dev->platform_data;
  698. sinfo->default_bpp = pdata_sinfo->default_bpp;
  699. sinfo->default_dmacon = pdata_sinfo->default_dmacon;
  700. sinfo->default_lcdcon2 = pdata_sinfo->default_lcdcon2;
  701. sinfo->default_monspecs = pdata_sinfo->default_monspecs;
  702. sinfo->atmel_lcdfb_power_control = pdata_sinfo->atmel_lcdfb_power_control;
  703. sinfo->guard_time = pdata_sinfo->guard_time;
  704. sinfo->smem_len = pdata_sinfo->smem_len;
  705. sinfo->lcdcon_is_backlight = pdata_sinfo->lcdcon_is_backlight;
  706. sinfo->lcdcon_pol_negative = pdata_sinfo->lcdcon_pol_negative;
  707. sinfo->lcd_wiring_mode = pdata_sinfo->lcd_wiring_mode;
  708. } else {
  709. dev_err(dev, "cannot get default configuration\n");
  710. goto free_info;
  711. }
  712. sinfo->info = info;
  713. sinfo->pdev = pdev;
  714. strcpy(info->fix.id, sinfo->pdev->name);
  715. info->flags = ATMEL_LCDFB_FBINFO_DEFAULT;
  716. info->pseudo_palette = sinfo->pseudo_palette;
  717. info->fbops = &atmel_lcdfb_ops;
  718. memcpy(&info->monspecs, sinfo->default_monspecs, sizeof(info->monspecs));
  719. info->fix = atmel_lcdfb_fix;
  720. /* Enable LCDC Clocks */
  721. if (cpu_is_at91sam9261() || cpu_is_at91sam9g10()
  722. || cpu_is_at32ap7000()) {
  723. sinfo->bus_clk = clk_get(dev, "hck1");
  724. if (IS_ERR(sinfo->bus_clk)) {
  725. ret = PTR_ERR(sinfo->bus_clk);
  726. goto free_info;
  727. }
  728. }
  729. sinfo->lcdc_clk = clk_get(dev, "lcdc_clk");
  730. if (IS_ERR(sinfo->lcdc_clk)) {
  731. ret = PTR_ERR(sinfo->lcdc_clk);
  732. goto put_bus_clk;
  733. }
  734. atmel_lcdfb_start_clock(sinfo);
  735. ret = fb_find_mode(&info->var, info, NULL, info->monspecs.modedb,
  736. info->monspecs.modedb_len, info->monspecs.modedb,
  737. sinfo->default_bpp);
  738. if (!ret) {
  739. dev_err(dev, "no suitable video mode found\n");
  740. goto stop_clk;
  741. }
  742. regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  743. if (!regs) {
  744. dev_err(dev, "resources unusable\n");
  745. ret = -ENXIO;
  746. goto stop_clk;
  747. }
  748. sinfo->irq_base = platform_get_irq(pdev, 0);
  749. if (sinfo->irq_base < 0) {
  750. dev_err(dev, "unable to get irq\n");
  751. ret = sinfo->irq_base;
  752. goto stop_clk;
  753. }
  754. /* Initialize video memory */
  755. map = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  756. if (map) {
  757. /* use a pre-allocated memory buffer */
  758. info->fix.smem_start = map->start;
  759. info->fix.smem_len = resource_size(map);
  760. if (!request_mem_region(info->fix.smem_start,
  761. info->fix.smem_len, pdev->name)) {
  762. ret = -EBUSY;
  763. goto stop_clk;
  764. }
  765. info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len);
  766. if (!info->screen_base)
  767. goto release_intmem;
  768. /*
  769. * Don't clear the framebuffer -- someone may have set
  770. * up a splash image.
  771. */
  772. } else {
  773. /* alocate memory buffer */
  774. ret = atmel_lcdfb_alloc_video_memory(sinfo);
  775. if (ret < 0) {
  776. dev_err(dev, "cannot allocate framebuffer: %d\n", ret);
  777. goto stop_clk;
  778. }
  779. }
  780. /* LCDC registers */
  781. info->fix.mmio_start = regs->start;
  782. info->fix.mmio_len = resource_size(regs);
  783. if (!request_mem_region(info->fix.mmio_start,
  784. info->fix.mmio_len, pdev->name)) {
  785. ret = -EBUSY;
  786. goto free_fb;
  787. }
  788. sinfo->mmio = ioremap(info->fix.mmio_start, info->fix.mmio_len);
  789. if (!sinfo->mmio) {
  790. dev_err(dev, "cannot map LCDC registers\n");
  791. goto release_mem;
  792. }
  793. /* Initialize PWM for contrast or backlight ("off") */
  794. init_contrast(sinfo);
  795. /* interrupt */
  796. ret = request_irq(sinfo->irq_base, atmel_lcdfb_interrupt, 0, pdev->name, info);
  797. if (ret) {
  798. dev_err(dev, "request_irq failed: %d\n", ret);
  799. goto unmap_mmio;
  800. }
  801. /* Some operations on the LCDC might sleep and
  802. * require a preemptible task context */
  803. INIT_WORK(&sinfo->task, atmel_lcdfb_task);
  804. ret = atmel_lcdfb_init_fbinfo(sinfo);
  805. if (ret < 0) {
  806. dev_err(dev, "init fbinfo failed: %d\n", ret);
  807. goto unregister_irqs;
  808. }
  809. /*
  810. * This makes sure that our colour bitfield
  811. * descriptors are correctly initialised.
  812. */
  813. atmel_lcdfb_check_var(&info->var, info);
  814. ret = fb_set_var(info, &info->var);
  815. if (ret) {
  816. dev_warn(dev, "unable to set display parameters\n");
  817. goto free_cmap;
  818. }
  819. dev_set_drvdata(dev, info);
  820. /*
  821. * Tell the world that we're ready to go
  822. */
  823. ret = register_framebuffer(info);
  824. if (ret < 0) {
  825. dev_err(dev, "failed to register framebuffer device: %d\n", ret);
  826. goto reset_drvdata;
  827. }
  828. /* add selected videomode to modelist */
  829. fb_var_to_videomode(&fbmode, &info->var);
  830. fb_add_videomode(&fbmode, &info->modelist);
  831. /* Power up the LCDC screen */
  832. if (sinfo->atmel_lcdfb_power_control)
  833. sinfo->atmel_lcdfb_power_control(1);
  834. dev_info(dev, "fb%d: Atmel LCDC at 0x%08lx (mapped at %p), irq %d\n",
  835. info->node, info->fix.mmio_start, sinfo->mmio, sinfo->irq_base);
  836. return 0;
  837. reset_drvdata:
  838. dev_set_drvdata(dev, NULL);
  839. free_cmap:
  840. fb_dealloc_cmap(&info->cmap);
  841. unregister_irqs:
  842. cancel_work_sync(&sinfo->task);
  843. free_irq(sinfo->irq_base, info);
  844. unmap_mmio:
  845. exit_backlight(sinfo);
  846. iounmap(sinfo->mmio);
  847. release_mem:
  848. release_mem_region(info->fix.mmio_start, info->fix.mmio_len);
  849. free_fb:
  850. if (map)
  851. iounmap(info->screen_base);
  852. else
  853. atmel_lcdfb_free_video_memory(sinfo);
  854. release_intmem:
  855. if (map)
  856. release_mem_region(info->fix.smem_start, info->fix.smem_len);
  857. stop_clk:
  858. atmel_lcdfb_stop_clock(sinfo);
  859. clk_put(sinfo->lcdc_clk);
  860. put_bus_clk:
  861. if (sinfo->bus_clk)
  862. clk_put(sinfo->bus_clk);
  863. free_info:
  864. framebuffer_release(info);
  865. out:
  866. dev_dbg(dev, "%s FAILED\n", __func__);
  867. return ret;
  868. }
  869. static int __exit atmel_lcdfb_remove(struct platform_device *pdev)
  870. {
  871. struct device *dev = &pdev->dev;
  872. struct fb_info *info = dev_get_drvdata(dev);
  873. struct atmel_lcdfb_info *sinfo;
  874. if (!info || !info->par)
  875. return 0;
  876. sinfo = info->par;
  877. cancel_work_sync(&sinfo->task);
  878. exit_backlight(sinfo);
  879. if (sinfo->atmel_lcdfb_power_control)
  880. sinfo->atmel_lcdfb_power_control(0);
  881. unregister_framebuffer(info);
  882. atmel_lcdfb_stop_clock(sinfo);
  883. clk_put(sinfo->lcdc_clk);
  884. if (sinfo->bus_clk)
  885. clk_put(sinfo->bus_clk);
  886. fb_dealloc_cmap(&info->cmap);
  887. free_irq(sinfo->irq_base, info);
  888. iounmap(sinfo->mmio);
  889. release_mem_region(info->fix.mmio_start, info->fix.mmio_len);
  890. if (platform_get_resource(pdev, IORESOURCE_MEM, 1)) {
  891. iounmap(info->screen_base);
  892. release_mem_region(info->fix.smem_start, info->fix.smem_len);
  893. } else {
  894. atmel_lcdfb_free_video_memory(sinfo);
  895. }
  896. dev_set_drvdata(dev, NULL);
  897. framebuffer_release(info);
  898. return 0;
  899. }
  900. #ifdef CONFIG_PM
  901. static int atmel_lcdfb_suspend(struct platform_device *pdev, pm_message_t mesg)
  902. {
  903. struct fb_info *info = platform_get_drvdata(pdev);
  904. struct atmel_lcdfb_info *sinfo = info->par;
  905. /*
  906. * We don't want to handle interrupts while the clock is
  907. * stopped. It may take forever.
  908. */
  909. lcdc_writel(sinfo, ATMEL_LCDC_IDR, ~0UL);
  910. sinfo->saved_lcdcon = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL);
  911. lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, 0);
  912. if (sinfo->atmel_lcdfb_power_control)
  913. sinfo->atmel_lcdfb_power_control(0);
  914. atmel_lcdfb_stop(sinfo);
  915. atmel_lcdfb_stop_clock(sinfo);
  916. return 0;
  917. }
  918. static int atmel_lcdfb_resume(struct platform_device *pdev)
  919. {
  920. struct fb_info *info = platform_get_drvdata(pdev);
  921. struct atmel_lcdfb_info *sinfo = info->par;
  922. atmel_lcdfb_start_clock(sinfo);
  923. atmel_lcdfb_start(sinfo);
  924. if (sinfo->atmel_lcdfb_power_control)
  925. sinfo->atmel_lcdfb_power_control(1);
  926. lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, sinfo->saved_lcdcon);
  927. /* Enable FIFO & DMA errors */
  928. lcdc_writel(sinfo, ATMEL_LCDC_IER, ATMEL_LCDC_UFLWI
  929. | ATMEL_LCDC_OWRI | ATMEL_LCDC_MERI);
  930. return 0;
  931. }
  932. #else
  933. #define atmel_lcdfb_suspend NULL
  934. #define atmel_lcdfb_resume NULL
  935. #endif
  936. static struct platform_driver atmel_lcdfb_driver = {
  937. .remove = __exit_p(atmel_lcdfb_remove),
  938. .suspend = atmel_lcdfb_suspend,
  939. .resume = atmel_lcdfb_resume,
  940. .driver = {
  941. .name = "atmel_lcdfb",
  942. .owner = THIS_MODULE,
  943. },
  944. };
  945. static int __init atmel_lcdfb_init(void)
  946. {
  947. return platform_driver_probe(&atmel_lcdfb_driver, atmel_lcdfb_probe);
  948. }
  949. static void __exit atmel_lcdfb_exit(void)
  950. {
  951. platform_driver_unregister(&atmel_lcdfb_driver);
  952. }
  953. module_init(atmel_lcdfb_init);
  954. module_exit(atmel_lcdfb_exit);
  955. MODULE_DESCRIPTION("AT91/AT32 LCD Controller framebuffer driver");
  956. MODULE_AUTHOR("Nicolas Ferre <nicolas.ferre@atmel.com>");
  957. MODULE_LICENSE("GPL");